js-routes 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/rails42.gemfile +1 -0
- data/gemfiles/rails42_sprockets3.gemfile +1 -0
- data/js-routes.gemspec +1 -0
- data/lib/js_routes.rb +14 -7
- data/lib/js_routes/version.rb +1 -1
- data/lib/routes.js +39 -14
- data/lib/routes.js.coffee +32 -10
- data/spec/js_routes/generated_javascript_spec.rb +4 -4
- data/spec/js_routes/rails_routes_compatibility_spec.rb +63 -6
- data/spec/spec_helper.rb +0 -1
- data/spec/support/routes.rb +3 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b720670fa76910ce7f6648985f595280bb07c16
|
4
|
+
data.tar.gz: 6ea110ece8ff7cf6e5fc1fe6635819f62c15464e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37d1e5fa18e348092b4f56525eb6c61626b8b4820e46bffc2b16f28466a181f3a233499c8cc9004db4dc5dee551c3dd1998efc8ed3515b43a9ee1e551e477c0b
|
7
|
+
data.tar.gz: fce1d09de9f6b5772a9b9b0a6f2a4759722f72f7a45e7032a9bcb7341f7987807624bff591d5115edfebcd1b04403aac258f4a46daa6f496f49f34dbddd94341
|
data/gemfiles/rails42.gemfile
CHANGED
data/js-routes.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_development_dependency(%q<therubyrhino>, [">= 2.0.4"])
|
31
31
|
else
|
32
32
|
s.add_development_dependency(%q<byebug>)
|
33
|
+
s.add_development_dependency(%q<pry-byebug>)
|
33
34
|
s.add_development_dependency(%q<therubyracer>, [">= 0.12.1"])
|
34
35
|
end
|
35
36
|
end
|
data/lib/js_routes.rb
CHANGED
@@ -110,9 +110,10 @@ class JsRoutes
|
|
110
110
|
"NODE_TYPES" => json(NODE_TYPES),
|
111
111
|
"SERIALIZER" => @options[:serializer] || json(nil),
|
112
112
|
"ROUTES" => js_routes,
|
113
|
-
"SPECIAL_OPTIONS_KEY" => @options[:special_options_key].to_s
|
113
|
+
"SPECIAL_OPTIONS_KEY" => @options[:special_options_key].to_s,
|
114
|
+
"DEPRECATED_BEHAVIOR" => Rails.version < "4",
|
114
115
|
}.inject(File.read(File.dirname(__FILE__) + "/routes.js")) do |js, (key, value)|
|
115
|
-
js.gsub!(key, value)
|
116
|
+
js.gsub!(key, value.to_s)
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
@@ -216,13 +217,19 @@ class JsRoutes
|
|
216
217
|
end
|
217
218
|
|
218
219
|
def route_js_arguments(route, parent_spec)
|
219
|
-
required_parts = route.required_parts
|
220
|
-
|
221
|
-
|
222
|
-
|
220
|
+
required_parts = route.required_parts
|
221
|
+
parts_table = route.parts.each_with_object({}) do |part, hash|
|
222
|
+
hash[part] = required_parts.include?(part)
|
223
|
+
end
|
224
|
+
default_options = route.defaults.select do |part, _|
|
225
|
+
FILTERED_DEFAULT_PARTS.exclude?(part) && URL_OPTIONS.include?(part) || parts_table[part]
|
223
226
|
end
|
224
227
|
[
|
225
|
-
|
228
|
+
# JS objects don't preserve the order of properties which is crucial,
|
229
|
+
# so array is a better choice.
|
230
|
+
parts_table.to_a,
|
231
|
+
default_options,
|
232
|
+
serialize(route.path.spec, parent_spec)
|
226
233
|
].map do |argument|
|
227
234
|
json(argument)
|
228
235
|
end.join(", ")
|
data/lib/js_routes/version.rb
CHANGED
data/lib/routes.js
CHANGED
@@ -4,7 +4,7 @@ Based on Rails routes of APP_CLASS
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
(function() {
|
7
|
-
var NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, Utils, createGlobalJsRoutesObject, defaults, root,
|
7
|
+
var DeprecatedBehavior, NodeTypes, ParameterMissing, ReservedOptions, SpecialOptionsKey, Utils, createGlobalJsRoutesObject, defaults, root,
|
8
8
|
hasProp = {}.hasOwnProperty,
|
9
9
|
slice = [].slice;
|
10
10
|
|
@@ -25,6 +25,8 @@ Based on Rails routes of APP_CLASS
|
|
25
25
|
|
26
26
|
SpecialOptionsKey = "SPECIAL_OPTIONS_KEY";
|
27
27
|
|
28
|
+
DeprecatedBehavior = DEPRECATED_BEHAVIOR;
|
29
|
+
|
28
30
|
ReservedOptions = ['anchor', 'trailing_slash', 'host', 'port', 'protocol'];
|
29
31
|
|
30
32
|
Utils = {
|
@@ -170,13 +172,22 @@ Based on Rails routes of APP_CLASS
|
|
170
172
|
});
|
171
173
|
}
|
172
174
|
},
|
173
|
-
normalize_options: function(
|
174
|
-
var i, j, key, len, options, result, url_parameters, value;
|
175
|
-
options = this.extract_options(
|
176
|
-
if (actual_parameters.length >
|
175
|
+
normalize_options: function(parts, required_parts, default_options, actual_parameters) {
|
176
|
+
var i, j, key, len, options, part, parts_options, result, route_parts, url_parameters, use_all_parts, value;
|
177
|
+
options = this.extract_options(parts.length, actual_parameters);
|
178
|
+
if (actual_parameters.length > parts.length) {
|
177
179
|
throw new Error("Too many parameters provided for path");
|
178
180
|
}
|
179
|
-
|
181
|
+
use_all_parts = DeprecatedBehavior || actual_parameters.length > required_parts.length;
|
182
|
+
parts_options = {};
|
183
|
+
for (key in options) {
|
184
|
+
if (!hasProp.call(options, key)) continue;
|
185
|
+
use_all_parts = true;
|
186
|
+
if (this.indexOf(parts, key) >= 0) {
|
187
|
+
parts_options[key] = value;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
options = this.merge(defaults.default_url_options, default_options, options);
|
180
191
|
result = {};
|
181
192
|
url_parameters = {};
|
182
193
|
result['url_parameters'] = url_parameters;
|
@@ -189,18 +200,23 @@ Based on Rails routes of APP_CLASS
|
|
189
200
|
url_parameters[key] = value;
|
190
201
|
}
|
191
202
|
}
|
192
|
-
|
193
|
-
|
203
|
+
route_parts = use_all_parts ? parts : required_parts;
|
204
|
+
i = 0;
|
205
|
+
for (j = 0, len = route_parts.length; j < len; j++) {
|
206
|
+
part = route_parts[j];
|
194
207
|
if (i < actual_parameters.length) {
|
195
|
-
|
208
|
+
if (!parts_options.hasOwnProperty(part)) {
|
209
|
+
url_parameters[part] = actual_parameters[i];
|
210
|
+
++i;
|
211
|
+
}
|
196
212
|
}
|
197
213
|
}
|
198
214
|
return result;
|
199
215
|
},
|
200
|
-
build_route: function(
|
216
|
+
build_route: function(parts, required_parts, default_options, route, full_url, args) {
|
201
217
|
var options, parameters, result, url, url_params;
|
202
218
|
args = Array.prototype.slice.call(args);
|
203
|
-
options = this.normalize_options(
|
219
|
+
options = this.normalize_options(parts, required_parts, default_options, args);
|
204
220
|
parameters = options['url_parameters'];
|
205
221
|
result = "" + (this.get_prefix()) + (this.visit(route, parameters));
|
206
222
|
url = Utils.clean_path(result);
|
@@ -313,10 +329,19 @@ Based on Rails routes of APP_CLASS
|
|
313
329
|
}
|
314
330
|
return prefix;
|
315
331
|
},
|
316
|
-
route: function(
|
317
|
-
var path_fn;
|
332
|
+
route: function(parts_table, default_options, route_spec, full_url) {
|
333
|
+
var j, len, part, parts, path_fn, ref, required, required_parts;
|
334
|
+
required_parts = [];
|
335
|
+
parts = [];
|
336
|
+
for (j = 0, len = parts_table.length; j < len; j++) {
|
337
|
+
ref = parts_table[j], part = ref[0], required = ref[1];
|
338
|
+
parts.push(part);
|
339
|
+
if (required) {
|
340
|
+
required_parts.push(part);
|
341
|
+
}
|
342
|
+
}
|
318
343
|
path_fn = function() {
|
319
|
-
return Utils.build_route(required_parts,
|
344
|
+
return Utils.build_route(parts, required_parts, default_options, route_spec, full_url, arguments);
|
320
345
|
};
|
321
346
|
path_fn.required_params = required_parts;
|
322
347
|
path_fn.toString = function() {
|
data/lib/routes.js.coffee
CHANGED
@@ -13,6 +13,7 @@ defaults =
|
|
13
13
|
|
14
14
|
NodeTypes = NODE_TYPES
|
15
15
|
SpecialOptionsKey = "SPECIAL_OPTIONS_KEY"
|
16
|
+
DeprecatedBehavior = DEPRECATED_BEHAVIOR
|
16
17
|
|
17
18
|
ReservedOptions = [
|
18
19
|
'anchor'
|
@@ -104,11 +105,21 @@ Utils =
|
|
104
105
|
if xs?.length > 0
|
105
106
|
tap {}, (m) -> m[k] = v for k, v of x for x in xs
|
106
107
|
|
107
|
-
normalize_options: (
|
108
|
-
options = @extract_options(
|
109
|
-
|
108
|
+
normalize_options: (parts, required_parts, default_options, actual_parameters) ->
|
109
|
+
options = @extract_options(parts.length, actual_parameters)
|
110
|
+
|
111
|
+
if actual_parameters.length > parts.length
|
110
112
|
throw new Error("Too many parameters provided for path")
|
111
|
-
|
113
|
+
|
114
|
+
use_all_parts = DeprecatedBehavior or actual_parameters.length > required_parts.length
|
115
|
+
parts_options = {}
|
116
|
+
|
117
|
+
for own key of options
|
118
|
+
use_all_parts = true
|
119
|
+
if @indexOf(parts, key) >= 0
|
120
|
+
parts_options[key] = value
|
121
|
+
|
122
|
+
options = @merge(defaults.default_url_options, default_options, options)
|
112
123
|
result = {}
|
113
124
|
url_parameters = {}
|
114
125
|
result['url_parameters'] = url_parameters
|
@@ -118,14 +129,19 @@ Utils =
|
|
118
129
|
else
|
119
130
|
url_parameters[key] = value
|
120
131
|
|
121
|
-
|
122
|
-
|
132
|
+
route_parts = if use_all_parts then parts else required_parts
|
133
|
+
i = 0
|
134
|
+
for part in route_parts when i < actual_parameters.length
|
135
|
+
unless parts_options.hasOwnProperty(part)
|
136
|
+
url_parameters[part] = actual_parameters[i]
|
137
|
+
++i
|
138
|
+
|
123
139
|
result
|
124
140
|
|
125
|
-
build_route: (
|
141
|
+
build_route: (parts, required_parts, default_options, route, full_url, args) ->
|
126
142
|
args = Array::slice.call(args)
|
127
143
|
|
128
|
-
options = @normalize_options(
|
144
|
+
options = @normalize_options(parts, required_parts, default_options, args)
|
129
145
|
parameters = options['url_parameters']
|
130
146
|
|
131
147
|
# path
|
@@ -239,9 +255,15 @@ Utils =
|
|
239
255
|
#
|
240
256
|
# route function: create route path function and add spec to it
|
241
257
|
#
|
242
|
-
route: (
|
258
|
+
route: (parts_table, default_options, route_spec, full_url) ->
|
259
|
+
required_parts = []
|
260
|
+
parts = []
|
261
|
+
for [part, required] in parts_table
|
262
|
+
parts.push(part)
|
263
|
+
required_parts.push(part) if required
|
264
|
+
|
243
265
|
path_fn = -> Utils.build_route(
|
244
|
-
required_parts,
|
266
|
+
parts, required_parts, default_options, route_spec, full_url, arguments
|
245
267
|
)
|
246
268
|
path_fn.required_params = required_parts
|
247
269
|
path_fn.toString = -> Utils.build_path_spec(route_spec)
|
@@ -25,13 +25,13 @@ describe JsRoutes do
|
|
25
25
|
is_expected.to include("inboxes_path: Utils.route(")
|
26
26
|
end
|
27
27
|
it "should have correct function without arguments signature" do
|
28
|
-
is_expected.to include("inboxes_path: Utils.route([]")
|
28
|
+
is_expected.to include("inboxes_path: Utils.route([[\"format\",false]]")
|
29
29
|
end
|
30
30
|
it "should have correct function with arguments signature" do
|
31
|
-
is_expected.to include("inbox_message_path: Utils.route([\"inbox_id\"
|
31
|
+
is_expected.to include("inbox_message_path: Utils.route([[\"inbox_id\",true],[\"id\",true],[\"format\",false]]")
|
32
32
|
end
|
33
33
|
it "should have correct function signature with unordered hash" do
|
34
|
-
is_expected.to include("inbox_message_attachment_path: Utils.route([\"inbox_id\"
|
34
|
+
is_expected.to include("inbox_message_attachment_path: Utils.route([[\"inbox_id\",true],[\"message_id\",true],[\"id\",true],[\"format\",false]]")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should have correct function comment with options argument" do
|
@@ -77,7 +77,7 @@ describe JsRoutes do
|
|
77
77
|
describe "compiled javascript asset" do
|
78
78
|
subject { ERB.new(File.read("app/assets/javascripts/js-routes.js.erb")).result(binding) }
|
79
79
|
it "should have js routes code" do
|
80
|
-
is_expected.to include("inbox_message_path: Utils.route([\"inbox_id\"
|
80
|
+
is_expected.to include("inbox_message_path: Utils.route([[\"inbox_id\",true],[\"id\",true],[\"format\",false]]")
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -14,6 +14,17 @@ describe JsRoutes, "compatibility with Rails" do
|
|
14
14
|
expect(evaljs("Routes.inbox_path(1)")).to eq(routes.inbox_path(1))
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should raise error if required argument is not passed" do
|
18
|
+
expect { evaljs("Routes.thing_path()") }
|
19
|
+
.to raise_error('Route parameter missing: id')
|
20
|
+
expect { evaljs("Routes.search_path()") }
|
21
|
+
.to raise_error('Route parameter missing: q')
|
22
|
+
expect { evaljs("Routes.book_path()") }
|
23
|
+
.to raise_error('Route parameter missing: title')
|
24
|
+
expect { evaljs("Routes.book_title_path()") }
|
25
|
+
.to raise_error('Route parameter missing: title')
|
26
|
+
end
|
27
|
+
|
17
28
|
it "should support 0 as a member parameter" do
|
18
29
|
expect(evaljs("Routes.inbox_path(0)")).to eq(routes.inbox_path(0))
|
19
30
|
end
|
@@ -59,9 +70,6 @@ describe JsRoutes, "compatibility with Rails" do
|
|
59
70
|
end
|
60
71
|
|
61
72
|
it 'should support route default subdomain' do
|
62
|
-
# root inside namespace is broken
|
63
|
-
# https://github.com/rails/rails/pull/23235
|
64
|
-
pending if Rails.version >= '5.0.0' && Rails.version <= "5.0.1"
|
65
73
|
expect(evaljs("Routes.backend_root_path()")).to eq(routes.backend_root_path)
|
66
74
|
end
|
67
75
|
|
@@ -69,6 +77,10 @@ describe JsRoutes, "compatibility with Rails" do
|
|
69
77
|
expect(evaljs("Routes.api_purchases_path({format: 'xml'})")).to eq(routes.api_purchases_path(format: 'xml'))
|
70
78
|
end
|
71
79
|
|
80
|
+
it "should support default format override by passing it in args" do
|
81
|
+
expect(evaljs("Routes.api_purchases_path('xml')")).to eq(routes.api_purchases_path('xml'))
|
82
|
+
end
|
83
|
+
|
72
84
|
it "doesn't apply defaults to path" do
|
73
85
|
expect(evaljs("Routes.with_defaults_path()")).to eq(routes.with_defaults_path)
|
74
86
|
end
|
@@ -184,11 +196,10 @@ describe JsRoutes, "compatibility with Rails" do
|
|
184
196
|
context "but not including them" do
|
185
197
|
it "should not include the optional parts" do
|
186
198
|
expect(evaljs("Routes.things_path()")).to eq(routes.things_path)
|
199
|
+
expect(evaljs("Routes.things_path({ q: 'hello' })")).to eq(routes.things_path(q: 'hello'))
|
187
200
|
end
|
188
201
|
|
189
202
|
it "should not require the optional parts as arguments" do
|
190
|
-
#TODO: fix this inconsistence
|
191
|
-
pending
|
192
203
|
expect(evaljs("Routes.thing_path(null, 5)")).to eq(routes.thing_path(nil, 5))
|
193
204
|
end
|
194
205
|
|
@@ -196,14 +207,60 @@ describe JsRoutes, "compatibility with Rails" do
|
|
196
207
|
expect(evaljs("Routes.thing_path(5, {optional_id: undefined})")).to eq(routes.thing_path(5, :optional_id => nil))
|
197
208
|
end
|
198
209
|
|
210
|
+
it "should raise error when passing non-full list of arguments and some query params" do
|
211
|
+
expect { evaljs("Routes.thing_path(5, {q: 'hello'})") }
|
212
|
+
.to raise_error('Route parameter missing: id')
|
213
|
+
end
|
214
|
+
|
199
215
|
it "should treat null as non-given optional part" do
|
200
216
|
expect(evaljs("Routes.thing_path(5, {optional_id: null})")).to eq(routes.thing_path(5, :optional_id => nil))
|
201
217
|
end
|
218
|
+
|
219
|
+
it "should work when passing required params in options" do
|
220
|
+
expect(evaljs("Routes.thing_deep_path({second_required: 1, third_required: 2})")).to eq(routes.thing_deep_path(second_required: 1, third_required: 2))
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should skip leading and trailing optional parts" do
|
224
|
+
skip if Rails.version < '4'
|
225
|
+
expect(evaljs("Routes.thing_deep_path(1, 2)")).to eq(routes.thing_deep_path(1, 2))
|
226
|
+
end
|
202
227
|
end
|
203
228
|
|
204
229
|
context "and including them" do
|
230
|
+
if Rails.version < '4'
|
231
|
+
it "should fail when insufficient arguments are given" do
|
232
|
+
expect { evaljs("Routes.thing_deep_path(1)")}
|
233
|
+
.to raise_error('Route parameter missing: second_required')
|
234
|
+
expect { evaljs("Routes.thing_deep_path(1,2)")}
|
235
|
+
.to raise_error('Route parameter missing: third_required')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
205
239
|
it "should include the optional parts" do
|
206
240
|
expect(evaljs("Routes.things_path({optional_id: 5})")).to eq(routes.things_path(:optional_id => 5))
|
241
|
+
expect(evaljs("Routes.things_path(5)")).to eq(routes.things_path(5))
|
242
|
+
expect(evaljs("Routes.thing_deep_path(1, { third_required: 3, second_required: 2 })")).to eq(routes.thing_deep_path(1, third_required: 3, second_required: 2))
|
243
|
+
expect(evaljs("Routes.thing_deep_path(1, { third_required: 3, second_required: 2, forth_optional: 4 })")).to eq(routes.thing_deep_path(1, third_required: 3, second_required: 2, forth_optional: 4))
|
244
|
+
expect(evaljs("Routes.thing_deep_path(2, { third_required: 3, first_optional: 1 })")).to eq(routes.thing_deep_path(2, third_required: 3, first_optional: 1))
|
245
|
+
expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1, second_required: 2 })")).to eq(routes.thing_deep_path(3, first_optional: 1, second_required: 2))
|
246
|
+
expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1, second_required: 2, forth_optional: 4 })")).to eq(routes.thing_deep_path(3, first_optional: 1, second_required: 2, forth_optional: 4))
|
247
|
+
expect(evaljs("Routes.thing_deep_path(4, { first_optional: 1, second_required: 2, third_required: 3 })")).to eq(routes.thing_deep_path(4, first_optional: 1, second_required: 2, third_required: 3))
|
248
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, { third_required: 3 })")).to eq(routes.thing_deep_path(1, 2, third_required: 3))
|
249
|
+
expect(evaljs("Routes.thing_deep_path(1,2, {third_required: 3, q: 'bogdan'})")).to eq(routes.thing_deep_path(1,2, {third_required: 3, q: 'bogdan'}))
|
250
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, { forth_optional: 4, third_required: 3 })")).to eq(routes.thing_deep_path(1, 2, forth_optional: 4, third_required: 3))
|
251
|
+
expect(evaljs("Routes.thing_deep_path(1, 3, { second_required: 2 })")).to eq(routes.thing_deep_path(1, 3, second_required: 2))
|
252
|
+
expect(evaljs("Routes.thing_deep_path(1, 4, { second_required: 2, third_required: 3 })")).to eq(routes.thing_deep_path(1, 4, second_required: 2, third_required: 3))
|
253
|
+
expect(evaljs("Routes.thing_deep_path(2, 3, { first_optional: 1 })")).to eq(routes.thing_deep_path(2, 3, first_optional: 1))
|
254
|
+
expect(evaljs("Routes.thing_deep_path(2, 3, { first_optional: 1, forth_optional: 4 })")).to eq(routes.thing_deep_path(2, 3, first_optional: 1, forth_optional: 4))
|
255
|
+
expect(evaljs("Routes.thing_deep_path(2, 4, { first_optional: 1, third_required: 3 })")).to eq(routes.thing_deep_path(2, 4, first_optional: 1, third_required: 3))
|
256
|
+
expect(evaljs("Routes.thing_deep_path(3, 4, { first_optional: 1, second_required: 2 })")).to eq(routes.thing_deep_path(3, 4, first_optional: 1, second_required: 2))
|
257
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, 3)")).to eq(routes.thing_deep_path(1, 2, 3))
|
258
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, 3, { forth_optional: 4 })")).to eq(routes.thing_deep_path(1, 2, 3, forth_optional: 4))
|
259
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, 4, { third_required: 3 })")).to eq(routes.thing_deep_path(1, 2, 4, third_required: 3))
|
260
|
+
expect(evaljs("Routes.thing_deep_path(1, 3, 4, { second_required: 2 })")).to eq(routes.thing_deep_path(1, 3, 4, second_required: 2))
|
261
|
+
expect(evaljs("Routes.thing_deep_path(2, 3, 4, { first_optional: 1 })")).to eq(routes.thing_deep_path(2, 3, 4, first_optional: 1))
|
262
|
+
expect(evaljs("Routes.thing_deep_path(1, 2, 3, 4)")).to eq(routes.thing_deep_path(1, 2, 3, 4))
|
263
|
+
|
207
264
|
end
|
208
265
|
|
209
266
|
context "on nested optional parts" do
|
@@ -232,7 +289,7 @@ describe JsRoutes, "compatibility with Rails" do
|
|
232
289
|
|
233
290
|
it "should throw Exceptions if when there is too many parameters" do
|
234
291
|
expect {
|
235
|
-
evaljs("Routes.inbox_path(1,2)")
|
292
|
+
evaljs("Routes.inbox_path(1,2,3)")
|
236
293
|
}.to raise_error(js_error_class)
|
237
294
|
end
|
238
295
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/routes.rb
CHANGED
@@ -29,6 +29,9 @@ def draw_routes
|
|
29
29
|
resources :things
|
30
30
|
end
|
31
31
|
|
32
|
+
get "(/sep1/:first_optional)/sep2/:second_required/sep3/:third_required(/:forth_optional)",
|
33
|
+
as: :thing_deep, controller: :things, action: :show
|
34
|
+
|
32
35
|
if Rails.version < "5.0.0"
|
33
36
|
get "/:controller(/:action(/:id))" => "classic#classic", :as => :classic
|
34
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: therubyracer
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
202
|
version: '0'
|
189
203
|
requirements: []
|
190
204
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.5.1
|
192
206
|
signing_key:
|
193
207
|
specification_version: 4
|
194
208
|
summary: Brings Rails named routes to javascript
|