actionpack-direct_routes 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04dad950a368d988adfa9444337430b56c7811bd
4
- data.tar.gz: 5bee513482a615aa1ece1b3cc851145bae383832
3
+ metadata.gz: c611d4a1232d18dcd4e3ced61f65b49cb7bfac97
4
+ data.tar.gz: 3c3e2639108b0ca64391242483f4742bd1d47067
5
5
  SHA512:
6
- metadata.gz: d366a84f1ee4c990a00c83c2b1432d38bce5b459f3af41cb2ef088dbe883ca239d9d6e30cf672e63998cb798dabe7a71f1bf4c386a1b82f79a89fa8cfe682a5a
7
- data.tar.gz: 7bdca729b229c83f7a8449a131a7ddf1c2d7c186394001203d2b7581f3b7ba10b4d15aa9f128397965d7b9c1193bf03da998371831a9aee35036537d782f6045
6
+ metadata.gz: d2296422d9978c7cf51351ddd218bf449eec57d1eba7c3dbc33de79cf9c1d69909af10dc4aecb0e729f7ef6042a53ffa748e89786c0874b61e7a5c15b9fb4852
7
+ data.tar.gz: 576cfb2fc04e49a48370ecb58e80ba91cce741c6b9c28d094b16b86787886c9012ec1a08b0c8d2558c42c029de0fa9a1cd5dd6c3285fbfa7a94027f769a99da4
@@ -15,7 +15,7 @@ module ActionDispatch
15
15
 
16
16
  def call(t, args, only_path = false)
17
17
  options = args.extract_options!
18
- url = t.url_for(eval_block(t, args, options))
18
+ url = t.full_url_for(eval_block(t, args, options))
19
19
 
20
20
  if only_path
21
21
  "/" + url.partition(%r{(?<!/)/(?!/)}).last
@@ -9,6 +9,10 @@ module ActionDispatch
9
9
  proxy.url_for(options)
10
10
  end
11
11
 
12
+ def full_url_for(options)
13
+ proxy.full_url_for(options)
14
+ end
15
+
12
16
  def optimize_routes_generation?
13
17
  proxy.optimize_routes_generation?
14
18
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "route_set/url_helpers"
4
+
5
+ module ActionDispatch
6
+ module Routing
7
+ module DirectRoutes
8
+ module UrlFor
9
+ def self.included(url_for_module)
10
+ url_for_module.module_exec { alias full_url_for url_for }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,9 +7,11 @@ ActiveSupport.on_load(:before_initialize) do
7
7
  require "action_dispatch/routing/direct_routes/mapper/scope"
8
8
  require "action_dispatch/routing/direct_routes/route_set"
9
9
  require "action_dispatch/routing/direct_routes/route_set/named_route_collection"
10
+ require "action_dispatch/routing/direct_routes/url_for"
10
11
 
11
12
  ActionDispatch::Routing::Mapper.include(ActionDispatch::Routing::DirectRoutes::Mapper)
12
13
  ActionDispatch::Routing::Mapper::Scope.include(ActionDispatch::Routing::DirectRoutes::Mapper::Scope)
13
14
  ActionDispatch::Routing::RouteSet.prepend(ActionDispatch::Routing::DirectRoutes::RouteSet)
14
15
  ActionDispatch::Routing::RouteSet::NamedRouteCollection.include(ActionDispatch::Routing::DirectRoutes::RouteSet::NamedRouteCollection)
