Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add specs for Refinery::Menu and fix stack level too deep error coming from #inspect #1551

Merged
merged 3 commits into from

2 participants

@ugisozols
Owner

No description provided.

@parndt

Does this actually give you full object inspection?

Owner

No. inspect output differs in 1.8.7 and 1.9.3 so I choose to stick to what's 1.9.3 is returning. Probably not the best decision so I'm open to suggestions.

@parndt
Owner

Maybe we shouldn't override inspect at all?

@parndt parndt merged commit 03defeb into 2-0-stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  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)
View
4 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
View
37 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
Something went wrong with that request. Please try again.