Skip to content

Commit

Permalink
Add tests for session_store configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjay-w committed Jul 15, 2024
1 parent 78944b0 commit 83aee30
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/lib/check_session_store_test.rb
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

0 comments on commit 83aee30

Please sign in to comment.