strikeroff-routing-filter 0.0.2 → 0.1.0
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.
- data/MIT-LICENSE +19 -19
- data/Manifest +20 -0
- data/README.markdown +150 -146
- data/Rakefile +21 -0
- data/VERSION +1 -1
- data/lib/routing_filter.rb +94 -94
- data/lib/routing_filter/base.rb +30 -30
- data/lib/routing_filter/force_extension.rb +56 -56
- data/lib/routing_filter/locale.rb +82 -82
- data/lib/routing_filter/pagination.rb +32 -32
- data/routing-filter.gemspec +33 -0
- data/spec/force_extension_spec.rb +65 -65
- data/spec/generation_spec.rb +366 -366
- data/spec/pagination_extension_spec.rb +19 -19
- data/spec/recognition_spec.rb +75 -75
- data/spec/routing_filter_spec.rb +113 -113
- data/spec/spec.opts +4 -4
- data/spec/spec_helper.rb +107 -107
- data/strikeroff-routing-filter.gemspec +33 -0
- metadata +46 -27
- data/.gitignore +0 -2
data/spec/generation_spec.rb
CHANGED
@@ -1,367 +1,367 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'RoutingFilter', 'url generation' do
|
4
|
-
include RoutingFilterHelpers
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
setup_environment :locale, :pagination
|
8
|
-
|
9
|
-
@site = Site.new
|
10
|
-
@section = Section.new
|
11
|
-
@article = Article.new
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "named route url_helpers" do
|
15
|
-
describe "a not nested resource" do
|
16
|
-
it 'does not change the section_path when given page option equals 1' do
|
17
|
-
section_path(:id => 1, :page => 1).should == '/en/sections/1'
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
21
|
-
section_path(:id => 1, :page => 2).should == '/en/sections/1/pages/2'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'prepends the current locale to section_path' do
|
25
|
-
I18n.locale = :de
|
26
|
-
section_path(:id => 1).should == '/de/sections/1'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'prepends a given locale param to section_path' do
|
30
|
-
I18n.locale = :de
|
31
|
-
section_path(:id => 1, :locale => :fi).should == '/fi/sections/1'
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'does not prepend a locale to section_path if given locale is false' do
|
35
|
-
section_path(:id => 1, :locale => false).should == '/sections/1'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'works on section_path with both a locale and page option' do
|
39
|
-
section_path(:id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should not prepend an invalid locale to section_path' do
|
43
|
-
section_path(:id => 1, :locale => :aa).should == '/sections/1'
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should prepend a longer locale to section_path' do
|
47
|
-
section_path(:id => 1, :locale => 'en-US').should == '/en-US/sections/1'
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should not prepend the default locale when configured not to' do
|
51
|
-
RoutingFilter::Locale.include_default_locale = false
|
52
|
-
section_path(:id => 1, :locale => :en).should == '/sections/1'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "a nested resource" do
|
57
|
-
it 'does not change the section_article_path when given page option equals 1' do
|
58
|
-
section_article_path(:section_id => 1, :id => 1, :page => 1).should == '/en/sections/1/articles/1'
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
62
|
-
section_article_path(:section_id => 1, :id => 1, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'prepends the current locale to section_article_path' do
|
66
|
-
I18n.locale = :de
|
67
|
-
section_article_path(:section_id => 1, :id => 1).should == '/de/sections/1/articles/1'
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'prepends a given locale param to section_article_path' do
|
71
|
-
I18n.locale = :de
|
72
|
-
section_article_path(:section_id => 1, :id => 1, :locale => :fi).should == '/fi/sections/1/articles/1'
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'does not prepend a locale to section_article_path if given locale is false' do
|
76
|
-
section_article_path(:section_id => 1, :id => 1, :locale => false).should == '/sections/1/articles/1'
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'works on section_article_path with both a locale and page option' do
|
80
|
-
section_article_path(:section_id => 1, :id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should not prepend an invalid locale to section_article_path' do
|
84
|
-
section_article_path(:section_id => 1, :id => 1, :locale => :aa).should == '/sections/1/articles/1'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should prepend a longer locale to section_article_path' do
|
88
|
-
section_article_path(:section_id => 1, :id => 1, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should not prepend the default locale when configured not to' do
|
92
|
-
RoutingFilter::Locale.include_default_locale = false
|
93
|
-
section_article_path(:section_id => 1, :id => 1, :locale => :en).should == '/sections/1/articles/1'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe 'when used with named route url_helper with "optimized" generation blocks' do
|
99
|
-
describe "a not nested resource" do
|
100
|
-
it 'does not change the section_path when given page option equals 1' do
|
101
|
-
section_path(1, :page => 1).should == '/en/sections/1'
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
105
|
-
section_path(1, :page => 2).should == '/en/sections/1/pages/2'
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'prepends the current locale to section_path' do
|
109
|
-
I18n.locale = :de
|
110
|
-
section_path(1).should == '/de/sections/1'
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'prepends a given locale param to section_path' do
|
114
|
-
I18n.locale = :de
|
115
|
-
section_path(1, :locale => :fi).should == '/fi/sections/1'
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'does not prepend a locale to section_path if given locale is false' do
|
119
|
-
section_path(1, :locale => false).should == '/sections/1'
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'works for section_path with both a locale and page option' do
|
123
|
-
section_path(1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should not prepend an invalid locale to section_path' do
|
127
|
-
section_path(1, :locale => :aa).should == '/sections/1'
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'should prepend a longer locale to section_path' do
|
131
|
-
section_path(1, :locale => 'en-US').should == '/en-US/sections/1'
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should not prepend the default locale when configured not to' do
|
135
|
-
RoutingFilter::Locale.include_default_locale = false
|
136
|
-
section_path(1, :locale => :en).should == '/sections/1'
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "a nested resource" do
|
141
|
-
it 'does not change the section_article_path when given page option equals 1' do
|
142
|
-
section_article_path(1, 1, :page => 1).should == '/en/sections/1/articles/1'
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
146
|
-
section_article_path(1, 1, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'prepends the current locale to section_article_path' do
|
150
|
-
I18n.locale = :de
|
151
|
-
section_article_path(1, 1).should == '/de/sections/1/articles/1'
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'prepends a given locale param to section_article_path' do
|
155
|
-
I18n.locale = :de
|
156
|
-
section_article_path(1, 1, :locale => :fi).should == '/fi/sections/1/articles/1'
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'does not prepend a locale to section_article_path if given locale is false' do
|
160
|
-
section_article_path(1, 1, :locale => false).should == '/sections/1/articles/1'
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'works for section_article_path with both a locale and page option' do
|
164
|
-
section_article_path(1, 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'should not prepend an invalid locale to section_article_path' do
|
168
|
-
section_article_path(1, 1, :locale => :aa).should == '/sections/1/articles/1'
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should prepend a longer locale to section_article_path' do
|
172
|
-
section_article_path(1, 1, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should not prepend the default locale when configured not to' do
|
176
|
-
RoutingFilter::Locale.include_default_locale = false
|
177
|
-
section_article_path(1, 1, :locale => :en).should == '/sections/1/articles/1'
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe 'when used with a polymorphic_path' do
|
183
|
-
describe "a not nested resource" do
|
184
|
-
it 'does not change the section_path when given page option equals 1' do
|
185
|
-
section_path(@section, :page => 1).should == '/en/sections/1'
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
189
|
-
section_path(@section, :page => 2).should == '/en/sections/1/pages/2'
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'prepends the current locale to section_path' do
|
193
|
-
I18n.locale = :de
|
194
|
-
section_path(@section).should == '/de/sections/1'
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'prepends a given locale param to section_path' do
|
198
|
-
I18n.locale = :de
|
199
|
-
section_path(@section, :locale => :fi).should == '/fi/sections/1'
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'does not prepend a locale to section_path if given locale is false' do
|
203
|
-
section_path(@section, :locale => false).should == '/sections/1'
|
204
|
-
end
|
205
|
-
|
206
|
-
it 'works for section_path with both a locale and page option' do
|
207
|
-
section_path(@section, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should not prepend an invalid locale to section_path' do
|
211
|
-
section_path(@section, :locale => :aa).should == '/sections/1'
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'should prepend a longer locale to section_path' do
|
215
|
-
section_path(@section, :locale => 'en-US').should == '/en-US/sections/1'
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'should not prepend the default locale when configured not to' do
|
219
|
-
RoutingFilter::Locale.include_default_locale = false
|
220
|
-
section_path(@section, :locale => :en).should == '/sections/1'
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe "a nested resource" do
|
225
|
-
it 'does not change the section_article_path when given page option equals 1' do
|
226
|
-
section_article_path(@section, @article, :page => 1).should == '/en/sections/1/articles/1'
|
227
|
-
end
|
228
|
-
|
229
|
-
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
230
|
-
section_article_path(@section, @article, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'prepends the current locale to section_article_path' do
|
234
|
-
I18n.locale = :de
|
235
|
-
section_article_path(@section, @article).should == '/de/sections/1/articles/1'
|
236
|
-
end
|
237
|
-
|
238
|
-
it 'prepends a given locale param to section_article_path' do
|
239
|
-
I18n.locale = :de
|
240
|
-
section_article_path(@section, @article, :locale => :fi).should == '/fi/sections/1/articles/1'
|
241
|
-
end
|
242
|
-
|
243
|
-
it 'does not prepend a locale to section_article_path if given locale is false' do
|
244
|
-
section_article_path(@section, @article, :locale => false).should == '/sections/1/articles/1'
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'works for section_article_path with both a locale and page option' do
|
248
|
-
section_article_path(@section, @article, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
249
|
-
end
|
250
|
-
|
251
|
-
it 'should not prepend an invalid locale to section_article_path' do
|
252
|
-
section_article_path(@section, @article, :locale => :aa).should == '/sections/1/articles/1'
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'should prepend a longer locale to section_article_path' do
|
256
|
-
section_article_path(@section, @article, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
257
|
-
end
|
258
|
-
|
259
|
-
it 'should not prepend the default locale when configured not to' do
|
260
|
-
RoutingFilter::Locale.include_default_locale = false
|
261
|
-
section_article_path(@section, @article, :locale => :en).should == '/sections/1/articles/1'
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
describe 'when used with url_for and an ActivRecord instance' do
|
267
|
-
describe "a not nested resource" do
|
268
|
-
it 'does not change the url_for result when given page option equals 1' do
|
269
|
-
params = @section_params.update :id => @section, :page => 1
|
270
|
-
url_for(params).should == 'http://test.host/en/sections/1'
|
271
|
-
end
|
272
|
-
|
273
|
-
it 'appends the pages segments to url_for result when given page option does not equal 1' do
|
274
|
-
params = @section_params.update :id => @section, :page => 2
|
275
|
-
url_for(params).should == 'http://test.host/en/sections/1/pages/2'
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'prepends the current locale to url_for result' do
|
279
|
-
I18n.locale = :de
|
280
|
-
params = @section_params.update :id => @section
|
281
|
-
url_for(params).should == 'http://test.host/de/sections/1'
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'prepends a given locale param url_for result' do
|
285
|
-
I18n.locale = :de
|
286
|
-
params = @section_params.update :id => @section, :locale => :fi
|
287
|
-
url_for(params).should == 'http://test.host/fi/sections/1'
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'does not prepend a locale to url_for result if given locale is false' do
|
291
|
-
params = @section_params.update :id => @section, :locale => false
|
292
|
-
url_for(params).should == 'http://test.host/sections/1'
|
293
|
-
end
|
294
|
-
|
295
|
-
it 'works for url_for result with both a locale and page option' do
|
296
|
-
params = @section_params.update :id => @section, :locale => :fi, :page => 2
|
297
|
-
url_for(params).should == 'http://test.host/fi/sections/1/pages/2'
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'should not prepend an invalid locale to section_path' do
|
301
|
-
params = @section_params.update :id => @section, :locale => :aa
|
302
|
-
url_for(params).should == 'http://test.host/sections/1'
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'should prepend a longer locale to section_path' do
|
306
|
-
params = @section_params.update :id => @section, :locale => 'en-US'
|
307
|
-
url_for(params).should == 'http://test.host/en-US/sections/1'
|
308
|
-
end
|
309
|
-
|
310
|
-
it 'should not prepend the default locale when configured not to' do
|
311
|
-
RoutingFilter::Locale.include_default_locale = false
|
312
|
-
params = @section_params.update :id => @section, :locale => :en
|
313
|
-
url_for(params).should == 'http://test.host/sections/1'
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
describe "a nested resource" do
|
318
|
-
it 'does not change the url_for result when given page option equals 1' do
|
319
|
-
params = @article_params.update :section_id => @section, :id => @article, :page => 1
|
320
|
-
url_for(params).should == 'http://test.host/en/sections/1/articles/1'
|
321
|
-
end
|
322
|
-
|
323
|
-
it 'appends the pages segments to url_for result when given page option does not equal 1' do
|
324
|
-
params = @article_params.update :section_id => @section, :id => @article, :page => 2
|
325
|
-
url_for(params).should == 'http://test.host/en/sections/1/articles/1/pages/2'
|
326
|
-
end
|
327
|
-
|
328
|
-
it 'prepends the current locale to url_for result' do
|
329
|
-
I18n.locale = :de
|
330
|
-
params = @article_params.update :section_id => @section, :id => @article
|
331
|
-
url_for(params).should == 'http://test.host/de/sections/1/articles/1'
|
332
|
-
end
|
333
|
-
|
334
|
-
it 'prepends a given locale param to url_for result' do
|
335
|
-
I18n.locale = :de
|
336
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => :fi
|
337
|
-
url_for(params).should == 'http://test.host/fi/sections/1/articles/1'
|
338
|
-
end
|
339
|
-
|
340
|
-
it 'does not prepend a locale to url_for result if given locale is false' do
|
341
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => false
|
342
|
-
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
343
|
-
end
|
344
|
-
|
345
|
-
it 'works for url_for result with both a locale and page option' do
|
346
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => :fi, :page => 2
|
347
|
-
url_for(params).should == 'http://test.host/fi/sections/1/articles/1/pages/2'
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'should not prepend an invalid locale to url_for result' do
|
351
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => :aa
|
352
|
-
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
353
|
-
end
|
354
|
-
|
355
|
-
it 'should prepend a longer locale to section_article_path' do
|
356
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => 'en-US'
|
357
|
-
url_for(params).should == 'http://test.host/en-US/sections/1/articles/1'
|
358
|
-
end
|
359
|
-
|
360
|
-
it 'should not prepend the default locale when configured not to' do
|
361
|
-
RoutingFilter::Locale.include_default_locale = false
|
362
|
-
params = @article_params.update :section_id => @section, :id => @article, :locale => :en
|
363
|
-
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe 'RoutingFilter', 'url generation' do
|
4
|
+
include RoutingFilterHelpers
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
setup_environment :locale, :pagination
|
8
|
+
|
9
|
+
@site = Site.new
|
10
|
+
@section = Section.new
|
11
|
+
@article = Article.new
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "named route url_helpers" do
|
15
|
+
describe "a not nested resource" do
|
16
|
+
it 'does not change the section_path when given page option equals 1' do
|
17
|
+
section_path(:id => 1, :page => 1).should == '/en/sections/1'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
21
|
+
section_path(:id => 1, :page => 2).should == '/en/sections/1/pages/2'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'prepends the current locale to section_path' do
|
25
|
+
I18n.locale = :de
|
26
|
+
section_path(:id => 1).should == '/de/sections/1'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'prepends a given locale param to section_path' do
|
30
|
+
I18n.locale = :de
|
31
|
+
section_path(:id => 1, :locale => :fi).should == '/fi/sections/1'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not prepend a locale to section_path if given locale is false' do
|
35
|
+
section_path(:id => 1, :locale => false).should == '/sections/1'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'works on section_path with both a locale and page option' do
|
39
|
+
section_path(:id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should not prepend an invalid locale to section_path' do
|
43
|
+
section_path(:id => 1, :locale => :aa).should == '/sections/1'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should prepend a longer locale to section_path' do
|
47
|
+
section_path(:id => 1, :locale => 'en-US').should == '/en-US/sections/1'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should not prepend the default locale when configured not to' do
|
51
|
+
RoutingFilter::Locale.include_default_locale = false
|
52
|
+
section_path(:id => 1, :locale => :en).should == '/sections/1'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "a nested resource" do
|
57
|
+
it 'does not change the section_article_path when given page option equals 1' do
|
58
|
+
section_article_path(:section_id => 1, :id => 1, :page => 1).should == '/en/sections/1/articles/1'
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
62
|
+
section_article_path(:section_id => 1, :id => 1, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'prepends the current locale to section_article_path' do
|
66
|
+
I18n.locale = :de
|
67
|
+
section_article_path(:section_id => 1, :id => 1).should == '/de/sections/1/articles/1'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'prepends a given locale param to section_article_path' do
|
71
|
+
I18n.locale = :de
|
72
|
+
section_article_path(:section_id => 1, :id => 1, :locale => :fi).should == '/fi/sections/1/articles/1'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'does not prepend a locale to section_article_path if given locale is false' do
|
76
|
+
section_article_path(:section_id => 1, :id => 1, :locale => false).should == '/sections/1/articles/1'
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'works on section_article_path with both a locale and page option' do
|
80
|
+
section_article_path(:section_id => 1, :id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should not prepend an invalid locale to section_article_path' do
|
84
|
+
section_article_path(:section_id => 1, :id => 1, :locale => :aa).should == '/sections/1/articles/1'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should prepend a longer locale to section_article_path' do
|
88
|
+
section_article_path(:section_id => 1, :id => 1, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should not prepend the default locale when configured not to' do
|
92
|
+
RoutingFilter::Locale.include_default_locale = false
|
93
|
+
section_article_path(:section_id => 1, :id => 1, :locale => :en).should == '/sections/1/articles/1'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'when used with named route url_helper with "optimized" generation blocks' do
|
99
|
+
describe "a not nested resource" do
|
100
|
+
it 'does not change the section_path when given page option equals 1' do
|
101
|
+
section_path(1, :page => 1).should == '/en/sections/1'
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
105
|
+
section_path(1, :page => 2).should == '/en/sections/1/pages/2'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'prepends the current locale to section_path' do
|
109
|
+
I18n.locale = :de
|
110
|
+
section_path(1).should == '/de/sections/1'
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'prepends a given locale param to section_path' do
|
114
|
+
I18n.locale = :de
|
115
|
+
section_path(1, :locale => :fi).should == '/fi/sections/1'
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'does not prepend a locale to section_path if given locale is false' do
|
119
|
+
section_path(1, :locale => false).should == '/sections/1'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'works for section_path with both a locale and page option' do
|
123
|
+
section_path(1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should not prepend an invalid locale to section_path' do
|
127
|
+
section_path(1, :locale => :aa).should == '/sections/1'
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should prepend a longer locale to section_path' do
|
131
|
+
section_path(1, :locale => 'en-US').should == '/en-US/sections/1'
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should not prepend the default locale when configured not to' do
|
135
|
+
RoutingFilter::Locale.include_default_locale = false
|
136
|
+
section_path(1, :locale => :en).should == '/sections/1'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "a nested resource" do
|
141
|
+
it 'does not change the section_article_path when given page option equals 1' do
|
142
|
+
section_article_path(1, 1, :page => 1).should == '/en/sections/1/articles/1'
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
146
|
+
section_article_path(1, 1, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'prepends the current locale to section_article_path' do
|
150
|
+
I18n.locale = :de
|
151
|
+
section_article_path(1, 1).should == '/de/sections/1/articles/1'
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'prepends a given locale param to section_article_path' do
|
155
|
+
I18n.locale = :de
|
156
|
+
section_article_path(1, 1, :locale => :fi).should == '/fi/sections/1/articles/1'
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'does not prepend a locale to section_article_path if given locale is false' do
|
160
|
+
section_article_path(1, 1, :locale => false).should == '/sections/1/articles/1'
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'works for section_article_path with both a locale and page option' do
|
164
|
+
section_article_path(1, 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should not prepend an invalid locale to section_article_path' do
|
168
|
+
section_article_path(1, 1, :locale => :aa).should == '/sections/1/articles/1'
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should prepend a longer locale to section_article_path' do
|
172
|
+
section_article_path(1, 1, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should not prepend the default locale when configured not to' do
|
176
|
+
RoutingFilter::Locale.include_default_locale = false
|
177
|
+
section_article_path(1, 1, :locale => :en).should == '/sections/1/articles/1'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe 'when used with a polymorphic_path' do
|
183
|
+
describe "a not nested resource" do
|
184
|
+
it 'does not change the section_path when given page option equals 1' do
|
185
|
+
section_path(@section, :page => 1).should == '/en/sections/1'
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'appends the pages segments to section_path when given page option does not equal 1' do
|
189
|
+
section_path(@section, :page => 2).should == '/en/sections/1/pages/2'
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'prepends the current locale to section_path' do
|
193
|
+
I18n.locale = :de
|
194
|
+
section_path(@section).should == '/de/sections/1'
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'prepends a given locale param to section_path' do
|
198
|
+
I18n.locale = :de
|
199
|
+
section_path(@section, :locale => :fi).should == '/fi/sections/1'
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'does not prepend a locale to section_path if given locale is false' do
|
203
|
+
section_path(@section, :locale => false).should == '/sections/1'
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'works for section_path with both a locale and page option' do
|
207
|
+
section_path(@section, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2'
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should not prepend an invalid locale to section_path' do
|
211
|
+
section_path(@section, :locale => :aa).should == '/sections/1'
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should prepend a longer locale to section_path' do
|
215
|
+
section_path(@section, :locale => 'en-US').should == '/en-US/sections/1'
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should not prepend the default locale when configured not to' do
|
219
|
+
RoutingFilter::Locale.include_default_locale = false
|
220
|
+
section_path(@section, :locale => :en).should == '/sections/1'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "a nested resource" do
|
225
|
+
it 'does not change the section_article_path when given page option equals 1' do
|
226
|
+
section_article_path(@section, @article, :page => 1).should == '/en/sections/1/articles/1'
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'appends the pages segments to section_article_path when given page option does not equal 1' do
|
230
|
+
section_article_path(@section, @article, :page => 2).should == '/en/sections/1/articles/1/pages/2'
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'prepends the current locale to section_article_path' do
|
234
|
+
I18n.locale = :de
|
235
|
+
section_article_path(@section, @article).should == '/de/sections/1/articles/1'
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'prepends a given locale param to section_article_path' do
|
239
|
+
I18n.locale = :de
|
240
|
+
section_article_path(@section, @article, :locale => :fi).should == '/fi/sections/1/articles/1'
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'does not prepend a locale to section_article_path if given locale is false' do
|
244
|
+
section_article_path(@section, @article, :locale => false).should == '/sections/1/articles/1'
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'works for section_article_path with both a locale and page option' do
|
248
|
+
section_article_path(@section, @article, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2'
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should not prepend an invalid locale to section_article_path' do
|
252
|
+
section_article_path(@section, @article, :locale => :aa).should == '/sections/1/articles/1'
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should prepend a longer locale to section_article_path' do
|
256
|
+
section_article_path(@section, @article, :locale => 'en-US').should == '/en-US/sections/1/articles/1'
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should not prepend the default locale when configured not to' do
|
260
|
+
RoutingFilter::Locale.include_default_locale = false
|
261
|
+
section_article_path(@section, @article, :locale => :en).should == '/sections/1/articles/1'
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe 'when used with url_for and an ActivRecord instance' do
|
267
|
+
describe "a not nested resource" do
|
268
|
+
it 'does not change the url_for result when given page option equals 1' do
|
269
|
+
params = @section_params.update :id => @section, :page => 1
|
270
|
+
url_for(params).should == 'http://test.host/en/sections/1'
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'appends the pages segments to url_for result when given page option does not equal 1' do
|
274
|
+
params = @section_params.update :id => @section, :page => 2
|
275
|
+
url_for(params).should == 'http://test.host/en/sections/1/pages/2'
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'prepends the current locale to url_for result' do
|
279
|
+
I18n.locale = :de
|
280
|
+
params = @section_params.update :id => @section
|
281
|
+
url_for(params).should == 'http://test.host/de/sections/1'
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'prepends a given locale param url_for result' do
|
285
|
+
I18n.locale = :de
|
286
|
+
params = @section_params.update :id => @section, :locale => :fi
|
287
|
+
url_for(params).should == 'http://test.host/fi/sections/1'
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'does not prepend a locale to url_for result if given locale is false' do
|
291
|
+
params = @section_params.update :id => @section, :locale => false
|
292
|
+
url_for(params).should == 'http://test.host/sections/1'
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'works for url_for result with both a locale and page option' do
|
296
|
+
params = @section_params.update :id => @section, :locale => :fi, :page => 2
|
297
|
+
url_for(params).should == 'http://test.host/fi/sections/1/pages/2'
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'should not prepend an invalid locale to section_path' do
|
301
|
+
params = @section_params.update :id => @section, :locale => :aa
|
302
|
+
url_for(params).should == 'http://test.host/sections/1'
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'should prepend a longer locale to section_path' do
|
306
|
+
params = @section_params.update :id => @section, :locale => 'en-US'
|
307
|
+
url_for(params).should == 'http://test.host/en-US/sections/1'
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'should not prepend the default locale when configured not to' do
|
311
|
+
RoutingFilter::Locale.include_default_locale = false
|
312
|
+
params = @section_params.update :id => @section, :locale => :en
|
313
|
+
url_for(params).should == 'http://test.host/sections/1'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
describe "a nested resource" do
|
318
|
+
it 'does not change the url_for result when given page option equals 1' do
|
319
|
+
params = @article_params.update :section_id => @section, :id => @article, :page => 1
|
320
|
+
url_for(params).should == 'http://test.host/en/sections/1/articles/1'
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'appends the pages segments to url_for result when given page option does not equal 1' do
|
324
|
+
params = @article_params.update :section_id => @section, :id => @article, :page => 2
|
325
|
+
url_for(params).should == 'http://test.host/en/sections/1/articles/1/pages/2'
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'prepends the current locale to url_for result' do
|
329
|
+
I18n.locale = :de
|
330
|
+
params = @article_params.update :section_id => @section, :id => @article
|
331
|
+
url_for(params).should == 'http://test.host/de/sections/1/articles/1'
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'prepends a given locale param to url_for result' do
|
335
|
+
I18n.locale = :de
|
336
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => :fi
|
337
|
+
url_for(params).should == 'http://test.host/fi/sections/1/articles/1'
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'does not prepend a locale to url_for result if given locale is false' do
|
341
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => false
|
342
|
+
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'works for url_for result with both a locale and page option' do
|
346
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => :fi, :page => 2
|
347
|
+
url_for(params).should == 'http://test.host/fi/sections/1/articles/1/pages/2'
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should not prepend an invalid locale to url_for result' do
|
351
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => :aa
|
352
|
+
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'should prepend a longer locale to section_article_path' do
|
356
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => 'en-US'
|
357
|
+
url_for(params).should == 'http://test.host/en-US/sections/1/articles/1'
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'should not prepend the default locale when configured not to' do
|
361
|
+
RoutingFilter::Locale.include_default_locale = false
|
362
|
+
params = @article_params.update :section_id => @section, :id => @article, :locale => :en
|
363
|
+
url_for(params).should == 'http://test.host/sections/1/articles/1'
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
367
|
end
|