-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for session_store configuration
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'test_helper' | ||
|
||
class SessionStoreTest < ActiveSupport::TestCase | ||
def with_environment(env) | ||
original_env = Rails.env | ||
Rails.singleton_class.class_eval do | ||
define_method(:env) { ActiveSupport::StringInquirer.new(env) } | ||
end | ||
yield | ||
ensure | ||
Rails.singleton_class.class_eval do | ||
define_method(:env) { original_env } | ||
end | ||
end | ||
|
||
test "session store configuration in production" do | ||
with_environment('production') do | ||
load Rails.root.join('config/initializers/session_store.rb') | ||
assert_equal ActionDispatch::Session::CookieStore, Rails.application.config.session_store | ||
assert_equal '_checkdesk_session', Rails.application.config.session_options[:key] | ||
assert_equal '.checkmedia.org', Rails.application.config.session_options[:domain] | ||
end | ||
end | ||
|
||
test "session store configuration in development" do | ||
with_environment('development') do | ||
load Rails.root.join('config/initializers/session_store.rb') | ||
assert_equal ActionDispatch::Session::CookieStore, Rails.application.config.session_store | ||
assert_equal '_checkdesk_session', Rails.application.config.session_options[:key] | ||
assert_equal 'localhost', Rails.application.config.session_options[:domain] | ||
end | ||
end | ||
|
||
test "session store configuration in test" do | ||
with_environment('test') do | ||
load Rails.root.join('config/initializers/session_store.rb') | ||
assert_equal ActionDispatch::Session::CookieStore, Rails.application.config.session_store | ||
assert_equal '_checkdesk_session', Rails.application.config.session_options[:key] | ||
assert_nil Rails.application.config.session_options[:domain] | ||
end | ||
end | ||
end |