From c9132c149cb9fe5628c2e947434e8c58acdaa709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 26 Apr 2010 09:04:04 +0200 Subject: Refactor tests by moving all middleware tests to the same place. --- railties/test/application/configuration_test.rb | 71 ++----------------------- 1 file changed, 5 insertions(+), 66 deletions(-) (limited to 'railties/test/application/configuration_test.rb') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 4f1fc3c299..dfc4e2359b 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -109,7 +109,7 @@ module ApplicationTests end end - test "Frameworks are not preloaded by default" do + test "frameworks are not preloaded by default" do require "#{app_path}/config/environment" assert ActionController.autoload?(:RecordIdentifier) @@ -193,71 +193,10 @@ module ApplicationTests assert_equal File.join(app_path, "somewhere"), Rails.public_path end - def make_basic_app - require "rails" - require "action_controller/railtie" - - app = Class.new(Rails::Application) - - yield app if block_given? - - app.config.session_store :disabled - app.initialize! - - app.routes.draw do - match "/" => "omg#index" - end - - require 'rack/test' - extend Rack::Test::Methods - end - - test "config.action_dispatch.x_sendfile_header defaults to ''" do - make_basic_app - - class ::OmgController < ActionController::Base - def index - send_file __FILE__ - end - end - - 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 - - class ::OmgController < ActionController::Base - def index - send_file __FILE__ - end - end - - 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 - - class ::OmgController < ActionController::Base - def index - send_file __FILE__ - end - end - - get "/" - assert_equal File.expand_path(__FILE__), last_response.headers["X-Lighttpd-Send-File"] - end - test "config.secret_token is sent in env" do make_basic_app do |app| app.config.secret_token = 'ThisIsASECRET123' + app.config.session_store :disabled end class ::OmgController < ActionController::Base @@ -287,9 +226,9 @@ module ApplicationTests end test "config.action_controller.perform_caching = true" do - make_basic_app do |app| - app.config.action_controller.perform_caching = true - end + make_basic_app do |app| + app.config.action_controller.perform_caching = true + end class ::OmgController < ActionController::Base @@count = 0 -- cgit v1.2.3