spec/unit/routing_spec.rb in activeadmin-0.3.4 vs spec/unit/routing_spec.rb in activeadmin-0.4.0

- old
+ new

@@ -1,8 +1,8 @@ require 'spec_helper' -describe ActiveAdmin, "Routing" do +describe ActiveAdmin, "Routing", :type => :routing do before :each do load_defaults! reload_routes! end @@ -81,8 +81,57 @@ end it "should route the nested edit path" do edit_admin_user_post_path(1,2).should == "/admin/users/1/posts/2/edit" end + + context "with collection action" do + before do + load_resources do + ActiveAdmin.register(Post) do + belongs_to :user, :optional => true + end + ActiveAdmin.register(User) do + collection_action "do_something" + end + end + end + + it "should properly route the collection action" do + { :get => "/admin/users/do_something" }. + should route_to({ :controller => 'admin/users',:action => 'do_something'}) + end + end end + describe "page" do + context "when default namespace" do + before(:each) do + load_resources { ActiveAdmin.register_page("Status") } + end + + it "should route to the page under /admin" do + admin_status_path.should == "/admin/status" + end + + context "when in the root namespace" do + before(:each) do + load_resources { ActiveAdmin.register_page("Status", :namespace => false) } + end + + it "should route to page under /" do + status_path.should == "/status" + end + end + + context "when singular page name" do + before(:each) do + load_resources { ActiveAdmin.register_page("Log") } + end + + it "should not inject _index_ into the route name" do + admin_log_path.should == "/admin/log" + end + end + end + end end