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:
parent
f512b417f5
commit
825521a5d4
|
@ -95,7 +95,7 @@ module Locomotive
|
||||||
def render_entry_children(page,depth)
|
def render_entry_children(page,depth)
|
||||||
output = %{}
|
output = %{}
|
||||||
|
|
||||||
children = page.children
|
children = page.children_with_minimal_attributes.reject { |c| c.templatized? }
|
||||||
if children.present?
|
if children.present?
|
||||||
output = %{<ul id="#{@options[:id]}-#{page.slug.dasherize}">}
|
output = %{<ul id="#{@options[:id]}-#{page.slug.dasherize}">}
|
||||||
children.each do |c, page|
|
children.each do |c, page|
|
||||||
|
|
|
@ -13,7 +13,8 @@ describe Locomotive::Liquid::Tags::Nav do
|
||||||
|
|
||||||
other_children = [
|
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.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_with_minimal_attributes).returns(other_children)
|
||||||
@home.children.last.stubs(:children).returns(other_children)
|
@home.children.last.stubs(:children).returns(other_children)
|
||||||
|
@ -43,13 +44,21 @@ describe Locomotive::Liquid::Tags::Nav do
|
||||||
|
|
||||||
it 'renders children to depth' do
|
it 'renders children to depth' do
|
||||||
output = render_nav('site', {}, 'depth: 2')
|
output = render_nav('site', {}, 'depth: 2')
|
||||||
|
|
||||||
output.should match /<ul id="nav">/
|
output.should match /<ul id="nav">/
|
||||||
output.should match /<li id="child-1" class="link first">/
|
output.should match /<li id="child-1" class="link first">/
|
||||||
output.should match /<\/a><ul id="nav-child-2">/
|
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-1" class="link first">/
|
||||||
|
output.should match /<li id="sub-child-2" class="link last">/
|
||||||
output.should match /<\/a><\/li><\/ul><\/li><\/ul>/
|
output.should match /<\/a><\/li><\/ul><\/li><\/ul>/
|
||||||
end
|
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
|
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>/
|
render_nav('site', {}, 'icon: true').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/
|
||||||
render_nav('site', {}, 'icon: before').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/
|
render_nav('site', {}, 'icon: before').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/
|
||||||
|
|
Loading…
Reference in New Issue