Permalink
Browse files

setup menu renderer modules for archive types and limit menus

  • Loading branch information...
1 parent 36a7f87 commit 86d8d0f459f66936038597da2fe3dd3ca1a43cb7 @saturnflyer saturnflyer committed Nov 5, 2011
Showing with 62 additions and 0 deletions.
  1. +23 −0 app/models/archive_menu_renderer.rb
  2. +39 −0 spec/models/archive_menu_renderer_spec.rb
@@ -0,0 +1,23 @@
+module ArchiveMenuRenderer
+ def excluded_class_names
+ Array(ArchiveMenuRenderer.instance_variable_get(:@excluded_class_names))
+ end
+end
+
+module ArchiveDayIndexMenuRenderer
+ def add_child_disabled?
+ true
+ end
+end
+
+module ArchiveMonthIndexMenuRenderer
+ def add_child_disabled?
+ true
+ end
+end
+
+module ArchiveYearIndexMenuRenderer
+ def add_child_disabled?
+ true
+ end
+end
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+describe ArchiveMenuRenderer do
+ context 'excluding classes from child list' do
+ it 'should be retrievable by the extended object' do
+ ArchiveMenuRenderer.instance_variable_set(:@excluded_class_names, ['SkippedPage'])
+ page = Object.new
+ page.extend ArchiveMenuRenderer
+ page.excluded_class_names.should include('SkippedPage')
+ end
+ end
+end
+
+describe ArchiveDayIndexMenuRenderer do
+ subject{
+ page = Object.new
+ page.extend ArchiveDayIndexMenuRenderer
+ page
+ }
+ its(:add_child_disabled?){ should be_true }
+end
+
+describe ArchiveMonthIndexMenuRenderer do
+ subject{
+ page = Object.new
+ page.extend ArchiveMonthIndexMenuRenderer
+ page
+ }
+ its(:add_child_disabled?){ should be_true }
+end
+
+describe ArchiveYearIndexMenuRenderer do
+ subject{
+ page = Object.new
+ page.extend ArchiveYearIndexMenuRenderer
+ page
+ }
+ its(:add_child_disabled?){ should be_true }
+end

0 comments on commit 86d8d0f

Please sign in to comment.