16
+ ActionDispatch::Routing::UrlFor.include(ActionDispatch::Routing::DirectRoutes::UrlFor)
15
17
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionPack
4
4
  module DirectRoutes
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
File without changes
@@ -0,0 +1,2 @@
1
+ DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from require at test/dummy/bin/rails:4)
2
+ DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from require at test/dummy/bin/rails:4)
@@ -0,0 +1,610 @@
1
+  (0.1ms) begin transaction
2
+ ------------------------------------------------------------------------------
3
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
4
+ ------------------------------------------------------------------------------
5
+  (0.1ms) rollback transaction
6
+  (0.3ms) begin transaction
7
+ ----------------------------------------------------------------------
8
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
9
+ ----------------------------------------------------------------------
10
+  (0.0ms) rollback transaction
11
+  (0.0ms) begin transaction
12
+ ---------------------------------------
13
+ CustomUrlHelpersTest: test_direct_paths
14
+ ---------------------------------------
15
+  (0.0ms) rollback transaction
16
+  (0.0ms) begin transaction
17
+ --------------------------------------
18
+ CustomUrlHelpersTest: test_direct_urls
19
+ --------------------------------------
20
+  (0.0ms) rollback transaction
21
+  (0.2ms) begin transaction
22
+ ---------------------------------------------------------
23
+ RoutingTest: test_named_routes_are_cleared_when_reloading
24
+ ---------------------------------------------------------
25
+  (0.2ms) begin transaction
26
+ -----------------------------------------------------------------------------
27
+ RoutingTest: test_reloads_routes_when_configuration_is_changed_in_development
28
+ -----------------------------------------------------------------------------
29
+  (0.1ms) rollback transaction
30
+  (0.3ms) rollback transaction
31
+  (0.3ms) begin transaction
32
+ ----------------------------------------------------------------------------
33
+ RoutingTest: test_reloads_routes_when_configuration_is_changed_in_production
34
+ ----------------------------------------------------------------------------
35
+  (0.2ms) begin transaction
36
+ -------------------------------------------------------------
37
+ RoutingTest: test_routes_are_added_and_removed_when_reloading
38
+ -------------------------------------------------------------
39
+  (0.1ms) rollback transaction
40
+  (0.1ms) rollback transaction
41
+  (0.9ms) begin transaction
42
+ --------------------------------------
43
+ CustomUrlHelpersTest: test_direct_urls
44
+ --------------------------------------
45
+  (0.4ms) begin transaction
46
+ ----------------------------------------------------------------------
47
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
48
+ ----------------------------------------------------------------------
49
+  (0.1ms) rollback transaction
50
+  (0.1ms) rollback transaction
51
+  (0.4ms) begin transaction
52
+ ---------------------------------------
53
+ CustomUrlHelpersTest: test_direct_paths
54
+ ---------------------------------------
55
+  (0.4ms) begin transaction
56
+ ------------------------------------------------------------------------------
57
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
58
+ ------------------------------------------------------------------------------
59
+  (0.1ms) rollback transaction
60
+  (0.1ms) rollback transaction
61
+  (0.1ms) begin transaction
62
+ ----------------------------------------------------------------------
63
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
64
+ ----------------------------------------------------------------------
65
+  (0.0ms) rollback transaction
66
+  (0.0ms) begin transaction
67
+ --------------------------------------
68
+ CustomUrlHelpersTest: test_direct_urls
69
+ --------------------------------------
70
+  (0.0ms) rollback transaction
71
+  (0.1ms) begin transaction
72
+ ------------------------------------------------------------------------------
73
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
74
+ ------------------------------------------------------------------------------
75
+  (0.1ms) rollback transaction
76
+  (0.2ms) begin transaction
77
+ ---------------------------------------
78
+ CustomUrlHelpersTest: test_direct_paths
79
+ ---------------------------------------
80
+  (0.0ms) rollback transaction
81
+  (0.3ms) begin transaction
82
+ ---------------------------------------------------------
83
+ RoutingTest: test_named_routes_are_cleared_when_reloading
84
+ ---------------------------------------------------------
85
+  (0.3ms) begin transaction
86
+ ----------------------------------------------------------------------------
87
+ RoutingTest: test_reloads_routes_when_configuration_is_changed_in_production
88
+ ----------------------------------------------------------------------------
89
+  (0.1ms) rollback transaction
90
+  (0.1ms) rollback transaction
91
+  (0.3ms) begin transaction
92
+ -----------------------------------------------------------------------------
93
+ RoutingTest: test_reloads_routes_when_configuration_is_changed_in_development
94
+ -----------------------------------------------------------------------------
95
+  (0.3ms) begin transaction
96
+ -------------------------------------------------------------
97
+ RoutingTest: test_routes_are_added_and_removed_when_reloading
98
+ -------------------------------------------------------------
99
+  (0.2ms) rollback transaction
100
+  (0.1ms) rollback transaction
101
+  (0.3ms) begin transaction
102
+ ----------------------------------------------------------------------
103
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
104
+ ----------------------------------------------------------------------
105
+  (1.0ms) begin transaction
106
+ ---------------------------------------
107
+ CustomUrlHelpersTest: test_direct_paths
108
+ ---------------------------------------
109
+  (0.1ms) rollback transaction
110
+  (0.1ms) rollback transaction
111
+  (0.3ms) begin transaction
112
+ --------------------------------------
113
+ CustomUrlHelpersTest: test_direct_urls
114
+ --------------------------------------
115
+  (0.3ms) begin transaction
116
+ ------------------------------------------------------------------------------
117
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
118
+ ------------------------------------------------------------------------------
119
+  (0.1ms) rollback transaction
120
+  (0.1ms) rollback transaction
121
+  (0.5ms) begin transaction
122
+  (0.4ms) begin transaction
123
+ --------------------------------------
124
+ CustomUrlHelpersTest: test_direct_urls
125
+ --------------------------------------
126
+ ---------------------------------------
127
+ CustomUrlHelpersTest: test_direct_paths
128
+ ---------------------------------------
129
+  (0.1ms) rollback transaction
130
+  (0.1ms) rollback transaction
131
+  (0.3ms) begin transaction
132
+ ------------------------------------------------------------------------------
133
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
134
+ ------------------------------------------------------------------------------
135
+  (1.0ms) begin transaction
136
+ ----------------------------------------------------------------------
137
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
138
+ ----------------------------------------------------------------------
139
+  (0.1ms) rollback transaction
140
+  (0.0ms) rollback transaction
141
+  (0.1ms) begin transaction
142
+ --------------------------------------
143
+ CustomUrlHelpersTest: test_direct_urls
144
+ --------------------------------------
145
+  (0.1ms) rollback transaction
146
+  (0.0ms) begin transaction
147
+ ------------------------------------------------------------------------------
148
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
149
+ ------------------------------------------------------------------------------
150
+  (0.0ms) rollback transaction
151
+  (0.1ms) begin transaction
152
+ ---------------------------------------
153
+ CustomUrlHelpersTest: test_direct_paths
154
+ ---------------------------------------
155
+  (0.1ms) rollback transaction
156
+  (0.2ms) begin transaction
157
+ ----------------------------------------------------------------------
158
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
159
+ ----------------------------------------------------------------------
160
+  (0.0ms) rollback transaction
161
+  (0.1ms) begin transaction
162
+ ------------------------------------------------------------------------------
163
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
164
+ ------------------------------------------------------------------------------
165
+  (0.2ms) rollback transaction
166
+  (0.1ms) begin transaction
167
+ ----------------------------------------------------------------------
168
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
169
+ ----------------------------------------------------------------------
170
+  (0.0ms) rollback transaction
171
+  (0.1ms) begin transaction
172
+ --------------------------------------
173
+ CustomUrlHelpersTest: test_direct_urls
174
+ --------------------------------------
175
+  (0.0ms) rollback transaction
176
+  (0.0ms) begin transaction
177
+ ---------------------------------------
178
+ CustomUrlHelpersTest: test_direct_paths
179
+ ---------------------------------------
180
+  (0.0ms) rollback transaction
181
+  (0.1ms) begin transaction
182
+ ---------------------------------------
183
+ CustomUrlHelpersTest: test_direct_paths
184
+ ---------------------------------------
185
+  (0.1ms) rollback transaction
186
+  (0.1ms) begin transaction
187
+ ---------------------------------------
188
+ CustomUrlHelpersTest: test_direct_paths
189
+ ---------------------------------------
190
+  (0.1ms) rollback transaction
191
+  (0.1ms) begin transaction
192
+ ---------------------------------------
193
+ CustomUrlHelpersTest: test_direct_paths
194
+ ---------------------------------------
195
+  (0.1ms) rollback transaction
196
+  (0.1ms) begin transaction
197
+ ---------------------------------------
198
+ CustomUrlHelpersTest: test_direct_paths
199
+ ---------------------------------------
200
+  (0.1ms) rollback transaction
201
+  (0.3ms) begin transaction
202
+ ---------------------------------------
203
+ CustomUrlHelpersTest: test_direct_paths
204
+ ---------------------------------------
205
+  (0.1ms) rollback transaction
206
+  (0.1ms) begin transaction
207
+ ---------------------------------------
208
+ CustomUrlHelpersTest: test_direct_paths
209
+ ---------------------------------------
210
+  (0.1ms) rollback transaction
211
+  (0.1ms) begin transaction
212
+ ---------------------------------------
213
+ CustomUrlHelpersTest: test_direct_paths
214
+ ---------------------------------------
215
+  (0.1ms) rollback transaction
216
+  (0.1ms) begin transaction
217
+ ---------------------------------------
218
+ CustomUrlHelpersTest: test_direct_paths
219
+ ---------------------------------------
220
+  (0.1ms) rollback transaction
221
+  (0.1ms) begin transaction
222
+ ---------------------------------------
223
+ CustomUrlHelpersTest: test_direct_paths
224
+ ---------------------------------------
225
+  (0.1ms) rollback transaction
226
+  (0.1ms) begin transaction
227
+ ---------------------------------------
228
+ CustomUrlHelpersTest: test_direct_paths
229
+ ---------------------------------------
230
+  (0.1ms) rollback transaction
231
+  (0.1ms) begin transaction
232
+ ---------------------------------------
233
+ CustomUrlHelpersTest: test_direct_paths
234
+ ---------------------------------------
235
+  (0.1ms) rollback transaction
236
+  (0.1ms) begin transaction
237
+ ---------------------------------------
238
+ CustomUrlHelpersTest: test_direct_paths
239
+ ---------------------------------------
240
+  (0.1ms) rollback transaction
241
+  (0.1ms) begin transaction
242
+ ---------------------------------------
243
+ CustomUrlHelpersTest: test_direct_paths
244
+ ---------------------------------------
245
+  (0.1ms) rollback transaction
246
+  (0.1ms) begin transaction
247
+ ---------------------------------------
248
+ CustomUrlHelpersTest: test_direct_paths
249
+ ---------------------------------------
250
+  (0.1ms) rollback transaction
251
+  (0.1ms) begin transaction
252
+ ----------------------------------------------------------------------
253
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
254
+ ----------------------------------------------------------------------
255
+  (0.1ms) rollback transaction
256
+  (0.0ms) begin transaction
257
+ ---------------------------------------
258
+ CustomUrlHelpersTest: test_direct_paths
259
+ ---------------------------------------
260
+  (0.0ms) rollback transaction
261
+  (0.0ms) begin transaction
262
+ ------------------------------------------------------------------------------
263
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
264
+ ------------------------------------------------------------------------------
265
+  (0.3ms) rollback transaction
266
+  (0.0ms) begin transaction
267
+ --------------------------------------
268
+ CustomUrlHelpersTest: test_direct_urls
269
+ --------------------------------------
270
+  (0.0ms) rollback transaction
271
+  (0.2ms) begin transaction
272
+ ----------------------------------------------------------------------
273
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
274
+ ----------------------------------------------------------------------
275
+  (0.1ms) rollback transaction
276
+  (0.0ms) begin transaction
277
+ ---------------------------------------
278
+ CustomUrlHelpersTest: test_direct_paths
279
+ ---------------------------------------
280
+  (0.1ms) rollback transaction
281
+  (0.1ms) begin transaction
282
+ ------------------------------------------------------------------------------
283
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
284
+ ------------------------------------------------------------------------------
285
+  (1.0ms) rollback transaction
286
+  (0.0ms) begin transaction
287
+ --------------------------------------
288
+ CustomUrlHelpersTest: test_direct_urls
289
+ --------------------------------------
290
+  (0.3ms) rollback transaction
291
+  (0.1ms) begin transaction
292
+ ---------------------------------------
293
+ CustomUrlHelpersTest: test_direct_paths
294
+ ---------------------------------------
295
+  (0.1ms) rollback transaction
296
+  (0.3ms) begin transaction
297
+ ----------------------------------------------------------------------
298
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
299
+ ----------------------------------------------------------------------
300
+  (0.0ms) rollback transaction
301
+  (0.1ms) begin transaction
302
+ --------------------------------------
303
+ CustomUrlHelpersTest: test_direct_urls
304
+ --------------------------------------
305
+  (0.1ms) rollback transaction
306
+  (0.1ms) begin transaction
307
+ ------------------------------------------------------------------------------
308
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
309
+ ------------------------------------------------------------------------------
310
+  (0.1ms) rollback transaction
311
+  (0.1ms) begin transaction
312
+ ----------------------------------------------------------------------
313
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
314
+ ----------------------------------------------------------------------
315
+  (0.1ms) rollback transaction
316
+  (0.0ms) begin transaction
317
+ ---------------------------------------
318
+ CustomUrlHelpersTest: test_direct_paths
319
+ ---------------------------------------
320
+  (0.0ms) rollback transaction
321
+  (0.0ms) begin transaction
322
+ ------------------------------------------------------------------------------
323
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
324
+ ------------------------------------------------------------------------------
325
+  (0.0ms) rollback transaction
326
+  (0.0ms) begin transaction
327
+ --------------------------------------
328
+ CustomUrlHelpersTest: test_direct_urls
329
+ --------------------------------------
330
+  (0.0ms) rollback transaction
331
+  (0.1ms) begin transaction
332
+ ------------------------------------------------------------------------------
333
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
334
+ ------------------------------------------------------------------------------
335
+  (0.1ms) rollback transaction
336
+  (0.0ms) begin transaction
337
+ ----------------------------------------------------------------------
338
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
339
+ ----------------------------------------------------------------------
340
+  (0.0ms) rollback transaction
341
+  (0.0ms) begin transaction
342
+ --------------------------------------
343
+ CustomUrlHelpersTest: test_direct_urls
344
+ --------------------------------------
345
+  (0.0ms) rollback transaction
346
+  (0.0ms) begin transaction
347
+ ---------------------------------------
348
+ CustomUrlHelpersTest: test_direct_paths
349
+ ---------------------------------------
350
+  (0.0ms) rollback transaction
351
+  (0.2ms) begin transaction
352
+ ----------------------------------------------------------------------
353
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
354
+ ----------------------------------------------------------------------
355
+  (0.1ms) rollback transaction
356
+  (0.0ms) begin transaction
357
+ ---------------------------------------
358
+ CustomUrlHelpersTest: test_direct_paths
359
+ ---------------------------------------
360
+  (0.0ms) rollback transaction
361
+  (0.0ms) begin transaction
362
+ ------------------------------------------------------------------------------
363
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
364
+ ------------------------------------------------------------------------------
365
+  (0.0ms) rollback transaction
366
+  (0.0ms) begin transaction
367
+ --------------------------------------
368
+ CustomUrlHelpersTest: test_direct_urls
369
+ --------------------------------------
370
+  (0.0ms) rollback transaction
371
+  (0.1ms) begin transaction
372
+ ------------------------------------------------------------------------------
373
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
374
+ ------------------------------------------------------------------------------
375
+  (0.0ms) rollback transaction
376
+  (0.0ms) begin transaction
377
+ ----------------------------------------------------------------------
378
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
379
+ ----------------------------------------------------------------------
380
+  (0.0ms) rollback transaction
381
+  (0.1ms) begin transaction
382
+ ---------------------------------------
383
+ CustomUrlHelpersTest: test_direct_paths
384
+ ---------------------------------------
385
+  (0.1ms) rollback transaction
386
+  (0.0ms) begin transaction
387
+ --------------------------------------
388
+ CustomUrlHelpersTest: test_direct_urls
389
+ --------------------------------------
390
+  (0.0ms) rollback transaction
391
+  (0.1ms) begin transaction
392
+ --------------------------------------
393
+ CustomUrlHelpersTest: test_direct_urls
394
+ --------------------------------------
395
+  (0.1ms) rollback transaction
396
+  (0.3ms) begin transaction
397
+ ------------------------------------------------------------------------------
398
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
399
+ ------------------------------------------------------------------------------
400
+  (0.0ms) rollback transaction
401
+  (0.0ms) begin transaction
402
+ ----------------------------------------------------------------------
403
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
404
+ ----------------------------------------------------------------------
405
+  (0.0ms) rollback transaction
406
+  (0.0ms) begin transaction
407
+ ---------------------------------------
408
+ CustomUrlHelpersTest: test_direct_paths
409
+ ---------------------------------------
410
+  (0.0ms) rollback transaction
411
+  (0.1ms) begin transaction
412
+ --------------------------------------
413
+ CustomUrlHelpersTest: test_direct_urls
414
+ --------------------------------------
415
+  (0.1ms) rollback transaction
416
+  (0.1ms) begin transaction
417
+ ------------------------------------------------------------------------------
418
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
419
+ ------------------------------------------------------------------------------
420
+  (0.0ms) rollback transaction
421
+  (0.0ms) begin transaction
422
+ ----------------------------------------------------------------------
423
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
424
+ ----------------------------------------------------------------------
425
+  (0.0ms) rollback transaction
426
+  (0.0ms) begin transaction
427
+ ---------------------------------------
428
+ CustomUrlHelpersTest: test_direct_paths
429
+ ---------------------------------------
430
+  (0.0ms) rollback transaction
431
+  (0.1ms) begin transaction
432
+ ---------------------------------------
433
+ CustomUrlHelpersTest: test_direct_paths
434
+ ---------------------------------------
435
+  (0.1ms) rollback transaction
436
+  (0.0ms) begin transaction
437
+ --------------------------------------
438
+ CustomUrlHelpersTest: test_direct_urls
439
+ --------------------------------------
440
+  (0.0ms) rollback transaction
441
+  (0.0ms) begin transaction
442
+ ------------------------------------------------------------------------------
443
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
444
+ ------------------------------------------------------------------------------
445
+  (0.0ms) rollback transaction
446
+  (0.0ms) begin transaction
447
+ ----------------------------------------------------------------------
448
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
449
+ ----------------------------------------------------------------------
450
+  (0.0ms) rollback transaction
451
+  (0.1ms) begin transaction
452
+ ---------------------------------------
453
+ CustomUrlHelpersTest: test_direct_paths
454
+ ---------------------------------------
455
+  (0.0ms) rollback transaction
456
+  (0.3ms) begin transaction
457
+ ------------------------------------------------------------------------------
458
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
459
+ ------------------------------------------------------------------------------
460
+  (0.0ms) rollback transaction
461
+  (0.3ms) begin transaction
462
+ --------------------------------------
463
+ CustomUrlHelpersTest: test_direct_urls
464
+ --------------------------------------
465
+  (0.0ms) rollback transaction
466
+  (0.2ms) begin transaction
467
+ ----------------------------------------------------------------------
468
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
469
+ ----------------------------------------------------------------------
470
+  (0.0ms) rollback transaction
471
+  (0.1ms) begin transaction
472
+ ------------------------------------------------------------------------------
473
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
474
+ ------------------------------------------------------------------------------
475
+  (0.0ms) rollback transaction
476
+  (0.0ms) begin transaction
477
+ ---------------------------------------
478
+ CustomUrlHelpersTest: test_direct_paths
479
+ ---------------------------------------
480
+  (0.1ms) rollback transaction
481
+  (0.1ms) begin transaction
482
+ ----------------------------------------------------------------------
483
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
484
+ ----------------------------------------------------------------------
485
+  (0.1ms) rollback transaction
486
+  (0.0ms) begin transaction
487
+ --------------------------------------
488
+ CustomUrlHelpersTest: test_direct_urls
489
+ --------------------------------------
490
+  (0.0ms) rollback transaction
491
+  (0.1ms) begin transaction
492
+ ----------------------------------------------------------------------
493
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
494
+ ----------------------------------------------------------------------
495
+  (0.0ms) rollback transaction
496
+  (0.0ms) begin transaction
497
+ ------------------------------------------------------------------------------
498
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
499
+ ------------------------------------------------------------------------------
500
+  (0.0ms) rollback transaction
501
+  (0.0ms) begin transaction
502
+ ---------------------------------------
503
+ CustomUrlHelpersTest: test_direct_paths
504
+ ---------------------------------------
505
+  (0.1ms) rollback transaction
506
+  (0.1ms) begin transaction
507
+ --------------------------------------
508
+ CustomUrlHelpersTest: test_direct_urls
509
+ --------------------------------------
510
+  (0.1ms) rollback transaction
511
+  (0.1ms) begin transaction
512
+ ---------------------------------------
513
+ CustomUrlHelpersTest: test_direct_paths
514
+ ---------------------------------------
515
+  (0.1ms) rollback transaction
516
+  (0.0ms) begin transaction
517
+ ------------------------------------------------------------------------------
518
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
519
+ ------------------------------------------------------------------------------
520
+  (0.0ms) rollback transaction
521
+  (0.0ms) begin transaction
522
+ ----------------------------------------------------------------------
523
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
524
+ ----------------------------------------------------------------------
525
+  (0.0ms) rollback transaction
526
+  (0.1ms) begin transaction
527
+ --------------------------------------
528
+ CustomUrlHelpersTest: test_direct_urls
529
+ --------------------------------------
530
+  (0.0ms) rollback transaction
531
+  (0.1ms) begin transaction
532
+ ------------------------------------
533
+ DirectRoutesTest: test_direct_routes
534
+ ------------------------------------
535
+  (0.1ms) rollback transaction
536
+  (0.1ms) begin transaction
537
+ ---------------------------------------
538
+ CustomUrlHelpersTest: test_direct_paths
539
+ ---------------------------------------
540
+  (0.1ms) rollback transaction
541
+  (0.0ms) begin transaction
542
+ --------------------------------------
543
+ CustomUrlHelpersTest: test_direct_urls
544
+ --------------------------------------
545
+  (0.1ms) rollback transaction
546
+  (0.0ms) begin transaction
547
+ ------------------------------------------------------------------------------
548
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
549
+ ------------------------------------------------------------------------------
550
+  (0.0ms) rollback transaction
551
+  (0.0ms) begin transaction
552
+ ----------------------------------------------------------------------
553
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
554
+ ----------------------------------------------------------------------
555
+  (0.1ms) rollback transaction
556
+  (0.0ms) begin transaction
557
+ ------------------------------------
558
+ DirectRoutesTest: test_direct_routes
559
+ ------------------------------------
560
+  (0.1ms) rollback transaction
561
+  (0.1ms) begin transaction
562
+ ------------------------------------------------------------------------------
563
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
564
+ ------------------------------------------------------------------------------
565
+  (0.0ms) rollback transaction
566
+  (0.0ms) begin transaction
567
+ ----------------------------------------------------------------------
568
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
569
+ ----------------------------------------------------------------------
570
+  (0.1ms) rollback transaction
571
+  (0.0ms) begin transaction
572
+ ---------------------------------------
573
+ CustomUrlHelpersTest: test_direct_paths
574
+ ---------------------------------------
575
+  (0.1ms) rollback transaction
576
+  (0.0ms) begin transaction
577
+ --------------------------------------
578
+ CustomUrlHelpersTest: test_direct_urls
579
+ --------------------------------------
580
+  (0.1ms) rollback transaction
581
+  (0.0ms) begin transaction
582
+ ------------------------------------
583
+ DirectRoutesTest: test_direct_routes
584
+ ------------------------------------
585
+  (0.1ms) rollback transaction
586
+  (0.1ms) begin transaction
587
+ ------------------------------------------------------------------------------
588
+ CustomUrlHelpersTest: test_defining_direct_inside_a_scope_raises_runtime_error
589
+ ------------------------------------------------------------------------------
590
+  (0.0ms) rollback transaction
591
+  (0.0ms) begin transaction
592
+ ----------------------------------------------------------------------
593
+ CustomUrlHelpersTest: test_defining_direct_url_registers_helper_method
594
+ ----------------------------------------------------------------------
595
+  (0.1ms) rollback transaction
596
+  (0.0ms) begin transaction
597
+ ---------------------------------------
598
+ CustomUrlHelpersTest: test_direct_paths
599
+ ---------------------------------------
600
+  (0.0ms) rollback transaction
601
+  (0.2ms) begin transaction
602
+ --------------------------------------
603
+ CustomUrlHelpersTest: test_direct_urls
604
+ --------------------------------------
605
+  (0.0ms) rollback transaction
606
+  (0.0ms) begin transaction
607
+ ------------------------------------
608
+ DirectRoutesTest: test_direct_routes
609
+ ------------------------------------
610
+  (0.0ms) rollback transaction
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ require File.expand_path("../../../test/dummy/config/environment.rb", __FILE__)
6
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../../test/dummy/db/migrate", __FILE__)]
7
+ require "rails/test_help"
8
+
9
+ class DirectRoutesTest < ActionView::TestCase
10
+ class Linkable
11
+ attr_reader :id
12
+
13
+ def self.name
14
+ super.demodulize
15
+ end
16
+
17
+ def initialize(id)
18
+ @id = id
19
+ end
20
+
21
+ def linkable_type
22
+ self.class.name.underscore
23
+ end
24
+ end
25
+
26
+ class Category < Linkable; end
27
+ class Collection < Linkable; end
28
+ class Product < Linkable; end
29
+
30
+ Routes = ActionDispatch::Routing::RouteSet.new
31
+ Routes.draw do
32
+ resources :categories, :collections, :products
33
+ direct(:linkable) { |linkable| [:"#{linkable.linkable_type}", { id: linkable.id }] }
34
+ end
35
+
36
+ include Routes.url_helpers
37
+
38
+ def setup
39
+ @category = Category.new("1")
40
+ @collection = Collection.new("2")
41
+ @product = Product.new("3")
42
+ end
43
+
44
+ def test_direct_routes
45
+ assert_equal "/categories/1", linkable_path(@category)
46
+ assert_equal "/collections/2", linkable_path(@collection)
47
+ assert_equal "/products/3", linkable_path(@product)
48
+
49
+ assert_equal "http://test.host/categories/1", linkable_url(@category)
50
+ assert_equal "http://test.host/collections/2", linkable_url(@collection)
51
+ assert_equal "http://test.host/products/3", linkable_url(@product)
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack-direct_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hamuyuuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-02 00:00:00.000000000 Z
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -165,6 +165,7 @@ files:
165
165
  - lib/action_dispatch/routing/direct_routes/route_set/custom_url_helper.rb
