Sha256: c0003f5526808d7f3bcac8a934a32a1d1f37d587948fb558e5afd2c49f88aef4

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Page, "with concurrent draft" do
  dataset :pages_with_layouts
  before :each do
    @page = pages(:home)
  end
  
  it "should be publishable" do
    @page.publishable?.should be_true
  end

  describe "when promoting" do
  
    it "should promote its page parts" do
      @page.parts.should_receive(:reload).and_return(@page.parts)
      @page.parts.each {|part| part.should_receive(:promote_draft!) }
      @page.promote_draft!
    end

    it "should update its status to published" do
      @page.update_attribute('status_id', Status[:draft].id)
      @page.promote_draft!
      @page.reload.status.should == Status[:published]
      @page.published?.should be_true
    end
  end
  
  describe "when unpublishing" do
    
    before(:each) do
      @page.promote_draft!
      @page.unpublish!
    end
    
    it "should set the content of its page parts to nil" do
      @page.parts.each {|part| part.content.should be_nil}
    end
    
    it "should retain its draft content" do
      @page.part("body").should_not be_nil
    end    
  
    it "should set published_at, draft_promoted_at and draft_promotion_scheduled_at dates to nil" do
      @page.published_at.should be_nil
      @page.draft_promoted_at.should be_nil
      @page.draft_promotion_scheduled_at.should be_nil
    end  
    
    it "should update its status to draft" do
      @page.reload.status.should == Status[:draft]
      @page.published?.should be_false
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
radiant-concurrent_draft-extension-1.0.7 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.6 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.5 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.4 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.3 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.2 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.1 spec/models/page_extensions_spec.rb
radiant-concurrent_draft-extension-1.0.0 spec/models/page_extensions_spec.rb