diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-23 12:58:56 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-23 12:58:56 -0800 |
commit | e6cfd853613f9d9e0232512146e40db4ee232a3c (patch) | |
tree | 824319d4261f200ff499e6900bc68841ec41c9a5 /railties | |
parent | 40b19e063592fc30705f17aafe6a458e7b622ff2 (diff) | |
parent | 98a1717e7c094d011c89ea1ed88673a595af2de8 (diff) | |
download | rails-e6cfd853613f9d9e0232512146e40db4ee232a3c.tar.gz rails-e6cfd853613f9d9e0232512146e40db4ee232a3c.tar.bz2 rails-e6cfd853613f9d9e0232512146e40db4ee232a3c.zip |
Merge pull request #3739 from lest/config-always-write-cookie
configuration option to always write cookie
Diffstat (limited to 'railties')
-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 |