Permalink
Browse files

Fixes being able to delete navigable items

  • Loading branch information...
1 parent dcad073 commit d5c7670376876b91c3d6fc73553a7594ddb4df2b @ramontayag committed Feb 19, 2012
Showing with 30 additions and 16 deletions.
  1. +5 −3 lib/navi/navigable/instance_methods.rb
  2. +25 −13 spec/navi/navigable_spec.rb
@@ -26,9 +26,11 @@ def navigator_instance
end
def prepare_standalone_navigator!
- set_navigator_label_to_self!
- set_navigator_url_to_hash!
- nullify_navigator_pointer_to_self!
+ if navigator_instance
+ set_navigator_label_to_self!
+ set_navigator_url_to_hash!
+ nullify_navigator_pointer_to_self!
+ end
end
def set_navigator_label_to_self!
@@ -2,22 +2,34 @@
describe "Navigable" do
context "when deleted" do
- before do
- page = Factory :page, :name => "Page name"
- @menu_item = page.to_navigator!
- page.destroy
- @menu_item.reload
- end
+ context "and the navigator has a navigable item" do
+ before do
+ page = Factory :page, :name => "Page name"
+ @menu_item = page.to_navigator!
+ page.destroy
+ @menu_item.reload
+ end
+
+ it "should nullify the navigator's (menu item) pointer to itself" do
+ @menu_item.navigable.should be_nil
+ @menu_item.navigable_id.should be_nil
+ @menu_item.navigable_type.should be_nil
+ end
- it "should nullify the navigator's (menu item) pointer to itself" do
- @menu_item.navigable.should be_nil
- @menu_item.navigable_id.should be_nil
- @menu_item.navigable_type.should be_nil
+ it "should set the label and url" do
+ @menu_item.label.should == "Page name"
+ @menu_item.url.should == "#"
+ end
end
- it "should set the label and url" do
- @menu_item.label.should == "Page name"
- @menu_item.url.should == "#"
+ context "and the navigable has no navigator item" do
+ before do
+ @page = Factory :page, :name => "Page name"
+ end
+
+ it "should not blow up" do
+ expect {@page.destroy}.to_not raise_error
+ end
end
end
end

0 comments on commit d5c7670

Please sign in to comment.