force_format 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +31 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -3
  6. data/README.md +69 -24
  7. data/Rakefile +4 -0
  8. data/force_format.gemspec +2 -1
  9. data/gemfiles/3.2.gemfile +8 -0
  10. data/gemfiles/3.2.gemfile.lock +128 -0
  11. data/gemfiles/4.0.gemfile +8 -0
  12. data/gemfiles/4.0.gemfile.lock +123 -0
  13. data/lib/force_format/{controller_access.rb → controller.rb} +4 -3
  14. data/lib/force_format/errors.rb +4 -1
  15. data/lib/force_format/railtie.rb +4 -4
  16. data/lib/force_format/version.rb +1 -1
  17. data/lib/force_format/{view_patch.rb → view.rb} +1 -1
  18. data/spec/array_options_spec.rb +109 -0
  19. data/spec/{dummy → dummy3.2}/README.rdoc +0 -0
  20. data/spec/{dummy → dummy3.2}/Rakefile +0 -0
  21. data/spec/{dummy → dummy3.2}/app/assets/javascripts/application.js +0 -0
  22. data/spec/{dummy → dummy3.2}/app/assets/stylesheets/application.css +0 -0
  23. data/spec/{dummy → dummy3.2}/app/controllers/application_controller.rb +0 -0
  24. data/spec/{dummy → dummy3.2}/app/controllers/pages_controller.rb +0 -0
  25. data/spec/{dummy → dummy3.2}/app/helpers/application_helper.rb +0 -0
  26. data/spec/{dummy → dummy3.2}/app/mailers/.gitkeep +0 -0
  27. data/spec/{dummy → dummy3.2}/app/models/.gitkeep +0 -0
  28. data/spec/{dummy → dummy3.2}/app/views/layouts/application.html.erb +0 -0
  29. data/spec/{dummy → dummy3.2}/app/views/pages/index.html.erb +0 -0
  30. data/spec/{dummy → dummy3.2}/app/views/pages/with_html.html.erb +0 -0
  31. data/spec/{dummy → dummy3.2}/app/views/pages/with_html_js.html.erb +0 -0
  32. data/spec/{dummy → dummy3.2}/app/views/pages/with_html_js.js.erb +0 -0
  33. data/spec/{dummy → dummy3.2}/app/views/pages/with_js.js.erb +0 -0
  34. data/spec/{dummy → dummy3.2}/app/views/pages/with_json.json.erb +0 -0
  35. data/spec/{dummy → dummy3.2}/app/views/pages/with_xml.xml.erb +0 -0
  36. data/spec/{dummy → dummy3.2}/config/application.rb +0 -0
  37. data/spec/{dummy → dummy3.2}/config/boot.rb +0 -0
  38. data/spec/{dummy → dummy3.2}/config/database.yml +0 -0
  39. data/spec/{dummy → dummy3.2}/config/environment.rb +0 -0
  40. data/spec/{dummy → dummy3.2}/config/environments/development.rb +0 -0
  41. data/spec/{dummy → dummy3.2}/config/environments/production.rb +0 -0
  42. data/spec/{dummy → dummy3.2}/config/environments/test.rb +0 -0
  43. data/spec/{dummy → dummy3.2}/config/initializers/backtrace_silencers.rb +0 -0
  44. data/spec/{dummy → dummy3.2}/config/initializers/inflections.rb +0 -0
  45. data/spec/{dummy → dummy3.2}/config/initializers/mime_types.rb +0 -0
  46. data/spec/{dummy → dummy3.2}/config/initializers/secret_token.rb +0 -0
  47. data/spec/{dummy → dummy3.2}/config/initializers/session_store.rb +0 -0
  48. data/spec/{dummy → dummy3.2}/config/initializers/wrap_parameters.rb +0 -0
  49. data/spec/{dummy → dummy3.2}/config/locales/en.yml +0 -0
  50. data/spec/{dummy → dummy3.2}/config/routes.rb +0 -0
  51. data/spec/{dummy → dummy3.2}/config.ru +0 -0
  52. data/spec/{dummy/lib/assets/.gitkeep → dummy3.2/db/test.sqlite3} +0 -0
  53. data/spec/{dummy/log → dummy3.2/lib/assets}/.gitkeep +0 -0
  54. data/spec/{dummy/public/favicon.ico → dummy3.2/log/.gitkeep} +0 -0
  55. data/spec/{dummy → dummy3.2}/public/404.html +0 -0
  56. data/spec/{dummy → dummy3.2}/public/422.html +0 -0
  57. data/spec/{dummy → dummy3.2}/public/500.html +0 -0
  58. data/spec/dummy3.2/public/favicon.ico +0 -0
  59. data/spec/{dummy → dummy3.2}/script/rails +0 -0
  60. data/spec/dummy4.0/README.rdoc +28 -0
  61. data/spec/dummy4.0/Rakefile +6 -0
  62. data/spec/dummy4.0/app/assets/images/.keep +0 -0
  63. data/spec/dummy4.0/app/assets/javascripts/application.js +13 -0
  64. data/spec/dummy4.0/app/assets/stylesheets/application.css +13 -0
  65. data/spec/dummy4.0/app/controllers/application_controller.rb +5 -0
  66. data/spec/dummy4.0/app/controllers/concerns/.keep +0 -0
  67. data/spec/dummy4.0/app/controllers/pages_controller.rb +4 -0
  68. data/spec/dummy4.0/app/helpers/application_helper.rb +2 -0
  69. data/spec/dummy4.0/app/mailers/.keep +0 -0
  70. data/spec/dummy4.0/app/models/.keep +0 -0
  71. data/spec/dummy4.0/app/models/concerns/.keep +0 -0
  72. data/spec/dummy4.0/app/views/layouts/application.html.erb +14 -0
  73. data/spec/dummy4.0/app/views/pages/index.html.erb +0 -0
  74. data/spec/dummy4.0/app/views/pages/with_html.html.erb +0 -0
  75. data/spec/dummy4.0/app/views/pages/with_html_js.html.erb +0 -0
  76. data/spec/dummy4.0/app/views/pages/with_html_js.js.erb +0 -0
  77. data/spec/dummy4.0/app/views/pages/with_js.js.erb +0 -0
  78. data/spec/dummy4.0/app/views/pages/with_json.json.erb +0 -0
  79. data/spec/dummy4.0/app/views/pages/with_xml.xml.erb +0 -0
  80. data/spec/dummy4.0/bin/bundle +3 -0
  81. data/spec/dummy4.0/bin/rails +4 -0
  82. data/spec/dummy4.0/bin/rake +4 -0
  83. data/spec/dummy4.0/config/application.rb +28 -0
  84. data/spec/dummy4.0/config/boot.rb +5 -0
  85. data/spec/dummy4.0/config/database.yml +25 -0
  86. data/spec/dummy4.0/config/environment.rb +5 -0
  87. data/spec/dummy4.0/config/environments/development.rb +29 -0
  88. data/spec/dummy4.0/config/environments/production.rb +80 -0
  89. data/spec/dummy4.0/config/environments/test.rb +36 -0
  90. data/spec/dummy4.0/config/initializers/backtrace_silencers.rb +7 -0
  91. data/spec/dummy4.0/config/initializers/filter_parameter_logging.rb +4 -0
  92. data/spec/dummy4.0/config/initializers/inflections.rb +16 -0
  93. data/spec/dummy4.0/config/initializers/mime_types.rb +5 -0
  94. data/spec/dummy4.0/config/initializers/secret_token.rb +12 -0
  95. data/spec/dummy4.0/config/initializers/session_store.rb +3 -0
  96. data/spec/dummy4.0/config/initializers/wrap_parameters.rb +14 -0
  97. data/spec/dummy4.0/config/locales/en.yml +23 -0
  98. data/spec/dummy4.0/config/routes.rb +4 -0
  99. data/spec/dummy4.0/config.ru +4 -0
  100. data/spec/dummy4.0/db/test.sqlite3 +0 -0
  101. data/spec/dummy4.0/lib/assets/.keep +0 -0
  102. data/spec/dummy4.0/log/.keep +0 -0
  103. data/spec/dummy4.0/public/404.html +58 -0
  104. data/spec/dummy4.0/public/422.html +58 -0
  105. data/spec/dummy4.0/public/500.html +57 -0
  106. data/spec/dummy4.0/public/favicon.ico +0 -0
  107. data/spec/exception_spec.rb +36 -0
  108. data/spec/hash_options_spec.rb +105 -0
  109. data/spec/rails_behaviour_spec.rb +35 -0
  110. data/spec/skip_filter_spec.rb +99 -0
  111. data/spec/spec_helper.rb +3 -1
  112. data/spec/wildcard_spec.rb +41 -0
  113. data/spec/without_options_spec.rb +73 -0
  114. metadata +216 -88
  115. data/spec/base_spec.rb +0 -429
