Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Jul 28, 2024
1 parent ed1da8e commit c32ddd1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Retrieve the session key and domain based on the environment using CheckConfig.
cookie_key = CheckConfig.get('session_store_key', '_checkdesk_session')
domain_setting = CheckConfig.get('session_store_domain', Rails.env.development? ? 'localhost' : 'checkmedia.org')
domain_setting = CheckConfig.get('session_store_domain', Rails.env.production? ? 'checkmedia.org' : 'localhost')

# Configure the session store with the dynamically obtained session key and domain.
Rails.application.config.session_store :cookie_store, key: cookie_key, domain: domain_setting
3 changes: 2 additions & 1 deletion test/lib/check_rack_attack_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'test_helper'
require_relative '../test_helper'

class ThrottlingTest < ActionDispatch::IntegrationTest
setup do
Expand Down Expand Up @@ -61,6 +61,7 @@ class ThrottlingTest < ActionDispatch::IntegrationTest

test "should apply higher rate limit for authenticated users" do
stub_configs({ 'api_rate_limit_authenticated' => 5 }) do
host!('localhost')
password = random_complex_password
user = create_user password: password
user_params = { api_user: { email: user.email, password: password } }
Expand Down
10 changes: 8 additions & 2 deletions test/lib/check_session_store_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
require 'test_helper'
require_relative '../test_helper'

class SessionStoreTest < ActiveSupport::TestCase
def setup
end

def teardown
end

def with_environment(env)
original_env = Rails.env
Rails.singleton_class.class_eval do
Expand All @@ -19,7 +25,7 @@ def with_environment(env)
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]
assert_equal 'checkmedia.org', Rails.application.config.session_options[:domain]
end
end
end
Expand Down

0 comments on commit c32ddd1

Please sign in to comment.