gin 1.1.2 → 1.2.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/History.rdoc +22 -1
- data/Manifest.txt +7 -0
- data/TODO.rdoc +45 -0
- data/bin/gin +105 -35
- data/lib/gin.rb +7 -1
- data/lib/gin/app.rb +328 -59
- data/lib/gin/asset_manifest.rb +178 -0
- data/lib/gin/asset_pipeline.rb +235 -0
- data/lib/gin/cache.rb +36 -0
- data/lib/gin/config.rb +3 -1
- data/lib/gin/constants.rb +6 -1
- data/lib/gin/controller.rb +180 -17
- data/lib/gin/core_ext/float.rb +10 -0
- data/lib/gin/core_ext/time.rb +41 -0
- data/lib/gin/filterable.rb +5 -5
- data/lib/gin/mountable.rb +100 -0
- data/lib/gin/request.rb +4 -12
- data/lib/gin/response.rb +4 -2
- data/lib/gin/router.rb +110 -37
- data/lib/gin/strict_hash.rb +33 -0
- data/lib/gin/test.rb +8 -4
- data/lib/gin/worker.rb +49 -0
- data/test/mock_app.rb +7 -7
- data/test/test_app.rb +266 -17
- data/test/test_cache.rb +73 -5
- data/test/test_config.rb +4 -4
- data/test/test_controller.rb +158 -32
- data/test/test_filterable.rb +16 -1
- data/test/test_gin.rb +7 -6
- data/test/test_request.rb +6 -1
- data/test/test_response.rb +1 -1
- data/test/test_router.rb +156 -34
- data/test/test_test.rb +51 -45
- metadata +42 -14
- checksums.yaml +0 -7
data/test/test_config.rb
CHANGED
@@ -8,7 +8,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
8
8
|
def setup
|
9
9
|
@error_io = StringIO.new
|
10
10
|
@config = Gin::Config.new "development",
|
11
|
-
dir
|
11
|
+
:dir => CONFIG_DIR, :logger => @error_io, :ttl => 300
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -23,7 +23,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
|
25
25
|
def test_config_unknown_env
|
26
|
-
@config = Gin::Config.new "foo", dir
|
26
|
+
@config = Gin::Config.new "foo", :dir => CONFIG_DIR
|
27
27
|
|
28
28
|
assert_equal "example.com", @config['memcache.host']
|
29
29
|
assert_equal 5, @config['memcache.connections']
|
@@ -47,7 +47,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
47
47
|
assert @config.instance_variable_get("@data").empty?
|
48
48
|
@config.load!
|
49
49
|
assert_equal %w{backend memcache},
|
50
|
-
@config.instance_variable_get("@data").keys
|
50
|
+
@config.instance_variable_get("@data").keys.sort
|
51
51
|
end
|
52
52
|
|
53
53
|
|
@@ -58,7 +58,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
|
60
60
|
def test_invalid_yaml
|
61
|
-
assert_raise
|
61
|
+
assert_raise Gin::Config::SYNTAX_ERROR do
|
62
62
|
YAML.load_file @config.send(:filepath_for, 'invalid')
|
63
63
|
end
|
64
64
|
assert_nil @config.load_config('invalid')
|
data/test/test_controller.rb
CHANGED
@@ -4,6 +4,11 @@ unless defined? EventMachine
|
|
4
4
|
class EventMachine; end
|
5
5
|
end
|
6
6
|
|
7
|
+
module FooNamespace
|
8
|
+
class NamespacedController < Gin::Controller
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
7
12
|
class AppController < Gin::Controller
|
8
13
|
FILTERS_RUN = []
|
9
14
|
|
@@ -25,7 +30,7 @@ end
|
|
25
30
|
|
26
31
|
class TestController < Gin::Controller
|
27
32
|
def show id
|
28
|
-
"SHOW #{id}!"
|
33
|
+
"TEST SHOW #{id}!"
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -106,7 +111,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
106
111
|
MockApp.options[:environment] = 'test'
|
107
112
|
MockApp.options[:asset_host] = nil
|
108
113
|
BarController.instance_variable_set("@layout", nil)
|
109
|
-
@app = MockApp.new logger
|
114
|
+
@app = MockApp.new :logger => StringIO.new
|
110
115
|
@ctrl = BarController.new(@app, rack_env)
|
111
116
|
end
|
112
117
|
|
@@ -121,6 +126,8 @@ class ControllerTest < Test::Unit::TestCase
|
|
121
126
|
'HTTP_HOST' => 'example.com',
|
122
127
|
'rack.input' => '',
|
123
128
|
'gin.path_query_hash' => {'id' => 123},
|
129
|
+
'SERVER_NAME' => 'localhost',
|
130
|
+
'SERVER_PORT' => '80'
|
124
131
|
}
|
125
132
|
end
|
126
133
|
|
@@ -169,7 +176,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
169
176
|
|
170
177
|
|
171
178
|
def test_view_layout_missing
|
172
|
-
str = @ctrl.view :bar, layout
|
179
|
+
str = @ctrl.view :bar, :layout => "missing"
|
173
180
|
assert_equal "Value is BarHelper\n", str
|
174
181
|
assert_equal [File.join(@app.views_dir, "bar.erb")],
|
175
182
|
@ctrl.env[Gin::Constants::GIN_TEMPLATES]
|
@@ -177,7 +184,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
177
184
|
|
178
185
|
|
179
186
|
def test_view_other_layout
|
180
|
-
str = @ctrl.view :bar, layout
|
187
|
+
str = @ctrl.view :bar, :layout => "bar.erb"
|
181
188
|
assert(/Bar Layout/ === str)
|
182
189
|
assert(/BarHelper/ === str)
|
183
190
|
assert_equal File.join(@app.layouts_dir, "bar.erb"),
|
@@ -188,7 +195,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
188
195
|
|
189
196
|
|
190
197
|
def test_view_no_layout
|
191
|
-
str = @ctrl.view :bar, layout
|
198
|
+
str = @ctrl.view :bar, :layout => false
|
192
199
|
assert_equal "Value is BarHelper\n", str
|
193
200
|
assert_equal [File.join(@app.views_dir, "bar.erb")],
|
194
201
|
@ctrl.env[Gin::Constants::GIN_TEMPLATES]
|
@@ -201,7 +208,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
201
208
|
|
202
209
|
|
203
210
|
def test_view_locals
|
204
|
-
str = @ctrl.view :bar, locals
|
211
|
+
str = @ctrl.view :bar, :locals => {:test_val => "LOCAL"}
|
205
212
|
assert(/Foo Layout/ === str)
|
206
213
|
assert(str !~ /BarHelper/)
|
207
214
|
assert(/Value is LOCAL/ === str)
|
@@ -214,7 +221,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
214
221
|
|
215
222
|
def test_view_scope
|
216
223
|
scope = Struct.new(:test_val).new("SCOPED")
|
217
|
-
str = @ctrl.view :bar, scope
|
224
|
+
str = @ctrl.view :bar, :scope => scope
|
218
225
|
assert(/Foo Layout/ === str)
|
219
226
|
assert(str !~ /BarHelper/)
|
220
227
|
assert(/Value is SCOPED/ === str)
|
@@ -226,7 +233,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
226
233
|
|
227
234
|
|
228
235
|
def test_view_engine
|
229
|
-
str = @ctrl.view :bar, engine
|
236
|
+
str = @ctrl.view :bar, :engine => MockTemplateEngine
|
230
237
|
assert(/Foo Layout/ === str)
|
231
238
|
assert(str !~ /BarHelper/)
|
232
239
|
assert(/mock render/ === str)
|
@@ -238,7 +245,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
238
245
|
|
239
246
|
|
240
247
|
def test_view_layout_engine
|
241
|
-
str = @ctrl.view :bar, layout_engine
|
248
|
+
str = @ctrl.view :bar, :layout_engine => MockTemplateEngine
|
242
249
|
assert_equal "mock render", str
|
243
250
|
end
|
244
251
|
|
@@ -246,7 +253,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
246
253
|
def test_view_content_type
|
247
254
|
@ctrl.content_type "text/html"
|
248
255
|
MockTemplateEngine.default_mime_type = "application/json"
|
249
|
-
@ctrl.view :bar, engine
|
256
|
+
@ctrl.view :bar, :engine => MockTemplateEngine, :content_type => "application/xml"
|
250
257
|
assert_equal "application/xml;charset=UTF-8",
|
251
258
|
@ctrl.response[Gin::Constants::CNT_TYPE]
|
252
259
|
end
|
@@ -255,7 +262,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
255
262
|
def test_view_template_content_type
|
256
263
|
@ctrl.response[Gin::Constants::CNT_TYPE] = nil
|
257
264
|
MockTemplateEngine.default_mime_type = "application/json"
|
258
|
-
@ctrl.view :bar, engine
|
265
|
+
@ctrl.view :bar, :engine => MockTemplateEngine
|
259
266
|
assert_equal "application/json;charset=UTF-8",
|
260
267
|
@ctrl.response[Gin::Constants::CNT_TYPE]
|
261
268
|
end
|
@@ -264,7 +271,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
264
271
|
def test_view_default_content_type
|
265
272
|
@ctrl.content_type "text/html"
|
266
273
|
MockTemplateEngine.default_mime_type = "application/json"
|
267
|
-
@ctrl.view :bar, engine
|
274
|
+
@ctrl.view :bar, :engine => MockTemplateEngine
|
268
275
|
assert_equal "text/html;charset=UTF-8",
|
269
276
|
@ctrl.response[Gin::Constants::CNT_TYPE]
|
270
277
|
end
|
@@ -279,7 +286,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
279
286
|
@ctrl.etag("my-etag")
|
280
287
|
assert_equal "my-etag".inspect, @ctrl.response['ETag']
|
281
288
|
|
282
|
-
@ctrl.etag("my-etag", kind
|
289
|
+
@ctrl.etag("my-etag", :kind => :strong)
|
283
290
|
assert_equal "my-etag".inspect, @ctrl.response['ETag']
|
284
291
|
|
285
292
|
@ctrl.etag("my-etag", :strong)
|
@@ -288,7 +295,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
288
295
|
|
289
296
|
|
290
297
|
def test_etag_weak
|
291
|
-
@ctrl.etag("my-etag", kind
|
298
|
+
@ctrl.etag("my-etag", :kind => :weak)
|
292
299
|
assert_equal 'W/"my-etag"', @ctrl.response['ETag']
|
293
300
|
|
294
301
|
@ctrl.etag("my-etag", :weak)
|
@@ -308,7 +315,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
308
315
|
assert_equal "my-etag".inspect, @ctrl.response['ETag']
|
309
316
|
|
310
317
|
rack_env['HTTP_IF_MATCH'] = '*'
|
311
|
-
resp = catch(:halt){ @ctrl.etag "my-etag", new_resource
|
318
|
+
resp = catch(:halt){ @ctrl.etag "my-etag", :new_resource => true }
|
312
319
|
assert_equal 412, resp
|
313
320
|
assert_equal "my-etag".inspect, @ctrl.response['ETag']
|
314
321
|
|
@@ -340,7 +347,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
340
347
|
|
341
348
|
rack_env['REQUEST_METHOD'] = 'POST'
|
342
349
|
rack_env['HTTP_IF_NONE_MATCH'] = '*'
|
343
|
-
resp = catch(:halt){ @ctrl.etag "my-etag", new_resource
|
350
|
+
resp = catch(:halt){ @ctrl.etag "my-etag", :new_resource => false }
|
344
351
|
assert_equal 412, resp
|
345
352
|
assert_equal "my-etag".inspect, @ctrl.response['ETag']
|
346
353
|
end
|
@@ -369,11 +376,11 @@ class ControllerTest < Test::Unit::TestCase
|
|
369
376
|
|
370
377
|
|
371
378
|
def test_cache_control
|
372
|
-
@ctrl.cache_control :public, :must_revalidate, max_age
|
379
|
+
@ctrl.cache_control :public, :must_revalidate, :max_age => 60
|
373
380
|
assert_equal "public, must-revalidate, max-age=60",
|
374
381
|
@ctrl.response['Cache-Control']
|
375
382
|
|
376
|
-
@ctrl.cache_control public
|
383
|
+
@ctrl.cache_control :public =>true, :must_revalidate =>false, :max_age =>'foo'
|
377
384
|
assert_equal "public, max-age=0", @ctrl.response['Cache-Control']
|
378
385
|
end
|
379
386
|
|
@@ -391,7 +398,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
391
398
|
|
392
399
|
def test_expires_time
|
393
400
|
time = Time.now + 60
|
394
|
-
@ctrl.expires time, :public, must_revalidate
|
401
|
+
@ctrl.expires time, :public, :must_revalidate =>false, :max_age =>20
|
395
402
|
|
396
403
|
assert_equal "public, max-age=20",
|
397
404
|
@ctrl.response['Cache-Control']
|
@@ -403,7 +410,7 @@ class ControllerTest < Test::Unit::TestCase
|
|
403
410
|
def test_expires_str
|
404
411
|
time = Time.now + 60
|
405
412
|
@ctrl.expires time.strftime("%Y/%m/%d %H:%M:%S"),
|
406
|
-
:public, must_revalidate
|
413
|
+
:public, :must_revalidate =>false, :max_age =>20
|
407
414
|
|
408
415
|
assert_equal "public, max-age=20",
|
409
416
|
@ctrl.response['Cache-Control']
|
@@ -592,7 +599,7 @@ if RUBY_VERSION =~ /^2.0/
|
|
592
599
|
|
593
600
|
def test_action_arguments_key_parameters
|
594
601
|
@ctrl = SpecialCtrl.new nil, rack_env.merge('QUERY_STRING'=>'q=pizza&count=20')
|
595
|
-
assert_equal ["pizza", {count
|
602
|
+
assert_equal ["pizza", {:count => 20}], @ctrl.send("action_arguments", "find")
|
596
603
|
end
|
597
604
|
end
|
598
605
|
|
@@ -663,6 +670,114 @@ end
|
|
663
670
|
end
|
664
671
|
|
665
672
|
|
673
|
+
def test_rewrite
|
674
|
+
resp = catch(:halt){ @ctrl.rewrite BarController, :show, :id => 123 }
|
675
|
+
expected = [200,
|
676
|
+
{"Content-Type"=>"text/html;charset=UTF-8",
|
677
|
+
"Content-Length"=>"9", "Host"=>"localhost:80"},
|
678
|
+
["SHOW 123!"]]
|
679
|
+
assert_equal expected, resp
|
680
|
+
end
|
681
|
+
|
682
|
+
|
683
|
+
def test_rewrite_action
|
684
|
+
resp = catch(:halt){ @ctrl.rewrite :show, :id => 123 }
|
685
|
+
expected = [200,
|
686
|
+
{"Content-Type"=>"text/html;charset=UTF-8",
|
687
|
+
"Content-Length"=>"9", "Host"=>"localhost:80"},
|
688
|
+
["SHOW 123!"]]
|
689
|
+
assert_equal expected, resp
|
690
|
+
end
|
691
|
+
|
692
|
+
|
693
|
+
def test_rewrite_named_route
|
694
|
+
resp = catch(:halt){ @ctrl.rewrite :show_bar, :id => 123 }
|
695
|
+
expected = [200,
|
696
|
+
{"Content-Type"=>"text/html;charset=UTF-8",
|
697
|
+
"Content-Length"=>"9", "Host"=>"localhost:80"},
|
698
|
+
["SHOW 123!"]]
|
699
|
+
assert_equal expected, resp
|
700
|
+
end
|
701
|
+
|
702
|
+
|
703
|
+
def test_rewrite_path
|
704
|
+
expected = [200,
|
705
|
+
{"Content-Type"=>"text/html;charset=UTF-8",
|
706
|
+
"Content-Length"=>"9", "Host"=>"localhost:80"},
|
707
|
+
["SHOW 123!"]]
|
708
|
+
|
709
|
+
resp = catch(:halt){ @ctrl.rewrite '/bar/123' }
|
710
|
+
assert_equal expected, resp
|
711
|
+
|
712
|
+
resp = catch(:halt){ @ctrl.rewrite '/bar/:id', :id => 123 }
|
713
|
+
assert_equal expected, resp
|
714
|
+
|
715
|
+
resp = catch(:halt){ @ctrl.rewrite '/bad/path', :id => 123 }
|
716
|
+
assert_equal 404, resp[0]
|
717
|
+
end
|
718
|
+
|
719
|
+
|
720
|
+
def test_rewrite_missing_param
|
721
|
+
assert_raises Gin::Router::PathArgumentError do
|
722
|
+
@ctrl.rewrite :show
|
723
|
+
end
|
724
|
+
end
|
725
|
+
|
726
|
+
|
727
|
+
def test_rewrite_missing_route
|
728
|
+
assert_raises Gin::RouterError do
|
729
|
+
@ctrl.rewrite TestController, :show
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
|
734
|
+
def test_reroute
|
735
|
+
resp = catch(:halt){ @ctrl.reroute BarController, :show, :id => 456 }
|
736
|
+
expected = [200,
|
737
|
+
{"Content-Type"=>"text/html;charset=UTF-8", "Content-Length"=>"9"},
|
738
|
+
["SHOW 456!"]]
|
739
|
+
assert_equal expected, resp
|
740
|
+
end
|
741
|
+
|
742
|
+
|
743
|
+
def test_reroute_action
|
744
|
+
resp = catch(:halt){ @ctrl.reroute :show, :id => 456 }
|
745
|
+
expected = [200,
|
746
|
+
{"Content-Type"=>"text/html;charset=UTF-8", "Content-Length"=>"9"},
|
747
|
+
["SHOW 456!"]]
|
748
|
+
assert_equal expected, resp
|
749
|
+
end
|
750
|
+
|
751
|
+
|
752
|
+
def test_reroute_named_route
|
753
|
+
assert_raises Gin::RouterError do
|
754
|
+
@ctrl.rewrite :unknown_route
|
755
|
+
end
|
756
|
+
|
757
|
+
resp = catch(:halt){ @ctrl.reroute :show_bar }
|
758
|
+
expected = [200,
|
759
|
+
{"Content-Type"=>"text/html;charset=UTF-8", "Content-Length"=>"9"},
|
760
|
+
["SHOW 123!"]]
|
761
|
+
assert_equal expected, resp
|
762
|
+
end
|
763
|
+
|
764
|
+
|
765
|
+
def test_reroute_missing_param
|
766
|
+
@ctrl.params.delete('id')
|
767
|
+
resp = catch(:halt){ @ctrl.reroute :show }
|
768
|
+
assert_equal 400, resp[0]
|
769
|
+
end
|
770
|
+
|
771
|
+
|
772
|
+
def test_reroute_missing_route
|
773
|
+
resp = catch(:halt){ @ctrl.reroute TestController, :show }
|
774
|
+
expected = [200,
|
775
|
+
{"Content-Type"=>"text/html;charset=UTF-8", "Content-Length"=>"14"},
|
776
|
+
["TEST SHOW 123!"]]
|
777
|
+
assert_equal expected, resp
|
778
|
+
end
|
779
|
+
|
780
|
+
|
666
781
|
def test_url_to
|
667
782
|
assert_equal "http://example.com/bar/123",
|
668
783
|
@ctrl.url_to(BarController, :show, :id => 123)
|
@@ -677,11 +792,11 @@ end
|
|
677
792
|
|
678
793
|
|
679
794
|
def test_path_to
|
680
|
-
assert_equal "/bar/123", @ctrl.path_to(BarController, :show, id
|
681
|
-
assert_equal "/bar/123", @ctrl.path_to(:show, id
|
682
|
-
assert_equal "/bar/delete?id=123", @ctrl.path_to(:rm_bar, id
|
795
|
+
assert_equal "/bar/123", @ctrl.path_to(BarController, :show, :id => 123)
|
796
|
+
assert_equal "/bar/123", @ctrl.path_to(:show, :id => 123)
|
797
|
+
assert_equal "/bar/delete?id=123", @ctrl.path_to(:rm_bar, :id => 123)
|
683
798
|
assert_equal "/bar/delete", @ctrl.path_to(:rm_bar)
|
684
|
-
assert_equal "/test?id=123", @ctrl.path_to("/test", id
|
799
|
+
assert_equal "/test?id=123", @ctrl.path_to("/test", :id => 123)
|
685
800
|
assert_equal "/test", @ctrl.path_to("/test")
|
686
801
|
end
|
687
802
|
|
@@ -785,7 +900,7 @@ end
|
|
785
900
|
assert_equal time.httpdate, @ctrl.response['Last-Modified']
|
786
901
|
|
787
902
|
date = Date.parse time.to_s
|
788
|
-
expected = Time.
|
903
|
+
expected = Time.local(time.year, time.month, time.day)
|
789
904
|
@ctrl.last_modified date
|
790
905
|
assert_equal expected.httpdate, @ctrl.response['Last-Modified']
|
791
906
|
end
|
@@ -850,7 +965,8 @@ end
|
|
850
965
|
rack_env['HTTP_IF_MODIFIED_SINCE'] = Time.parse("10 Feb 3012").httpdate
|
851
966
|
time = Time.now
|
852
967
|
@ctrl.status code
|
853
|
-
@ctrl.last_modified time
|
968
|
+
res = catch(:halt){ @ctrl.last_modified time }
|
969
|
+
assert_equal 304, res if code == 200
|
854
970
|
assert_equal time.httpdate, @ctrl.response['Last-Modified']
|
855
971
|
end
|
856
972
|
end
|
@@ -895,7 +1011,7 @@ end
|
|
895
1011
|
|
896
1012
|
def test_send_file_last_modified
|
897
1013
|
mod_date = Time.now
|
898
|
-
catch(:halt){ @ctrl.send_file "./Manifest.txt", last_modified
|
1014
|
+
catch(:halt){ @ctrl.send_file "./Manifest.txt", :last_modified => mod_date }
|
899
1015
|
assert_equal mod_date.httpdate, @ctrl.headers["Last-Modified"]
|
900
1016
|
assert_nil @ctrl.headers['Content-Disposition']
|
901
1017
|
end
|
@@ -934,10 +1050,11 @@ end
|
|
934
1050
|
|
935
1051
|
def test_content_type_params
|
936
1052
|
assert_equal "application/json;charset=ASCII-8BIT",
|
937
|
-
@ctrl.content_type(".json", charset
|
1053
|
+
@ctrl.content_type(".json", :charset => "ASCII-8BIT")
|
938
1054
|
|
939
|
-
|
940
|
-
|
1055
|
+
ctype, more = @ctrl.content_type(".json", :foo => "bar").split(';')
|
1056
|
+
assert_equal "application/json", ctype
|
1057
|
+
assert_equal %w{charset=UTF-8 foo=bar}, more.split(', ').sort
|
941
1058
|
end
|
942
1059
|
|
943
1060
|
|
@@ -947,7 +1064,7 @@ end
|
|
947
1064
|
end
|
948
1065
|
|
949
1066
|
assert_equal "text/html;charset=UTF-8",
|
950
|
-
@ctrl.content_type('fhwbghd', default
|
1067
|
+
@ctrl.content_type('fhwbghd', :default => 'text/html')
|
951
1068
|
end
|
952
1069
|
|
953
1070
|
|
@@ -994,6 +1111,15 @@ end
|
|
994
1111
|
end
|
995
1112
|
|
996
1113
|
|
1114
|
+
def test_class_controller_name_namespaced
|
1115
|
+
assert_equal 'foo_namespace/namespaced',
|
1116
|
+
FooNamespace::NamespacedController.controller_name
|
1117
|
+
|
1118
|
+
assert_equal :show_namespaced,
|
1119
|
+
FooNamespace::NamespacedController.route_name_for(:show)
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
|
997
1123
|
def test_class_content_type
|
998
1124
|
assert_equal "text/html", AppController.content_type
|
999
1125
|
assert_equal "text/html", BarController.content_type
|
data/test/test_filterable.rb
CHANGED
@@ -47,7 +47,7 @@ class FilterableTest < Test::Unit::TestCase
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def __call_filters__ type, action
|
50
|
+
def __call_filters__ type, action
|
51
51
|
filter(*__send__(:"#{type}_filters_for", action))
|
52
52
|
end
|
53
53
|
end
|
@@ -66,11 +66,18 @@ class FilterableTest < Test::Unit::TestCase
|
|
66
66
|
self.class.is_custom_thing
|
67
67
|
end
|
68
68
|
|
69
|
+
filter :only_foo do
|
70
|
+
FILTER_CALLS << :only_foo
|
71
|
+
"onlyfoo"
|
72
|
+
end
|
73
|
+
|
69
74
|
before_filter :custom_thing
|
70
75
|
|
71
76
|
skip_before_filter :find_device
|
72
77
|
skip_before_filter :logged_in, :only => [:create, :new]
|
73
78
|
skip_after_filter :set_login_cookie, :except => [:logout]
|
79
|
+
|
80
|
+
after_filter :only_foo, :only => :foo
|
74
81
|
end
|
75
82
|
|
76
83
|
|
@@ -99,6 +106,14 @@ class FilterableTest < Test::Unit::TestCase
|
|
99
106
|
end
|
100
107
|
|
101
108
|
|
109
|
+
def test_filter_chain_exceptions
|
110
|
+
assert_equal [:log_action], AppCtrl.after_filters[:foo]
|
111
|
+
assert_equal [:log_action, :only_foo], SessionCtrl.after_filters[:foo]
|
112
|
+
assert_equal [:log_action, :set_login_cookie, :other_filter],
|
113
|
+
SessionCtrl.after_filters[:logout]
|
114
|
+
end
|
115
|
+
|
116
|
+
|
102
117
|
def test_call_filters
|
103
118
|
@app_ctrl.send(:__call_filters__, :before, :action)
|
104
119
|
assert_equal [:logged_in, :find_device], FILTER_CALLS
|