166
166
  - lib/action_dispatch/routing/direct_routes/route_set/named_route_collection.rb
167
167
  - lib/action_dispatch/routing/direct_routes/route_set/url_helpers.rb
168
+ - lib/action_dispatch/routing/direct_routes/url_for.rb
168
169
  - lib/actionpack/direct_routes.rb
169
170
  - lib/actionpack/direct_routes/version.rb
170
171
  - test/application/routing_test.rb
@@ -199,11 +200,15 @@ files:
199
200
  - test/dummy/config/locales/en.yml
200
201
  - test/dummy/config/routes.rb
201
202
  - test/dummy/config/secrets.yml
203
+ - test/dummy/db/test.sqlite3
204
+ - test/dummy/log/development.log
205
+ - test/dummy/log/test.log
202
206
  - test/dummy/public/404.html
203
207
  - test/dummy/public/422.html
204
208
  - test/dummy/public/500.html
205
209
  - test/dummy/public/favicon.ico
206
210
  - test/integration/custom_url_helpers_test.rb
211
+ - test/integration/direct_routes_test.rb
207
212
  - test/test_helper.rb
208
213
  homepage: https://github.com/hamuyuuki/actionpack-direct_routes
209
214
  licenses:
@@ -230,41 +235,45 @@ signing_key:
230
235
  specification_version: 4
