File tree Expand file tree Collapse file tree 2 files changed +47
-32
lines changed Expand file tree Collapse file tree 2 files changed +47
-32
lines changed Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+ #require File.expand_path('config_shared_examples', File.dirname(__FILE__))
3+
4+ module ActiveAdmin
5+ describe Resource ::Routes do
6+ before { load_defaults! }
7+
8+ let ( :application ) { ActiveAdmin ::Application . new }
9+ let ( :namespace ) { Namespace . new ( application , :admin ) }
10+
11+ def config ( options = { } )
12+ @config ||= Resource . new ( namespace , Category , options )
13+ end
14+
15+ describe "route names" do
16+ it "should return the route prefix" do
17+ config . route_prefix . should == "admin"
18+ end
19+ it "should return the route collection path" do
20+ config . route_collection_path . should == "/admin/categories"
21+ end
22+
23+ context "when in the root namespace" do
24+ let ( :config ) { application . register Category , :namespace => false }
25+ it "should have a nil route_prefix" do
26+ config . route_prefix . should == nil
27+ end
28+
29+ it "should generate a correct route" do
30+ config
31+ reload_routes!
32+ config . route_collection_path . should == "/categories"
33+ end
34+ end
35+
36+ context "when registering a plural resource" do
37+ class ::News ; def self . has_many ( *) ; end end
38+
39+ it "should return the plurali route with _index" do
40+ config = application . register News
41+ reload_routes!
42+ config . route_collection_path . should == "/admin/news"
43+ end
44+ end
45+ end
46+ end
47+ end
Original file line number Diff line number Diff line change @@ -94,38 +94,6 @@ def config(options = {})
9494
9595 end
9696
97- describe "route names" do
98- it "should return the route prefix" do
99- config . route_prefix . should == "admin"
100- end
101- it "should return the route collection path" do
102- config . route_collection_path . should == "/admin/categories"
103- end
104-
105- context "when in the root namespace" do
106- let ( :config ) { application . register Category , :namespace => false }
107- it "should have a nil route_prefix" do
108- config . route_prefix . should == nil
109- end
110-
111- it "should generate a correct route" do
112- config
113- reload_routes!
114- config . route_collection_path . should == "/categories"
115- end
116- end
117-
118- context "when registering a plural resource" do
119- class ::News ; def self . has_many ( *) ; end end
120-
121- it "should return the plurali route with _index" do
122- config = application . register News
123- reload_routes!
124- config . route_collection_path . should == "/admin/news"
125- end
126- end
127- end
128-
12997 describe "scoping" do
13098 context "when using a block" do
13199 before do
You can’t perform that action at this time.
0 commit comments