spec/unit/routing_spec.rb in activeadmin-0.5.1 vs spec/unit/routing_spec.rb in activeadmin-0.6.0

- old
+ new

@@ -109,9 +109,52 @@ it "should route the edit path" do edit_post_path(1).should == "/posts/1/edit" end end + + context "with member action" do + context "without an http verb" do + before do + load_resources do + ActiveAdmin.register(Post){ member_action "do_something" } + end + end + + it "should default to GET" do + {:get => "/admin/posts/1/do_something"}.should be_routable + {:post => "/admin/posts/1/do_something"}.should_not be_routable + end + end + + context "with one http verb" do + before do + load_resources do + ActiveAdmin.register(Post){ member_action "do_something", :method => :post } + end + end + + it "should properly route" do + {:post => "/admin/posts/1/do_something"}.should be_routable + end + end + + context "with two http verbs" do + before do + load_resources do + ActiveAdmin.register(Post){ member_action "do_something", :method => [:put, :delete] } + end + end + + it "should properly route the first verb" do + {:put => "/admin/posts/1/do_something"}.should be_routable + end + + it "should properly route the second verb" do + {:delete => "/admin/posts/1/do_something"}.should be_routable + end + end + end end describe "belongs to resource" do it "should route the nested index path" do admin_user_posts_path(1).should == "/admin/users/1/posts"