strong_routes 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71eb6db636e7c67d3e3ca4df52256cd0ec42146d
|
4
|
+
data.tar.gz: fec00ffa91534d046242fa1be5560c91812c6744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 878b70625b77b8c3722279681c2d7eb3cd51b367a06a29de18d278e067405a968af9ba91244f5140be6e71180e73cd29aa19f4a2edb2115acc713b398fe5e78d
|
7
|
+
data.tar.gz: aa4523e8ec53db12771933cd7bb2e83542c52cfa91bda5bea3ef61438ab343d0eb0a99d43b338f75269c67e022d2f9b46ac7ec24024a5cd5e467e3b0c1286c91
|
@@ -6,13 +6,6 @@ module StrongRoutes
|
|
6
6
|
config.strong_routes = StrongRoutes.config
|
7
7
|
|
8
8
|
initializer 'strong_routes.initialize' do |app|
|
9
|
-
# Need to force Rails to load the routes since there's no way to hook
|
10
|
-
# in after routes are loaded
|
11
|
-
app.reload_routes!
|
12
|
-
|
13
|
-
config.strong_routes.allowed_routes ||= []
|
14
|
-
config.strong_routes.allowed_routes += RouteMapper.map(app.routes)
|
15
|
-
|
16
9
|
case
|
17
10
|
when config.strong_routes.insert_before? then
|
18
11
|
app.config.middleware.insert_before(config.strong_routes.insert_before, Allow)
|
@@ -22,6 +15,17 @@ module StrongRoutes
|
|
22
15
|
app.config.middleware.insert_before(::Rails::Rack::Logger, Allow)
|
23
16
|
end
|
24
17
|
end
|
18
|
+
|
19
|
+
# Load this late so initializers that depend on routes have a chance to
|
20
|
+
# initialize (i.e. Devise)
|
21
|
+
config.after_initialize do |app|
|
22
|
+
# Need to force Rails to load the routes since there's no way to hook
|
23
|
+
# in after routes are loaded
|
24
|
+
app.reload_routes!
|
25
|
+
|
26
|
+
config.strong_routes.allowed_routes ||= []
|
27
|
+
config.strong_routes.allowed_routes += RouteMapper.map(app.routes)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -4,15 +4,16 @@ require 'action_dispatch'
|
|
4
4
|
require 'strong_routes/rails/route_mapper'
|
5
5
|
|
6
6
|
describe ::StrongRoutes::Rails::RouteMapper do
|
7
|
-
let(:paths) { [ 'users', 'posts', 'user_posts', 'bar', 'trading-post' ] }
|
7
|
+
let(:paths) { [ 'users', 'posts', 'comments', 'user_posts', 'bar', 'trading-post' ] }
|
8
8
|
let(:route_set) {
|
9
9
|
route_set = ActionDispatch::Routing::RouteSet.new
|
10
10
|
route_set.draw do
|
11
11
|
resources :users, :only => :index do
|
12
|
-
resources :posts
|
12
|
+
resources :posts, :shallow => true do
|
13
|
+
resources :comments, :shallow => true
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
|
-
resources :posts, :only => :show
|
16
17
|
resources :user_posts, :only => :show
|
17
18
|
|
18
19
|
get 'bar/sandwich', :to => 'users#index'
|
@@ -23,7 +24,7 @@ describe ::StrongRoutes::Rails::RouteMapper do
|
|
23
24
|
|
24
25
|
describe ".map" do
|
25
26
|
it "maps routes to path strings" do
|
26
|
-
::StrongRoutes::Rails::RouteMapper.map(route_set).must_equal paths
|
27
|
+
::StrongRoutes::Rails::RouteMapper.map(route_set).sort.must_equal paths.sort
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
@@ -31,7 +32,7 @@ describe ::StrongRoutes::Rails::RouteMapper do
|
|
31
32
|
subject { ::StrongRoutes::Rails::RouteMapper.new(route_set) }
|
32
33
|
|
33
34
|
it "maps routes to path strings" do
|
34
|
-
subject.map.must_equal paths
|
35
|
+
subject.map.sort.must_equal paths.sort
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|