diff --git a/changelog.md b/changelog.md index 904913182d..bdb30a4104 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ * [See full list](https://github.com/resolve/refinerycms/compare/2-0-stable...master) +## 2.0.4 [unreleased] +* Fixed stack level too deep error in Refinery::Menu#inspect. [Uģis Ozols](https://github.com/ugisozols) + ## 2.0.3 [2 April 2012] * Fixed missing authentication initializer. [Uģis Ozols](https://github.com/ugisozols) * Fixed Heroku and sqlite3 related errors. [Philip Arndt](https://github.com/parndt) diff --git a/core/lib/refinery/menu.rb b/core/lib/refinery/menu.rb index 13137d699d..932e6d8d95 100644 --- a/core/lib/refinery/menu.rb +++ b/core/lib/refinery/menu.rb @@ -22,10 +22,6 @@ def to_s items.map(&:title).join(' ') end - def inspect - items.map(&:inspect) - end - # The delegation is specified so crazily so that it works on 1.8.x and 1.9.x delegate *((Array.instance_methods - Object.instance_methods) << {:to => :items}) end diff --git a/core/spec/lib/refinery/menu_spec.rb b/core/spec/lib/refinery/menu_spec.rb new file mode 100644 index 0000000000..30b1131bed --- /dev/null +++ b/core/spec/lib/refinery/menu_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +module Refinery + describe Menu do + + let(:menu) do + page1 = FactoryGirl.create(:page, :title => 'test1') + page2 = FactoryGirl.create(:page, :title => 'test2', :parent_id => page1.id) + Refinery::Menu.new([page1, page2]) + end + + describe '.initialize' do + it "returns a collection of menu item objects" do + menu.each { |item| item.should be_an_instance_of(MenuItem) } + end + end + + describe '#items' do + it 'returns a collection' do + menu.items.count.should eq(2) + end + end + + describe '#roots' do + it 'returns a collection of items with parent_id == nil' do + menu.roots.collect(&:parent_id).should eq([nil]) + end + end + + describe '#to_s' do + it 'returns string of joined page titles' do + menu.to_s.should eq('test1 test2') + end + end + + end +end