231
236
  summary: Backport Direct routes into Rails 4 and Rails 5.0.
232
237
  test_files:
238
+ - test/test_helper.rb
239
+ - test/application/routing_test.rb
240
+ - test/integration/direct_routes_test.rb
233
241
  - test/integration/custom_url_helpers_test.rb
234
- - test/dummy/config/application.rb
235
- - test/dummy/config/boot.rb
236
- - test/dummy/config/routes.rb
242
+ - test/dummy/app/controllers/application_controller.rb
243
+ - test/dummy/app/helpers/application_helper.rb
244
+ - test/dummy/app/views/layouts/application.html.erb
245
+ - test/dummy/app/assets/javascripts/application.js
246
+ - test/dummy/app/assets/stylesheets/application.css
237
247
  - test/dummy/config/locales/en.yml
238
- - test/dummy/config/initializers/backtrace_silencers.rb
239
- - test/dummy/config/initializers/cookies_serializer.rb
248
+ - test/dummy/config/database.yml
249
+ - test/dummy/config/environments/production.rb
250
+ - test/dummy/config/environments/development.rb
251
+ - test/dummy/config/environments/test.rb
252
+ - test/dummy/config/secrets.yml
253
+ - test/dummy/config/environment.rb
254
+ - test/dummy/config/routes.rb
255
+ - test/dummy/config/boot.rb
256
+ - test/dummy/config/application.rb
240
257
  - test/dummy/config/initializers/to_time_preserves_timezone.rb
