crumbs 2.1.2 → 4.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +31 -41
  4. data/Rakefile +1 -14
  5. data/lib/crumbs/definitions.rb +26 -0
  6. data/lib/crumbs/dsl/controller.rb +7 -11
  7. data/lib/crumbs/dsl/namespace.rb +8 -4
  8. data/lib/crumbs/extensions/action_controller/base.rb +43 -0
  9. data/lib/crumbs/proxy.rb +10 -7
  10. data/lib/crumbs/railtie.rb +4 -2
  11. data/lib/crumbs/version.rb +1 -1
  12. data/lib/crumbs.rb +7 -38
  13. data/lib/generators/crumbs/install/install_generator.rb +15 -0
  14. data/test/dummy/Rakefile +1 -2
  15. data/test/dummy/app/assets/javascripts/application.js +2 -2
  16. data/test/dummy/app/assets/stylesheets/application.css +6 -4
  17. data/test/dummy/app/controllers/admin/reports/deliveries_controller.rb +6 -0
  18. data/test/dummy/app/controllers/admin/users_controller.rb +9 -0
  19. data/test/dummy/app/controllers/pages_controller.rb +0 -21
  20. data/test/dummy/app/views/application/_crumbs.html.erb +3 -0
  21. data/test/dummy/app/views/application/index.html.erb +1 -0
  22. data/test/dummy/app/views/application/show.html.erb +1 -0
  23. data/test/dummy/app/views/layouts/application.html.erb +9 -11
  24. data/test/dummy/bin/bundle +1 -0
  25. data/test/dummy/bin/rails +2 -1
  26. data/test/dummy/bin/rake +1 -0
  27. data/test/dummy/bin/setup +30 -0
  28. data/test/dummy/config/application.rb +6 -1
  29. data/test/dummy/config/boot.rb +1 -1
  30. data/test/dummy/config/crumbs.rb +15 -12
  31. data/test/dummy/config/environment.rb +1 -1
  32. data/test/dummy/config/environments/development.rb +14 -5
  33. data/test/dummy/config/environments/production.rb +18 -26
  34. data/test/dummy/config/environments/test.rb +10 -12
  35. data/test/dummy/config/initializers/assets.rb +11 -0
  36. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  37. data/test/dummy/config/initializers/mime_types.rb +1 -2
  38. data/test/dummy/config/initializers/session_store.rb +1 -1
  39. data/test/dummy/config/locales/en.yml +1 -23
  40. data/test/dummy/config/routes.rb +9 -70
  41. data/test/dummy/config/secrets.yml +22 -0
  42. data/test/dummy/config.ru +1 -1
  43. data/test/dummy/log/development.log +0 -0
  44. data/test/dummy/log/test.log +1050 -0
  45. data/test/dummy/public/404.html +58 -55
  46. data/test/dummy/public/422.html +58 -55
  47. data/test/dummy/public/500.html +57 -54
  48. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  49. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8e/8eFn-IE_QAK9wkb3vBoqeyKxaN7o1hbJQnrz-uVvvQA.cache +0 -0
  50. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  51. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RP/RPShcX3Jre4zxu1UEaxs1Tw4slXRjICXTyfQvtEWC7M.cache +0 -0
  52. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache +1 -0
  53. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache +1 -0
  54. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache +1 -0
  55. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  56. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache +1 -0
  57. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache +1 -0
  58. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  59. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache +0 -0
  60. data/test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache +1 -0
  61. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache +1 -0
  62. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yv/yv8GQNKBriraHQF7esI3Zifw_OgHI0-bFlUD2nbZ3fw.cache +0 -0
  63. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zn/znrkcru9CbH2razkpdTQATvom11yKHllvnOQyyPSJAo.cache +0 -0
  64. data/test/generator_test.rb +5 -6
  65. data/test/test_helper.rb +4 -13
  66. data/test/view_test.rb +40 -0
  67. metadata +71 -31
  68. data/lib/crumbs/action_controller/base.rb +0 -47
  69. data/lib/generators/crumbs/install_generator.rb +0 -14
  70. data/lib/generators/crumbs/templates/configure.rb +0 -2
  71. data/test/dummy/README.rdoc +0 -28
  72. data/test/dummy/app/controllers/namespace/pages_controller.rb +0 -8
  73. data/test/dummy/app/views/pages/crumbs.html.erb +0 -3
  74. data/test/dummy/config/database.yml +0 -25
  75. data/test/dummy/config/initializers/secret_token.rb +0 -13
  76. data/test/dummy/db/schema.rb +0 -16
  77. data/test/with_last_test.rb +0 -553
  78. data/test/without_last_test.rb +0 -495
  79. /data/lib/generators/crumbs/{templates/define.rb → install/templates/configuration.rb} +0 -0
