dynamic_router 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamic_router/version.rb +1 -1
- data/spec/dynamic_router_spec.rb +6 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6f602701fcab286e0c5e053bcd6a82d54ebaa7e
|
4
|
+
data.tar.gz: 17cd846d4ba3d9e787fd0eb8d7f996e8726811d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78fb249b744d7ba4abccf31f209a99fecdcd38f5f38fa29504fe44d71659a29e9cd483df4306d5c7f74f8ad039f151e06ad33562d5210aedfa71d7d95c687507
|
7
|
+
data.tar.gz: 273e48fca1662ea204383cfc3036fdeefabe653ab6f1665f326a0a5fe3e2a45bfc6d7e982e0c57d09535cf689bfe82a87b431bc3ee47dbf2db4e44edcda66ebc
|
data/spec/dynamic_router_spec.rb
CHANGED
@@ -2,6 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe DynamicRouter do
|
4
4
|
before(:each) do
|
5
|
+
class Example < ActiveRecord::Base
|
6
|
+
end
|
7
|
+
|
5
8
|
Example.destroy_all
|
6
9
|
|
7
10
|
Example.create!(:first_path => "path_a", :second_path => "path_a_a", :default_field => "default_value")
|
@@ -44,14 +47,10 @@ RSpec.describe DynamicRouter do
|
|
44
47
|
expect(Rails.application.routes.routes.named_routes["path_a_path_a_a"].defaults).to match a_hash_including(:default_value => "default_value")
|
45
48
|
end
|
46
49
|
|
47
|
-
it "should
|
48
|
-
Rails.application.
|
49
|
-
DynamicRouter.has_dynamic_route_for(Example, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method", :defaults => {:default_value => Proc.new {|example| example.default_field}})
|
50
|
-
end
|
50
|
+
it "should reload the routes after save the model" do
|
51
|
+
expect(Rails.application.routes_reloader).to receive(:reload!)
|
51
52
|
|
52
53
|
Example.create!(:first_path => "path_a", :second_path => "path_a_b")
|
53
|
-
|
54
|
-
expect(Rails.application.routes.recognize_path('/path_a/path_a_b', :method => :get))
|
55
54
|
end
|
56
55
|
|
57
56
|
it "should not create the route if the url is blank" do
|
@@ -63,12 +62,8 @@ RSpec.describe DynamicRouter do
|
|
63
62
|
end
|
64
63
|
|
65
64
|
it "should not create the route if the url eval to blank" do
|
66
|
-
Rails.application.routes.draw do
|
67
|
-
DynamicRouter.has_dynamic_route_for(Example, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method")
|
68
|
-
end
|
69
|
-
|
70
65
|
Example.create!(:first_path => "")
|
71
66
|
|
72
|
-
expect(Rails.application.routes.routes.named_routes.size).to eq(
|
67
|
+
expect(Rails.application.routes.routes.named_routes.size).to eq(0)
|
73
68
|
end
|
74
69
|
end
|