spec/models/brightcontent/page_spec.rb in brightcontent-pages-2.0.33 vs spec/models/brightcontent/page_spec.rb in brightcontent-pages-2.1.0

- old
+ new

@@ -6,10 +6,31 @@ it "validates persence of name" do build_stubbed(:page, name: nil).should_not be_valid end end + describe "callbacks" do + it 'expires path cache after commit' do + expect(Pages::PathConstraint).to receive(:expire) + create(:page) + end + end + + describe "#find_by_path" do + it 'finds the page by path' do + create(:page) + page = create(:page, name: "About us") + expect(Page.find_by_path('/about-us')).to eq page + end + end + + describe '#sanitize_path' do + it 'removes the leading slash' do + expect(Page.sanitize_path('/path')).to eq 'path' + end + end + describe "slugs" do context "first page" do subject { create(:page, name: "Homepage") } its(:slug) { should be_empty } end @@ -53,31 +74,7 @@ before { create(:page) } subject { create(:page, name: "Second_page") } it { should_not be_homepage } end end - - describe "root_parent_children" do - it "returns the children if page is root element" do - root, child = build(:page), build(:page) - root.children << child - root.root_parent_children.should == [child] - end - - it "returns the children of parent if page has parent" do - root, page, child = create(:page), create(:page), create(:page) - root.children << page - page.children << child - page.root_parent_children.should == [page] - end - - it "returns the children of root parent if page has multiple parent" do - root1, root2, page = create(:page), create(:page), create(:page) - root1.children << root2 - root2.children << page - page.root_parent_children.should == [root2] - end - - end - end end