diff options
author | lest <just.lest@gmail.com> | 2011-11-23 23:36:56 +0300 |
---|---|---|
committer | lest <just.lest@gmail.com> | 2011-11-23 23:50:04 +0300 |
commit | 98a1717e7c094d011c89ea1ed88673a595af2de8 (patch) | |
tree | 24fcc58fdef79730ae0840c4e1d35c532df8cd4e /railties/test/application | |
parent | 8549f7a4f0c30c37050666f5661ea9e270a298fd (diff) | |
download | rails-98a1717e7c094d011c89ea1ed88673a595af2de8.tar.gz rails-98a1717e7c094d011c89ea1ed88673a595af2de8.tar.bz2 rails-98a1717e7c094d011c89ea1ed88673a595af2de8.zip |
configuration option to always write cookie
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/middleware/cookies_test.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/railties/test/application/middleware/cookies_test.rb b/railties/test/application/middleware/cookies_test.rb new file mode 100644 index 0000000000..13556cbed2 --- /dev/null +++ b/railties/test/application/middleware/cookies_test.rb @@ -0,0 +1,47 @@ +require 'isolation/abstract_unit' + +module ApplicationTests + class CookiesTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + + def new_app + File.expand_path("#{app_path}/../new_app") + end + + def setup + build_app + boot_rails + FileUtils.rm_rf("#{app_path}/config/environments") + end + + def teardown + teardown_app + FileUtils.rm_rf(new_app) if File.directory?(new_app) + end + + test 'always_write_cookie is true by default in development' do + require 'rails' + Rails.env = 'development' + require "#{app_path}/config/environment" + assert_equal true, ActionDispatch::Cookies::CookieJar.always_write_cookie + end + + test 'always_write_cookie is false by default in production' do + require 'rails' + Rails.env = 'production' + require "#{app_path}/config/environment" + assert_equal false, ActionDispatch::Cookies::CookieJar.always_write_cookie + end + + test 'always_write_cookie can be overrided' do + add_to_config <<-RUBY + config.action_dispatch.always_write_cookie = false + RUBY + + require 'rails' + Rails.env = 'development' + require "#{app_path}/config/environment" + assert_equal false, ActionDispatch::Cookies::CookieJar.always_write_cookie + end + end +end |