Add spec for menu_item#destroy

pull/643/head
Till Breuer 11 years ago
parent 92d4c0798f
commit 7770f03d1a
  1. 2
      app/models/menu_item.rb
  2. 10
      spec/models/menu_item_spec.rb

@ -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
end
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
end
end
end

Loading…
Cancel
Save