aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/middleware/sendfile_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-06 12:11:38 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-06 12:11:38 +0100
commitc954d54e2f36bb53ced5e3655adc071dd233797e (patch)
treed84bf4bf51f65a1c817089c6fe37c3e9f20420d0 /railties/test/application/middleware/sendfile_test.rb
parentf2b41914d6be935182d37e0c0d491352ac3de043 (diff)
parentd40ca9cce241a8083756c993d6c99a79e62e050e (diff)
downloadrails-c954d54e2f36bb53ced5e3655adc071dd233797e.tar.gz
rails-c954d54e2f36bb53ced5e3655adc071dd233797e.tar.bz2
rails-c954d54e2f36bb53ced5e3655adc071dd233797e.zip
Merge branch 'master' into nested_has_many_through
Diffstat (limited to 'railties/test/application/middleware/sendfile_test.rb')
-rw-r--r--railties/test/application/middleware/sendfile_test.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/railties/test/application/middleware/sendfile_test.rb b/railties/test/application/middleware/sendfile_test.rb
new file mode 100644
index 0000000000..0128261cd4
--- /dev/null
+++ b/railties/test/application/middleware/sendfile_test.rb
@@ -0,0 +1,56 @@
+require 'isolation/abstract_unit'
+
+module ApplicationTests
+ class SendfileTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ boot_rails
+ FileUtils.rm_rf "#{app_path}/config/environments"
+ end
+
+ def app
+ @app ||= Rails.application
+ end
+
+ define_method :simple_controller do
+ class ::OmgController < ActionController::Base
+ def index
+ send_file __FILE__
+ end
+ end
+ end
+
+ # x_sendfile_header middleware
+ test "config.action_dispatch.x_sendfile_header defaults to ''" do
+ make_basic_app
+ simple_controller
+
+ get "/"
+ assert_equal File.read(__FILE__), last_response.body
+ end
+
+ test "config.action_dispatch.x_sendfile_header can be set" do
+ make_basic_app do |app|
+ app.config.action_dispatch.x_sendfile_header = "X-Sendfile"
+ end
+
+ simple_controller
+
+ get "/"
+ assert_equal File.expand_path(__FILE__), last_response.headers["X-Sendfile"]
+ end
+
+ test "config.action_dispatch.x_sendfile_header is sent to Rack::Sendfile" do
+ make_basic_app do |app|
+ app.config.action_dispatch.x_sendfile_header = 'X-Lighttpd-Send-File'
+ end
+
+ simple_controller
+
+ get "/"
+ assert_equal File.expand_path(__FILE__), last_response.headers["X-Lighttpd-Send-File"]
+ end
+ end
+end