data/spec/base_spec.rb DELETED
@@ -1,429 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PagesController, :type => :controller do
4
-
5
- context "force_format_filter is not used" do
6
-
7
- controller do
8
- def index
9
- end
10
- end
11
-
12
- it "should respond with 200 for html" do
13
- get "index"
14
- response.code.should eq("200")
15
- end
16
-
17
- it "should respond with 200 for html" do
18
- get "index", :format => :html
19
- response.code.should eq("200")
20
- end
21
-
22
- it "should respond with MissingTemplate for js" do
23
- expect { get "index", :format => :js }.to raise_error(ActionView::MissingTemplate)
24
- end
25
-
26
- it "should respond with MissingTemplate for xml" do
27
- expect { get "index", :format => :xml }.to raise_error(ActionView::MissingTemplate)
28
- end
29
-
30
- it "should respond with MissingTemplate for json" do
31
- expect { get "index", :format => :json }.to raise_error(ActionView::MissingTemplate)
32
- end
33
-
34
- end
35
-
36
-
37
- context "force_format_filter is used with [:html] for all actions" do
38
-
39
- controller do
40
- send "force_format_filter", :for => [:html]
41
-
42
- def index
43
- render "with_html"
44
- end
45
- end
46
-
47
- it "should respond with 200 for html" do
48
- get "index"
49
- response.code.should eq("200")
50
- end
51
-
52
- it "should respond with 200 for html" do
53
- get "index", :format => :html
54
- response.code.should eq("200")
55
- end
56
-
57
- it "should respond with RoutingError for js" do
58
- expect { get "index", :format => :js }.to raise_error(ActionController::RoutingError)
59
- end
60
-
61
- it "should respond with RoutingError for xml" do
62
- expect { get "index", :format => :xml }.to raise_error(ActionController::RoutingError)
63
- end
64
-
65
- it "should respond with RoutingError for json" do
66
- expect { get "index", :format => :json }.to raise_error(ActionController::RoutingError)
67
- end
68
-
69
- end
70
-
71
- context "force_format_filter is used with [:html, :js] for all actions" do
72
-
73
- controller do
74
- send "force_format_filter", :for => [:html, :js]
75
-
76
- def index
77
- render "with_html_js"
78
- end
79
- end
80
-
81
- it "should respond with 200 for html" do
82
- get "index"
83
- response.code.should eq("200")
84
- end
85
-
86
- it "should respond with 200 for html" do
87
- get "index", :format => :html
88
- response.code.should eq("200")
89
- end
90
-
91
- it "should respond with 200 for js" do
92
- get "index", :format => :js
93
- response.code.should eq("200")
94
- end
95
-
96
- it "should respond with RoutingError for xml" do
97
- expect { get "index", :format => :xml }.to raise_error(ActionController::RoutingError)
98
- end
99
-
100
- it "should respond with RoutingError for json" do
101
- expect { get "index", :format => :json }.to raise_error(ActionController::RoutingError)
102
- end
103
-
104
- end
105
-
106
-
107
- context "force_format_filter is used with no format specified for all actions" do
108
-
109
- controller do
110
- send "force_format_filter"
111
-
112
- def index
113
- end
114
- end
115
-
116
- it "should respond with 200 for html" do
117
- get "index"
118
- response.code.should eq("200")
119
- end
120
-
121
- it "should respond with 200 for html" do
122
- get "index", :format => :html
123
- response.code.should eq("200")
124
- end
125
-
126
- it "should respond with RoutingError for js" do
127
- expect { get "index", :format => :js }.to raise_error(ActionController::RoutingError)
128
- end
129
-
130
- it "should respond with RoutingError for xml" do
131
- expect { get "index", :format => :xml }.to raise_error(ActionController::RoutingError)
132
- end
133
-
134
- it "should respond with RoutingError for json" do
135
- expect { get "index", :format => :json }.to raise_error(ActionController::RoutingError)
136
- end
137
-
138
- end
139
-
140
-
141
- context "force_format_filter is used with skip_format_filter specified for all actions" do
142
-
143
- controller do
144
- send "force_format_filter"
145
- send "skip_force_format_filter"
146
-
147
- def index
148
- end
149
- end
150
-
151
- it "should respond with 200 for html" do
152
- get "index"
153
- response.code.should eq("200")
154
- end
155
-
156
- it "should respond with 200 for html" do
157
- get "index", :format => :html
158
- response.code.should eq("200")
159
- end
160
-
161
- it "should respond with MissingTemplate for js" do
162
- expect { get "index", :format => :js }.to raise_error(ActionView::MissingTemplate)
163
- end
164
-
165
- it "should respond with MissingTemplate for xml" do
166
- expect { get "index", :format => :xml }.to raise_error(ActionView::MissingTemplate)
167
- end
168
-
169
- it "should respond with MissingTemplate for json" do
170
- expect { get "index", :format => :json }.to raise_error(ActionView::MissingTemplate)
171
- end
172
-
173
- end
174
-
175
-
176
-
177
- context "force_format_filter is used with skip_format_filter specified for all actions" do
178
-
179
- controller do
180
- send "skip_force_format_filter"
181
-
182
- def index
183
- end
184
- end
185
-
186
- it "should respond with 200 for html" do
187
- get "index"
188
- response.code.should eq("200")
189
- end
190
-
191
- it "should respond with 200 for html" do
192
- get "index", :format => :html
193
- response.code.should eq("200")
194
- end
195
-
196
- it "should respond with MissingTemplate for js" do
197
- expect { get "index", :format => :js }.to raise_error(ActionView::MissingTemplate)
198
- end
199
-
200
- it "should respond with MissingTemplate for xml" do
201
- expect { get "index", :format => :xml }.to raise_error(ActionView::MissingTemplate)
202
- end
203
-
204
- it "should respond with MissingTemplate for json" do
205
- expect { get "index", :format => :json }.to raise_error(ActionView::MissingTemplate)
206
- end
207
-
208
- end
209
-
210
-
211
-
212
- context "force_format_filter is used with no format specified for all actions" do
213
-
214
- controller do
215
- send "force_format_filter", :only => :index
216
- send "skip_force_format_filter", :only => :skipped
217
-
218
- def new
219
- render "with_html"
220
- end
221
-
222
- def index
223
- render "with_html"
224
- end
225
- end
226
-
227
- it "should respond with 200 for html" do
228
- get "index"
229
- response.code.should eq("200")
230
- end
231
-
232
- it "should respond with 200 for html" do
233
- get "index", :format => :html
234
- response.code.should eq("200")
235
- end
236
-
237
- it "should respond with RoutingError for js" do
238
- expect { get "index", :format => :js }.to raise_error(ActionController::RoutingError)
239
- end
240
-
241
- it "should respond with RoutingError for xml" do
242
- expect { get "index", :format => :xml }.to raise_error(ActionController::RoutingError)
243
- end
244
-
245
- it "should respond with RoutingError for json" do
246
- expect { get "index", :format => :json }.to raise_error(ActionController::RoutingError)
247
- end
248
-
249
-
250
- it "should respond with 200 for html" do
251
- get "new"
252
- response.code.should eq("200")
253
- end
254
-
255
- it "should respond with 200 for html" do
256
- get "new", :format => :html
257
- response.code.should eq("200")
258
- end
259
-
260
- it "should respond with MissingTemplate for js" do
261
- expect { get "new", :format => :js }.to raise_error(ActionView::MissingTemplate)
262
- end
263
-
264
- it "should respond with MissingTemplate for xml" do
265
- expect { get "new", :format => :xml }.to raise_error(ActionView::MissingTemplate)
266
- end
267
-
268
- it "should respond with MissingTemplate for json" do
269
- expect { get "new", :format => :json }.to raise_error(ActionView::MissingTemplate)
270
- end
271
-
272
- end
273
-
274
-
275
- context "force_format_filter is used with format specified more than once" do
276
-
277
- controller do
278
- send "force_format_filter", :for => {:index => [:js], :new => :json}
279
-
280
- def index
281
- render "with_js"
282
- end
283
-
284
- def new
285
- render "with_json"
286
- end
287
- end
288
-
289
- it "should respond with 200 for js" do
290
- get "index", :format => :js
291
- response.code.should eq("200")
292
- end
293
-
294
- it "should respond with 200 for json" do
295
- get "new", :format => :json
296
- response.code.should eq("200")
297
- end
298
-
299
- it "should respond with RoutingError for html" do
300
- expect { get "index", :format => :html }.to raise_error(ActionController::RoutingError)
301
- end
302
-
303
- it "should respond with RoutingError for html" do
304
- expect { get "new", :format => :html }.to raise_error(ActionController::RoutingError)
305
- end
306
-
307
- end
308
-
309
- context "force_format_filter is used with format specified more than once but used default" do
310
-
311
- controller do
312
- send "force_format_filter", :for => {:index => :js, :default => [:json]}
313
-
314
- def index
315
- render "with_js"
316
- end
317
-
318
- def new
319
- render "with_json"
320
- end
321
- end
322
-
323
- it "should respond with 200 for js" do
324
- get "index", :format => :js
325
- response.code.should eq("200")
326
- end
327
-
328
- it "should respond with 200 for json" do
329
- get "new", :format => :json
330
- response.code.should eq("200")
331
- end
332
-
333
- it "should respond with RoutingError for html" do
334
- expect { get "index", :format => :html }.to raise_error(ActionController::RoutingError)
335
- end
336
-
337
- it "should respond with RoutingError for html" do
338
- expect { get "new", :format => :html }.to raise_error(ActionController::RoutingError)
339
- end
340
-
341
- end
342
-
343
-
344
- context "force_format_filter is used with unsupported format" do
345
-
346
- controller do
347
- send "force_format_filter", :for => {:index => :what}
348
-
349
- def index
350
- render "with_js"
351
- end
352
- end
353
-
354
- it "should respond with UnsupportedFormatsError for html" do
355
- expect { get "index", :format => :html }.to raise_error(UnsupportedFormatsError)
356
- end
357
-
358
- end
359
-
360
- context "force_format_filter is used with unsupported format" do
361
-
362
- controller do
363
- send "force_format_filter", :for => {:index => :what}
364
-
365
- def index
366
- render "with_js"
367
- end
368
- end
369
-
370
- it "should respond with UnsupportedFormatsError for html" do
371
- expect { get "index", :format => :html }.to raise_error(UnsupportedFormatsError)
372
- end
373
-
374
- end
375
-
376
- context "force_format_filter is used with a custom exception" do
377
-
378
- controller do
379
- send "force_format_filter", :for => [:js], :exception => lambda { |o| raise(ActiveRecord::RecordNotFound, o) }
380
-
381
- def index
382
- render "with_js"
383
- end
384
- end
385
-
386
- it "should respond with RecordNotFound for html" do
387
- expect { get "index", :format => :html }.to raise_error(ActiveRecord::RecordNotFound)
388
- end
389
-
390
- end
391
-
392
- context "force_format_filter is used with a wildcard format and rewrite set" do
393
-
394
- controller do
395
- send "force_format_filter", :for => :html, :skip_wildcard => false
396
-
397
- def index
398
- render "with_html"
399
- end
400
- end
401
-
402
- it "should respond with 200 for html" do
403
- request.env["HTTP_ACCEPT"] = '*/*'
404
- get "index"
405
- end
406
-
407
- end
408
-
409
-
410
- context "force_format_filter is used with a wildcard format and rewrite set to false" do
411
-
412
- controller do
413
- send "force_format_filter", :for => :html, :skip_wildcard => true
414
-
415
- def index
416
- render "with_html"
417
- end
418
- end
419
-
420
- it "should respond with RoutingError for html" do
421
- expect do
422
- request.env["HTTP_ACCEPT"] = '*/*'
423
- get "index"
424
- end.to raise_error(ActionController::RoutingError)
425
- end
426
-
427
- end
428
-
429
- end