added .parent method to Page drop
This commit is contained in:
parent
b23f2697e9
commit
025d5a7dda
@ -12,6 +12,10 @@ module Locomotive
|
||||
def slug
|
||||
self._source.templatized? ? self._source.content_type.slug.singularize : self._source.slug
|
||||
end
|
||||
|
||||
def parent
|
||||
@parent ||= self._source.parent.to_liquid
|
||||
end
|
||||
|
||||
def children
|
||||
@children ||= liquify(*self._source.children)
|
||||
|
@ -98,6 +98,14 @@ Factory.define :page do |p|
|
||||
p.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||
end
|
||||
|
||||
Factory.define :sub_page, :parent => :page do |p|
|
||||
p.title 'Subpage'
|
||||
p.slug 'subpage'
|
||||
p.published true
|
||||
p.site { Site.where(:subdomain => "acme").first || Factory(:site) }
|
||||
p.parent { Page.where(:slug => "index").first || Factory(:page) }
|
||||
end
|
||||
|
||||
|
||||
## Snippets ##
|
||||
Factory.define :snippet do |s|
|
||||
|
@ -40,6 +40,18 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context '#parent' do
|
||||
before(:each) do
|
||||
@sub_page = Factory.build(:sub_page, :meta_keywords => 'Sub Libidinous, Angsty', :meta_description => "Sub Quite the combination.")
|
||||
end
|
||||
|
||||
it 'renders title of parent page' do
|
||||
content = render_template '{{ sub_page.parent.title }}', {'sub_page' => @sub_page}
|
||||
content.should == "Home page"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context '#rendering page title' do
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user