Sha256: 733408578b961a1830b59c00569407dbe6e50d9f38f37d9774240c93a2620298

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe ManageableContent::Page do

  context "fields" do
    it { should have_db_column(:key).of_type(:string) }
    it { should have_db_column(:locale).of_type(:string) }
    it { should have_db_column(:created_at).of_type(:datetime) }
    it { should have_db_column(:updated_at).of_type(:datetime) }

    it { should have_db_index([:key, :locale]).unique(true) }
  end

  context "mass assignment" do
    it { should allow_mass_assignment_of(:page_contents_attributes) }

    it { should_not allow_mass_assignment_of(:key) }
    it { should_not allow_mass_assignment_of(:locale) }
    it { should_not allow_mass_assignment_of(:updated_at) }
    it { should_not allow_mass_assignment_of(:created_at) }

    it { should allow_mass_assignment_of(:page_contents_attributes) }
  end

  context "validations" do
    it { should validate_presence_of(:locale) }
  end

  context "associations" do
    it { should have_many(:page_contents) }
  end

  context "instance methods" do
    before :each do
      @page         = create(:page, :key => 'the/example', :locale => I18n.locale)
      @page_content = create(:page_content, :page => @page, :key => 'mycontent')
    end

    it "should retrieve correct content with :page_content" do
      @page.page_content(:mycontent).should == @page_content
    end

    it "should retrieve correct content with :content" do
      @page.content(:mycontent).should == @page_content.content
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
manageable_content-0.2.6 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.5 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.4 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.3 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.2 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.1 spec/models/manageable_content/page_spec.rb
manageable_content-0.2.0 spec/models/manageable_content/page_spec.rb
manageable_content-0.1.1 spec/models/manageable_content/page_spec.rb
manageable_content-0.0.1 spec/models/manageable_content/page_spec.rb