@@ -1,553 +0,0 @@
1
- require 'test_helper'
2
-
3
- class WithLastTest < ActionDispatch::IntegrationTest
4
-
5
- setup do
6
- Crumbs.config.show_last = true
7
- end
8
-
9
- test 'namespaced controller' do
10
- get '/namespaced'
11
- assert_equal(
12
- [
13
- { base_url: 'http://www.example.com', path: '/namespaced', fullpath: '/namespaced' }
14
- ],
15
- session[:referers]
16
- )
17
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
18
- assert_select 'a', 2
19
- assert_select 'a[href="/"]:contains("Home")'
20
- assert_select 'a[href="/namespaced"]:contains("Namespaced Home")'
21
- else
22
- assert_select 'a', count: 2
23
- assert_select 'a[href="/"]', 'Home'
24
- assert_select 'a[href="/namespaced"]', 'Namespaced Home'
25
- end
26
- end
27
-
28
- test 'last request in same path' do
29
- get '/'
30
- assert_equal(
31
- [
32
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
33
- ],
34
- session[:referers]
35
- )
36
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
37
- assert_select 'a', 1
38
- assert_select 'a[href="/"]:contains("Home")'
39
- else
40
- assert_select 'a', count: 1
41
- assert_select 'a[href="/"]', 'Home'
42
- end
43
-
44
- get '/static'
45
- assert_equal(
46
- [
47
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
48
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' }
49
- ],
50
- session[:referers]
51
- )
52
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
53
- assert_select 'a', 2
54
- assert_select 'a[href="/"]:contains("Home")'
55
- assert_select 'a[href="/static"]:contains("Static")'
56
- else
57
- assert_select 'a', count: 2
58
- assert_select 'a[href="/"]', 'Home'
59
- assert_select 'a[href="/static"]', 'Static'
60
- end
61
-
62
- get '/static/nested'
63
- assert_equal(
64
- [
65
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
66
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' },
67
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested' }
68
- ],
69
- session[:referers]
70
- )
71
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
72
- assert_select 'a', 3
73
- assert_select 'a[href="/"]:contains("Home")'
74
- assert_select 'a[href="/static"]:contains("Static")'
75
- assert_select 'a[href="/static/nested"]:contains("Nested")'
76
- else
77
- assert_select 'a', count: 3
78
- assert_select 'a[href="/"]', 'Home'
79
- assert_select 'a[href="/static"]', 'Static'
80
- assert_select 'a[href="/static/nested"]', 'Nested'
81
- end
82
-
83
- get '/'
84
- assert_equal(
85
- [
86
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
87
- ],
88
- session[:referers]
89
- )
90
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
91
- assert_select 'a', 1
92
- assert_select 'a[href="/"]:contains("Home")'
93
- else
94
- assert_select 'a', count: 1
95
- assert_select 'a[href="/"]', 'Home'
96
- end
97
- end
98
-
99
- test 'remember last request with parameters in the same path' do
100
- get '/?p1=p1'
101
- assert_equal(
102
- [
103
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
104
- ],
105
- session[:referers]
106
- )
107
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
108
- assert_select 'a', 1
109
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
110
- else
111
- assert_select 'a', count: 1
112
- assert_select 'a[href="/?p1=p1"]', 'Home'
113
- end
114
-
115
- get '/static?p2=p2'
116
- assert_equal(
117
- [
118
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
119
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' }
120
- ],
121
- session[:referers]
122
- )
123
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
124
- assert_select 'a', 2
125
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
126
- assert_select 'a[href="/static?p2=p2"]:contains("Static")'
127
- else
128
- assert_select 'a', count: 2
129
- assert_select 'a[href="/?p1=p1"]', 'Home'
130
- assert_select 'a[href="/static?p2=p2"]', 'Static'
131
- end
132
-
133
- get '/static/nested?p3=p3'
134
- assert_equal(
135
- [
136
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
137
- { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' },
138
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
139
- ],
140
- session[:referers]
141
- )
142
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
143
- assert_select 'a', 3
144
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
145
- assert_select 'a[href="/static?p2=p2"]:contains("Static")'
146
- assert_select 'a[href="/static/nested?p3=p3"]:contains("Nested")'
147
- else
148
- assert_select 'a', count: 3
149
- assert_select 'a[href="/?p1=p1"]', 'Home'
150
- assert_select 'a[href="/static?p2=p2"]', 'Static'
151
- assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
152
- end
153
-
154
- get '/'
155
- assert_equal(
156
- [
157
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
158
- ],
159
- session[:referers]
160
- )
161
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
162
- assert_select 'a', 1
163
- assert_select 'a[href="/"]:contains("Home")'
164
- else
165
- assert_select 'a', count: 1
166
- assert_select 'a[href="/"]', 'Home'
167
- end
168
- end
169
-
170
- test 'gaps not cause any error and generate crumbs either' do
171
- get '/?p1=p1'
172
- assert_equal(
173
- [
174
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
175
- ],
176
- session[:referers]
177
- )
178
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
179
- assert_select 'a', 1
180
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
181
- else
182
- assert_select 'a', count: 1
183
- assert_select 'a[href="/?p1=p1"]', 'Home'
184
- end
185
-
186
- get '/static/nested?p3=p3'
187
- assert_equal(
188
- [
189
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
190
- { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
191
- ],
192
- session[:referers]
193
- )
194
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
195
- assert_select 'a', 3
196
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
197
- assert_select 'a[href="/static"]:contains("Static")'
198
- assert_select 'a[href="/static/nested?p3=p3"]:contains("Nested")'
199
- else
200
- assert_select 'a', count: 3
201
- assert_select 'a[href="/?p1=p1"]', 'Home'
202
- assert_select 'a[href="/static"]', 'Static'
203
- assert_select 'a[href="/static/nested?p3=p3"]', 'Nested'
204
- end
205
-
206
- get '/'
207
- assert_equal(
208
- [
209
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
210
- ],
211
- session[:referers]
212
- )
213
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
214
- assert_select 'a', 1
215
- assert_select 'a[href="/"]:contains("Home")'
216
- else
217
- assert_select 'a', count: 1
218
- assert_select 'a[href="/"]', 'Home'
219
- end
220
- end
221
-
222
- test 'empty crumbs not cause any error and not generate crumbs' do
223
- get '/?p1=p1'
224
- assert_equal(
225
- [
226
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
227
- ],
228
- session[:referers]
229
- )
230
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
231
- assert_select 'a', 1
232
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
233
- else
234
- assert_select 'a', count: 1
235
- assert_select 'a[href="/?p1=p1"]', 'Home'
236
- end
237
-
238
- get '/empty?p2=p2'
239
- assert_equal(
240
- [
241
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
242
- { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' }
243
- ],
244
- session[:referers]
245
- )
246
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
247
- assert_select 'a', 1
248
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
249
- else
250
- assert_select 'a', count: 1
251
- assert_select 'a[href="/?p1=p1"]', 'Home'
252
- end
253
-
254
- get '/empty/nested?p3=p3'
255
- assert_equal(
256
- [
257
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
258
- { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' },
259
- { base_url: 'http://www.example.com', path: '/empty/nested', fullpath: '/empty/nested?p3=p3' }
260
- ],
261
- session[:referers]
262
- )
263
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
264
- assert_select 'a', 2
265
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
266
- assert_select 'a[href="/empty/nested?p3=p3"]:contains("Nested")'
267
- else
268
- assert_select 'a', count: 2
269
- assert_select 'a[href="/?p1=p1"]', 'Home'
270
- assert_select 'a[href="/empty/nested?p3=p3"]', 'Nested'
271
- end
272
-
273
- get '/'
274
- assert_equal(
275
- [
276
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
277
- ],
278
- session[:referers]
279
- )
280
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
281
- assert_select 'a', 1
282
- assert_select 'a[href="/"]:contains("Home")'
283
- else
284
- assert_select 'a', count: 1
285
- assert_select 'a[href="/"]', 'Home'
286
- end
287
- end
288
-
289
- test 'params not cause any error and can be use alter crumb name' do
290
- get '/?p1=p1'
291
- assert_equal(
292
- [
293
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
294
- ],
295
- session[:referers]
296
- )
297
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
298
- assert_select 'a', 1
299
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
300
- else
301
- assert_select 'a', count: 1
302
- assert_select 'a[href="/?p1=p1"]', 'Home'
303
- end
304
-
305
- get '/param?p2=p2'
306
- assert_equal(
307
- [
308
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
309
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
310
- ],
311
- session[:referers]
312
- )
313
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
314
- assert_select 'a', 2
315
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
316
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
317
- else
318
- assert_select 'a', count: 2
319
- assert_select 'a[href="/?p1=p1"]', 'Home'
320
- assert_select 'a[href="/param?p2=p2"]', 'Param'
321
- end
322
-
323
- get '/param/1?p3=p3'
324
- assert_equal(
325
- [
326
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
327
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
328
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
329
- ],
330
- session[:referers]
331
- )
332
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
333
- assert_select 'a', 3
334
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
335
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
336
- assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
337
- else
338
- assert_select 'a', count: 3
339
- assert_select 'a[href="/?p1=p1"]', 'Home'
340
- assert_select 'a[href="/param?p2=p2"]', 'Param'
341
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
342
- end
343
-
344
- get '/param/1/nested?p4=p4'
345
- assert_equal(
346
- [
347
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
348
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
349
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
350
- { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
351
- ],
352
- session[:referers]
353
- )
354
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
355
- assert_select 'a', 4
356
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
357
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
358
- assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
359
- assert_select 'a[href="/param/1/nested?p4=p4"]:contains("Nested")'
360
- else
361
- assert_select 'a', count: 4
362
- assert_select 'a[href="/?p1=p1"]', 'Home'
363
- assert_select 'a[href="/param?p2=p2"]', 'Param'
364
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
365
- assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
366
- end
367
-
368
- get '/'
369
- assert_equal(
370
- [
371
- { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
372
- ],
373
- session[:referers]
374
- )
375
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
376
- assert_select 'a', 1
377
- assert_select 'a[href="/"]:contains("Home")'
378
- else
379
- assert_select 'a', count: 1
380
- assert_select 'a[href="/"]', 'Home'
381
- end
382
- end
383
-
384
- test 'going back not cause any error and retain history' do
385
- get '/?p1=p1'
386
- assert_equal(
387
- [
388
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
389
- ],
390
- session[:referers]
391
- )
392
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
393
- assert_select 'a', 1
394
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
395
- else
396
- assert_select 'a', count: 1
397
- assert_select 'a[href="/?p1=p1"]', 'Home'
398
- end
399
-
400
- get '/param?p2=p2'
401
- assert_equal(
402
- [
403
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
404
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
405
- ],
406
- session[:referers]
407
- )
408
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
409
- assert_select 'a', 2
410
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
411
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
412
- else
413
- assert_select 'a', count: 2
414
- assert_select 'a[href="/?p1=p1"]', 'Home'
415
- assert_select 'a[href="/param?p2=p2"]', 'Param'
416
- end
417
-
418
- get '/param/1?p3=p3'
419
- assert_equal(
420
- [
421
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
422
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
423
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
424
- ],
425
- session[:referers]
426
- )
427
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
428
- assert_select 'a', 3
429
- assert_select 'a[href="/?p1=p1"]:contains("Hom")'
430
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
431
- assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
432
- else
433
- assert_select 'a', count: 3
434
- assert_select 'a[href="/?p1=p1"]', 'Home'
435
- assert_select 'a[href="/param?p2=p2"]', 'Param'
436
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
437
- end
438
-
439
- get '/param/1/nested?p4=p4'
440
- assert_equal(
441
- [
442
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
443
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
444
- { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
445
- { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
446
- ],
447
- session[:referers]
448
- )
449
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
450
- assert_select 'a', 4
451
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
452
- assert_select 'a[href="/param?p2=p2"]:contains("Param")'
453
- assert_select 'a[href="/param/1?p3=p3"]:contains("Param1")'
454
- assert_select 'a[href="/param/1/nested?p4=p4"]:contains("Nested")'
455
- else
456
- assert_select 'a', count: 4
457
- assert_select 'a[href="/?p1=p1"]', 'Home'
458
- assert_select 'a[href="/param?p2=p2"]', 'Param'
459
- assert_select 'a[href="/param/1?p3=p3"]', 'Param1'
460
- assert_select 'a[href="/param/1/nested?p4=p4"]', 'Nested'
461
- end
462
-
463
- get '/param'
464
- assert_equal(
465
- [
466
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
467
- { base_url: 'http://www.example.com', path: '/param', fullpath: '/param' }
468
- ],
469
- session[:referers]
470
- )
471
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
472
- assert_select 'a', 2
473
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
474
- assert_select 'a[href="/param"]:contains("Param")'
475
- else
476
- assert_select 'a', count: 2
477
- assert_select 'a[href="/?p1=p1"]', 'Home'
478
- assert_select 'a[href="/param"]', 'Param'
479
- end
480
- end
481
-
482
- test 'translations not cause any error' do
483
- get '/?p1=p1'
484
- assert_equal(
485
- [
486
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
487
- ],
488
- session[:referers]
489
- )
490
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
491
- assert_select 'a', 1
492
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
493
- else
494
- assert_select 'a', count: 1
495
- assert_select 'a[href="/?p1=p1"]', 'Home'
496
- end
497
-
498
- get '/i18n?p2=p2'
499
- assert_equal(
500
- [
501
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
502
- { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' }
503
- ],
504
- session[:referers]
505
- )
506
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
507
- assert_select 'a', 2
508
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
509
- assert_select 'a[href="/i18n?p2=p2"]:contains("Hello world")'
510
- else
511
- assert_select 'a', count: 2
512
- assert_select 'a[href="/?p1=p1"]', 'Home'
513
- assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
514
- end
515
-
516
- get '/i18n/nested?p3=p3'
517
- assert_equal(
518
- [
519
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
520
- { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' },
521
- { base_url: 'http://www.example.com', path: '/i18n/nested', fullpath: '/i18n/nested?p3=p3' }
522
- ],
523
- session[:referers]
524
- )
525
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
526
- assert_select 'a', 3
527
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
528
- assert_select 'a[href="/i18n?p2=p2"]:contains("Hello world")'
529
- assert_select 'a[href="/i18n/nested?p3=p3"]:contains("Nested")'
530
- else
531
- assert_select 'a', count: 3
532
- assert_select 'a[href="/?p1=p1"]', 'Home'
533
- assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
534
- assert_select 'a[href="/i18n/nested?p3=p3"]', 'Nested'
535
- end
536
-
537
- get '/?p1=p1'
538
- assert_equal(
539
- [
540
- { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
541
- ],
542
- session[:referers]
543
- )
544
- if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
545
- assert_select 'a', 1
546
- assert_select 'a[href="/?p1=p1"]:contains("Home")'
547
- else
548
- assert_select 'a', count: 1
549
- assert_select 'a[href="/?p1=p1"]', 'Home'
550
- end
551
- end
552
-
553
- end