Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Apr 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions core/lib/refinery/menu.rb
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions 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