diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-03-28 14:44:34 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-03-28 14:44:34 +1100 |
commit | 2bcc2ebf44b59e46c104c92d621e8051c97bfcf5 (patch) | |
tree | d2a3f04fd3020c1b5d88847af62d52f2d5e5bd61 /railties/test/application | |
parent | f5774e3e3f70a3acfa559b9ff889e9417fb71d4b (diff) | |
parent | 8398f21880a952769ccd6437a4344922fe596dab (diff) | |
download | rails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.tar.gz rails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.tar.bz2 rails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/configuration_test.rb | 70 | ||||
-rw-r--r-- | railties/test/application/paths_test.rb | 18 |
2 files changed, 45 insertions, 43 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 54cd751f4e..68ca2acaad 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -140,7 +140,7 @@ module ApplicationTests require "#{app_path}/config/environment" end end - + test "filter_parameters should be able to set via config.filter_parameters" do add_to_config <<-RUBY config.filter_parameters += [ :foo, 'bar', lambda { |key, value| @@ -172,16 +172,27 @@ module ApplicationTests assert $prepared end - test "config.action_dispatch.x_sendfile_header defaults to X-Sendfile" do + def make_basic_app require "rails" require "action_controller/railtie" - class MyApp < Rails::Application - config.cookie_secret = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" + 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 - MyApp.initialize! + 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 @@ -189,44 +200,53 @@ module ApplicationTests end end - MyApp.routes.draw do - match "/" => "omg#index" + 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 - require 'rack/test' - extend Rack::Test::Methods + 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 - require "rails" - require "action_controller/railtie" - - class MyApp < Rails::Application - config.cookie_secret = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" - config.action_dispatch.x_sendfile_header = 'X-Lighttpd-Send-File' + make_basic_app do |app| + app.config.action_dispatch.x_sendfile_header = 'X-Lighttpd-Send-File' end - MyApp.initialize! - class ::OmgController < ActionController::Base def index send_file __FILE__ end end - MyApp.routes.draw do - match "/" => "omg#index" - end + get "/" + assert_equal File.expand_path(__FILE__), last_response.headers["X-Lighttpd-Send-File"] + end - require 'rack/test' - extend Rack::Test::Methods + test "protect from forgery is the default in a new app" do + make_basic_app + + class ::OmgController < ActionController::Base + protect_from_forgery + + def index + render :inline => "<%= csrf_meta_tag %>" + end + end get "/" - assert_equal File.expand_path(__FILE__), last_response.headers["X-Lighttpd-Send-File"] + assert last_response.body =~ /csrf\-param/ end end end diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb index 511b8b629a..589e515d05 100644 --- a/railties/test/application/paths_test.rb +++ b/railties/test/application/paths_test.rb @@ -51,8 +51,6 @@ module ApplicationTests assert_path @paths.config.environment, "config", "environments", "development.rb" assert_equal root("app", "controllers"), @paths.app.controllers.to_a.first - assert_equal Pathname.new(File.dirname(__FILE__)).join("..", "..", "builtin", "rails_info").expand_path, - Pathname.new(@paths.app.controllers.to_a[1]).expand_path end test "booting up Rails yields a list of paths that are eager" do @@ -80,21 +78,5 @@ module ApplicationTests assert_not_in_load_path "tmp" assert_not_in_load_path "tmp", "cache" end - - test "controller paths include builtin in development mode" do - Rails.env.replace "development" - assert Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ } - end - - test "controller paths does not have builtin_directories in test mode" do - Rails.env.replace "test" - assert !Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ } - end - - test "controller paths does not have builtin_directories in production mode" do - Rails.env.replace "production" - assert !Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ } - end - end end |