diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-06-07 14:39:42 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-06-07 14:39:42 -0400 |
commit | a4154d8efbc4921b48866cac8fd3cf5550ed9e78 (patch) | |
tree | 2b320e24c5c914f7bc53b73f9909ebd3057cd501 /actionpack/test | |
parent | 48033eaa4e7e4c517d81a609ea17bbee81528d4d (diff) | |
parent | e6bb1a1b1f9c47414c588521ae05c02be923976f (diff) | |
download | rails-a4154d8efbc4921b48866cac8fd3cf5550ed9e78.tar.gz rails-a4154d8efbc4921b48866cac8fd3cf5550ed9e78.tar.bz2 rails-a4154d8efbc4921b48866cac8fd3cf5550ed9e78.zip |
Merge pull request #25079 from jeffkreeftmeijer/send_file-halts-request-cycle
Use `#performed?` to terminate controller callbacks
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/send_file_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 2820425c31..9df70dacbf 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -11,6 +11,8 @@ class SendFileController < ActionController::Base include ActionController::Testing layout "layouts/standard" # to make sure layouts don't interfere + before_action :file, only: :file_from_before_action + attr_writer :options def options @options ||= {} @@ -20,6 +22,10 @@ class SendFileController < ActionController::Base send_file(file_path, options) end + def file_from_before_action + raise 'No file sent from before action.' + end + def test_send_file_headers_bang options = { :type => Mime[:png], @@ -192,6 +198,15 @@ class SendFileTest < ActionController::TestCase assert_nil @controller.headers['Content-Disposition'] end + def test_send_file_from_before_action + response = nil + assert_nothing_raised { response = process('file_from_before_action') } + assert_not_nil response + + assert_kind_of String, response.body + assert_equal file_data, response.body + end + %w(file data).each do |method| define_method "test_send_#{method}_status" do @controller.options = { :stream => false, :status => 500 } |