Sha256: 32daa6df69e42bd349365314e2770e0740dfea9d7367b8ab2399a3d02935ce27

Contents?: true

Size: 1.24 KB

Versions: 13

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

module Brightcontent
  describe Page do
    describe "validations" do
      it "validates persence of name" do
        build_stubbed(:page, name: nil).should_not be_valid
      end
    end

    describe "slugs" do
      context "first page" do
        subject { create(:page, name: "Homepage") }
        its(:slug) { should be_empty }
      end

      context "second page" do
        let!(:homepage) { create(:page, name: "Homepage") }

        it "generates slug for siblings" do
          create(:page, name: "About us").slug.should eq "about-us"
        end

        it "creates a slug for children" do
          create(:page, name: "About us", parent: homepage).slug.should eq "homepage/about-us"
        end

        it "persists the slug" do
          page = create(:page, name: "About us", parent: homepage).reload
          page.slug.should eq "homepage/about-us"
        end
      end
    end

    describe ".homepage?" do
      subject { create(:page, name: "Homepage") }

      context "is homepage" do
        it { should be_homepage }
      end

      context "is not homepage" do
        before { create(:page) }
        subject { create(:page, name: "Second_page") }
        it { should_not be_homepage }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
brightcontent-pages-2.0.8 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.7 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.6 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.5 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.3 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.2 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.1 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.0.alpha6 spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.0.alpha5 spec/models/brightcontent/page_spec.rb
brightcontent-2.0.0.alpha3 pages/spec/models/brightcontent/page_spec.rb
brightcontent-pages-2.0.0.alpha3 spec/models/brightcontent/page_spec.rb
brightcontent-2.0.0.alpha2 pages/spec/models/brightcontent/page_spec.rb
brightcontent-pages-0.0.1 spec/models/brightcontent/page_spec.rb