Defect #36336

Executing test helper "log_user" function behavior is different between Redmine 4.0 and >= 4.1

Added by Ko Nagase 10 months ago. Updated 10 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Accounts / authentication
Target version:-
Resolution:Wont fix Affected version:4.1.5

Description

I noticed that test helper "log_user" function behavior (User.current value) is different between Redmine 4.0 and >= 4.1.
I am not sure whether this is unexpected result or expected result (or I just miss something)...

Redmine 4.0 (4.0-stable branch):

Edit test code:

--- a/test/integration/account_test.rb
+++ b/test/integration/account_test.rb
@@ -25,6 +25,7 @@ class AccountTest < Redmine::IntegrationTest
     assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fmy%2Fpage" 
     log_user('jsmith', 'jsmith')

+    puts "User.current: #{User.current}" 
     get "/my/account" 
     assert_response :success
   end

Execute test:

bundle exec rails test test/integration/account_test.rb:23
Run options: --seed 47668

# Running:

User.current: John Smith
.

Finished in 1.700418s, 0.5881 runs/s, 3.5285 assertions/s.
1 runs, 6 assertions, 0 failures, 0 errors, 0 skips

Redmine 4.1 and 4.2 (4.1-stable and 4.2-stable branches)

Edit test code:

--- a/test/integration/account_test.rb
+++ b/test/integration/account_test.rb
@@ -27,6 +27,7 @@ class AccountTest < Redmine::IntegrationTest
     assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fmy%2Fpage" 
     log_user('jsmith', 'jsmith')

+    puts "User.current: #{User.current}" 
     get "/my/account" 
     assert_response :success
   end

Execute test:

bundle exec rails test test/integration/account_test.rb:25
Run options: --seed 25932

# Running:

User.current: Anonymous
.

Finished in 1.583653s, 0.6315 runs/s, 3.7887 assertions/s.
1 runs, 6 assertions, 0 failures, 0 errors, 0 skips


Related issues

Related to Redmine - Feature #31911: Update request_store gem to 1.4 Closed

History

#1 Updated by Go MAEDA 10 months ago

#2 Updated by Go MAEDA 10 months ago

I think the behavior has changed by #31911 and you should use User.find(session[:user_id]) instead of User.current in tests. See #31911#note-2, #16685#note-13, and #16685#note-13 for details.

#3 Updated by Ko Nagase 10 months ago

  • Status changed from New to Resolved

Okay, I see.
I set the status to "Resolved".

Thanks for the clarification!

#4 Updated by Go MAEDA 10 months ago

  • Status changed from Resolved to Closed
  • Resolution set to Wont fix

Thank you for your feedback. Closing.

Also available in: Atom PDF