need to reject templatized pages, because they're not real pages.

Also using children with minimal attributes, like top level.
This commit is contained in:
Dirk Kelly 2011-01-24 23:14:29 +08:00
parent f512b417f5
commit 825521a5d4
2 changed files with 11 additions and 2 deletions

View File

@ -95,7 +95,7 @@ module Locomotive
def render_entry_children(page,depth)
output = %{}
children = page.children
children = page.children_with_minimal_attributes.reject { |c| c.templatized? }
if children.present?
output = %{<ul id="#{@options[:id]}-#{page.slug.dasherize}">}
children.each do |c, page|

View File

@ -13,7 +13,8 @@ describe Locomotive::Liquid::Tags::Nav do
other_children = [
Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true)
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true)
]
@home.children.last.stubs(:children_with_minimal_attributes).returns(other_children)
@home.children.last.stubs(:children).returns(other_children)
@ -43,12 +44,20 @@ describe Locomotive::Liquid::Tags::Nav do
it 'renders children to depth' do
output = render_nav('site', {}, 'depth: 2')
output.should match /<ul id="nav">/
output.should match /<li id="child-1" class="link first">/
output.should match /<\/a><ul id="nav-child-2">/
output.should match /<li id="sub-child-1" class="link first">/
output.should match /<li id="sub-child-2" class="link last">/
output.should match /<\/a><\/li><\/ul><\/li><\/ul>/
end
it 'does not render templatized pages' do
output = render_nav('site', {}, 'depth: 2')
output.should_not match /sub-child-template-3/
end
it 'adds an icon before the link' do
render_nav('site', {}, 'icon: true').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/