aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-05-20 08:21:32 +0200
committerYves Senn <yves.senn@gmail.com>2014-05-20 08:21:32 +0200
commit00d1b132c0194b3a9b495ad43ba0c1198755b548 (patch)
tree07fc536d88101de855f7dcf5451790fa6e7f39a4 /actionpack/test/controller
parentfe06e9ac2358654d2bc875775140807eb5406def (diff)
parentac36b45672513417d59ab8960b49ff1f8707d352 (diff)
downloadrails-00d1b132c0194b3a9b495ad43ba0c1198755b548.tar.gz
rails-00d1b132c0194b3a9b495ad43ba0c1198755b548.tar.bz2
rails-00d1b132c0194b3a9b495ad43ba0c1198755b548.zip
Merge pull request #15178 from zuhao/refactor_actionpack_respond_with_test
Deregister csv renderer after test to prevent leak.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/mime/respond_with_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_with_test.rb b/actionpack/test/controller/mime/respond_with_test.rb
index 416b3b81a5..742225fec5 100644
--- a/actionpack/test/controller/mime/respond_with_test.rb
+++ b/actionpack/test/controller/mime/respond_with_test.rb
@@ -643,6 +643,8 @@ class RespondWithControllerTest < ActionController::TestCase
get :index, format: 'csv'
assert_equal Mime::CSV, @response.content_type
assert_equal "c,s,v", @response.body
+ ensure
+ ActionController::Renderers.remove :csv
end
def test_raises_missing_renderer_if_an_api_behavior_with_no_renderer
@@ -652,6 +654,23 @@ class RespondWithControllerTest < ActionController::TestCase
end
end
+ def test_removing_renderers
+ ActionController::Renderers.add :csv do |obj, options|
+ send_data obj.to_csv, type: Mime::CSV
+ end
+ @controller = CsvRespondWithController.new
+ @request.accept = "text/csv"
+ get :index, format: 'csv'
+ assert_equal Mime::CSV, @response.content_type
+
+ ActionController::Renderers.remove :csv
+ assert_raise ActionController::MissingRenderer do
+ get :index, format: 'csv'
+ end
+ ensure
+ ActionController::Renderers.remove :csv
+ end
+
def test_error_is_raised_if_no_respond_to_is_declared_and_respond_with_is_called
@controller = EmptyRespondWithController.new
@request.accept = "*/*"