From 814314cc82f031999ab041cd20d65ed034a8a81f Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sat, 2 Nov 2024 05:05:46 +0200 Subject: [PATCH] Updated tests --- test/application_system_test_case.rb | 6 ++++++ test/test_helper.rb | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 27b894c..94c7484 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -24,6 +24,12 @@ def sign_in_as(user) click_on "Login to your account" assert_current_path workspaces_path + session[:user_id] = user.id # Add this line to ensure session is set user end + + def teardown + super + session[:user_id] = nil if respond_to?(:session) + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index ea4dcef..8bf1a2a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -36,10 +36,18 @@ class TestCase # Add more helper methods to be used by all tests here... def sign_in_as(user) - post(sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }) + if respond_to?(:post) + post(sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }) + else + session[:user_id] = user.id + end user end + def teardown + session[:user_id] = nil if respond_to?(:session) + end + # Pundit helpers def assert_permit(user, record, action) msg = "User #{user.inspect} should be permitted to #{action} #{record}, but isn't permitted"