added .breadcrumbs method to Page drop. It gives all the ancestors of the page and the page itself

This commit is contained in:
Rytis Lukoševičius 2011-08-14 11:34:57 +03:00
parent 025d5a7dda
commit 69e24e8fe0
2 changed files with 15 additions and 0 deletions

View File

@ -16,6 +16,10 @@ module Locomotive
def parent
@parent ||= self._source.parent.to_liquid
end
def breadcrumbs
@breadcrumbs ||= liquify(*self._source.self_and_ancestors)
end
def children
@children ||= liquify(*self._source.children)

View File

@ -52,6 +52,17 @@ describe Locomotive::Liquid::Drops::Page do
end
end
context '#breadcrumbs' do
before(:each) do
@sub_page = Factory.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
end
it 'renders breadcrumbs of current page' do
content = render_template '{% for crumb in sub_page.breadcrumbs %}{{ crumb.title}},{% endfor %}', {'sub_page' => @sub_page}
content.should == 'Home page,Subpage,'
end
end
context '#rendering page title' do