@ -32,7 +32,7 @@ class MenuItem < ActiveRecord::Base
serialize :options, Hash
attr_accessible :name, :title, :navigatable_id
attr_accessible :name, :title, :navigatable_id, :parent_id
validates_presence_of :title
validates_format_of :title, :with => /\A[^,\.\/\?\;\|\:]*\z/
@ -31,4 +31,14 @@ describe MenuItem do
end
context 'it should destroy' do
let!(:menu_item) { FactoryGirl.create(:menu_item) }
let!(:child_item) { FactoryGirl.create(:menu_item, parent_id: menu_item.id ) }
example 'all children when deleting the parent' do
menu_item.destroy
MenuItem.exists?(child_item.id).should be_false