spec/unit/routing_spec.rb in activeadmin-1.0.0.pre4 vs spec/unit/routing_spec.rb in activeadmin-1.0.0.pre5
- old
+ new
@@ -1,10 +1,10 @@
# encoding: utf-8
require 'rails_helper'
-describe ActiveAdmin, "Routing", type: :routing do
+RSpec.describe ActiveAdmin, "Routing", type: :routing do
before do
load_defaults!
reload_routes!
end
@@ -12,12 +12,14 @@
after :all do
load_defaults!
reload_routes!
end
+ let(:namespaces) { ActiveAdmin.application.namespaces }
+
it "should only have the namespaces necessary for route testing" do
- expect(ActiveAdmin.application.namespaces.names).to eq [:admin, :root]
+ expect(namespaces.names).to eq [:admin]
end
it "should route to the admin dashboard" do
expect(get('/admin')).to route_to 'admin/dashboard#index'
end
@@ -28,10 +30,28 @@
expect(admin_root_path).to eq "/admin"
end
end
end
+ describe "route_options" do
+ context "with a custom path set in route_options" do
+ before do
+ namespaces[:admin].route_options = { path: '/custom-path' }
+ reload_routes!
+ end
+
+ after do
+ namespaces[:admin].route_options = {}
+ reload_routes!
+ end
+
+ it "should route using the custom path" do
+ expect(admin_posts_path).to eq "/custom-path/posts"
+ end
+ end
+ end
+
describe "standard resources" do
context "when in admin namespace" do
it "should route the index path" do
expect(admin_posts_path).to eq "/admin/posts"
end
@@ -52,10 +72,14 @@
context "when in root namespace" do
before(:each) do
load_resources { ActiveAdmin.register(Post, namespace: false) }
end
+ after(:each) do
+ namespaces.instance_variable_get(:@namespaces).delete(:root)
+ end
+
it "should route the index path" do
expect(posts_path).to eq "/posts"
end
it "should route the show path" do
@@ -163,9 +187,13 @@
end
context "when in the root namespace" do
before(:each) do
load_resources { ActiveAdmin.register_page("Chocolate I lØve You!", namespace: false) }
+ end
+
+ after(:each) do
+ namespaces.instance_variable_get(:@namespaces).delete(:root)
end
it "should route to page under /" do
expect(chocolate_i_love_you_path).to eq "/chocolate_i_love_you"
end