241
- - test/dummy/config/initializers/wrap_parameters.rb
258
+ - test/dummy/config/initializers/assets.rb
259
+ - test/dummy/config/initializers/cookies_serializer.rb
260
+ - test/dummy/config/initializers/mime_types.rb
242
261
  - test/dummy/config/initializers/session_store.rb
243
262
  - test/dummy/config/initializers/filter_parameter_logging.rb
244
- - test/dummy/config/initializers/assets.rb
263
+ - test/dummy/config/initializers/backtrace_silencers.rb
245
264
  - test/dummy/config/initializers/inflections.rb
246
- - test/dummy/config/initializers/mime_types.rb
247
- - test/dummy/config/secrets.yml
248
- - test/dummy/config/environment.rb
249
- - test/dummy/config/database.yml
250
- - test/dummy/config/environments/development.rb
251
- - test/dummy/config/environments/production.rb
252
- - test/dummy/config/environments/test.rb
253
- - test/dummy/bin/setup
254
- - test/dummy/bin/rails
255
- - test/dummy/bin/bundle
256
- - test/dummy/bin/rake
257
- - test/dummy/app/views/layouts/application.html.erb
258
- - test/dummy/app/assets/stylesheets/application.css
259
- - test/dummy/app/assets/javascripts/application.js
260
- - test/dummy/app/controllers/application_controller.rb
261
- - test/dummy/app/helpers/application_helper.rb
262
- - test/dummy/public/404.html
263
- - test/dummy/public/favicon.ico
265
+ - test/dummy/config/initializers/wrap_parameters.rb
266
+ - test/dummy/README.rdoc
264
267
  - test/dummy/public/500.html
268
+ - test/dummy/public/favicon.ico
265
269
  - test/dummy/public/422.html
270
+ - test/dummy/public/404.html
271
+ - test/dummy/bin/bundle
272
+ - test/dummy/bin/rake
273
+ - test/dummy/bin/rails
274
+ - test/dummy/bin/setup
266
275
  - test/dummy/config.ru
276
+ - test/dummy/db/test.sqlite3
267
277
  - test/dummy/Rakefile
268
- - test/dummy/README.rdoc
269
- - test/application/routing_test.rb
270
- - test/test_helper.rb
278
+ - test/dummy/log/development.log
279
+ - test/dummy/log/test.log