From 2d3c0e974f11bf2e96a501d7668941c66a24491a Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 1 Feb 2011 14:43:07 +0800 Subject: [PATCH] not showing unlisted pages in the nav --- lib/locomotive/liquid/tags/nav.rb | 2 +- spec/lib/locomotive/liquid/tags/nav_spec.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/locomotive/liquid/tags/nav.rb b/lib/locomotive/liquid/tags/nav.rb index 7c653af5..711f85b4 100644 --- a/lib/locomotive/liquid/tags/nav.rb +++ b/lib/locomotive/liquid/tags/nav.rb @@ -106,7 +106,7 @@ module Locomotive # Determines whether or not a page should be a part of the menu def include_page?(page) - if page.templatized? || !page.published? + if page.unlisted? || page.templatized? || !page.published? false elsif @options[:exclude] (page.fullpath =~ @options[:exclude]).nil? diff --git a/spec/lib/locomotive/liquid/tags/nav_spec.rb b/spec/lib/locomotive/liquid/tags/nav_spec.rb index 15072109..8a4e296a 100644 --- a/spec/lib/locomotive/liquid/tags/nav_spec.rb +++ b/spec/lib/locomotive/liquid/tags/nav_spec.rb @@ -15,8 +15,9 @@ describe Locomotive::Liquid::Tags::Nav do 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 => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false), - Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true) - ] + Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true), + Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :unlisted => true) + ] @home.children.last.stubs(:children_with_minimal_attributes).returns(other_children) @home.children.last.stubs(:children).returns(other_children) @@ -66,6 +67,12 @@ describe Locomotive::Liquid::Tags::Nav do output.should_not match /sub-child-unpublished-3/ end + it 'does not render unlisted pages' do + output = render_nav('site', {}, 'depth: 2') + + output.should_not match /sub-child-unlisted-3/ + end + it 'does not render nested excluded pages' do output = render_nav('site', {}, 'depth: 2, exclude: "child_2/sub_child_2"')