-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cds/reduce assertions per test #2563
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
276206d
Reduced number of assertions per test and brought Minitest/MultipleAs…
ConnorSheremeta a1a1eaa
System test changes
ConnorSheremeta 666cc2b
Address review comments
ConnorSheremeta 4ea66cf
small changes
ConnorSheremeta c697fbe
Merge branch 'master' into cds/reduce-assertions-per-test
ConnorSheremeta d43f132
Address code review feedback
ConnorSheremeta f08c473
# Conflicts:
ConnorSheremeta 80fd1b7
Fix last conflict
ConnorSheremeta b3e7c6b
Rubocop fixes
ConnorSheremeta dd58c73
Merge branch 'master' into cds/reduce-assertions-per-test
ConnorSheremeta 3fb87b1
Fix broken test which was getting another tests setup
ConnorSheremeta 2803cb1
accidentally commited folder
ConnorSheremeta 49c44dd
Merge branch 'master' into cds/reduce-assertions-per-test
ConnorSheremeta 36f4556
put new test in appropriate directory
ConnorSheremeta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,20 @@ | ||
require 'test_helper' | ||
|
||
class UpdateUserActivityJobTest < ActiveSupport::TestCase | ||
|
||
test 'should update the user activity (last seen at and IP) through the job' do | ||
user = users(:user_admin) | ||
ip = '4.73.73.73' | ||
now = Time.now.utc.to_s | ||
UpdateUserActivityJob.perform_now(user.id, now, ip) | ||
user.reload | ||
assert_equal user.last_seen_at.to_s, now | ||
assert_equal user.last_seen_ip, ip | ||
# Still does not change sign-in information | ||
assert_predicate user.last_sign_in_at, :blank? | ||
assert_predicate user.last_sign_in_ip, :blank? | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_ip, :blank? | ||
end | ||
|
||
end |
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 |
---|---|---|
|
@@ -23,83 +23,47 @@ class UserTest < ActiveSupport::TestCase | |
assert_equal "User:#{user.id}", user.flipper_id | ||
end | ||
|
||
# rubocop:disable Minitest/MultipleAssertions | ||
# TODO: our tests are quite smelly. This one needs work! | ||
test 'should update the activity columns when not signing-in' do | ||
user = users(:user_regular) | ||
test 'should update the activity columns when not signing-in for new user without activity update' do | ||
user = users(:user_admin) | ||
assert_predicate user.last_seen_at, :blank? | ||
assert_predicate user.last_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
end | ||
|
||
test 'should update the activity columns when not signing-in' do | ||
pgwillia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
user = users(:user_regular) | ||
|
||
ip1 = '4.26.50.50' | ||
now1 = Time.now.utc.to_s | ||
ip = '4.26.50.50' | ||
now = Time.now.utc.to_s | ||
|
||
user.update_activity!(now1, ip1) | ||
user.update_activity!(now, ip) | ||
user.reload | ||
|
||
assert_predicate user.last_seen_at, :present? | ||
assert_equal user.last_seen_at.to_s, now1 | ||
assert_equal user.last_seen_ip, ip1 | ||
assert_equal user.last_seen_at.to_s, now | ||
assert_equal user.last_seen_ip, ip | ||
# Does not change sign-in information | ||
assert_predicate user.last_sign_in_at, :blank? | ||
assert_predicate user.last_sign_in_ip, :blank? | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_ip, :blank? | ||
|
||
travel 1.hour do | ||
ip2 = '4.73.73.73' | ||
now2 = Time.now.utc.to_s | ||
assert_not_equal now2, now1 | ||
UpdateUserActivityJob.perform_now(user.id, now2, ip2) | ||
user.reload | ||
assert_equal user.last_seen_at.to_s, now2 | ||
assert_equal user.last_seen_ip, ip2 | ||
# Still does not change sign-in information | ||
assert_predicate user.last_sign_in_at, :blank? | ||
assert_predicate user.last_sign_in_ip, :blank? | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_ip, :blank? | ||
end | ||
end | ||
# rubocop:enable Minitest/MultipleAssertions | ||
|
||
# rubocop:disable Minitest/MultipleAssertions | ||
# TODO: our tests are quite smelly. This one needs work! | ||
test 'should update the activity columns when signing-in' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above this could be split into three tests
|
||
user = users(:user_regular) | ||
assert_predicate user.last_seen_at, :blank? | ||
assert_predicate user.last_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
|
||
ip1 = '4.26.50.50' | ||
now1 = Time.now.utc.to_s | ||
ip = '4.26.50.50' | ||
now = Time.now.utc.to_s | ||
|
||
user.update_activity!(now1, ip1, sign_in: true) | ||
user.update_activity!(now, ip, sign_in: true) | ||
user.reload | ||
assert_predicate user.last_seen_at, :present? | ||
assert_equal user.last_seen_at.to_s, now1 | ||
assert_equal user.last_seen_ip, ip1 | ||
assert_equal user.last_sign_in_at.to_s, now1 | ||
assert_equal user.last_sign_in_ip, ip1 | ||
assert_equal user.last_seen_at.to_s, now | ||
assert_equal user.last_seen_ip, ip | ||
assert_equal user.last_sign_in_at.to_s, now | ||
assert_equal user.last_sign_in_ip, ip | ||
assert_predicate user.previous_sign_in_at, :blank? | ||
assert_predicate user.previous_sign_in_ip, :blank? | ||
|
||
travel 1.hour do | ||
ip2 = '4.73.73.73' | ||
now2 = Time.now.utc.to_s | ||
assert_not_equal now2, now1 | ||
|
||
user.update_activity!(now2, ip2, sign_in: true) | ||
user.reload | ||
assert_equal user.last_seen_at.to_s, now2 | ||
assert_equal user.last_seen_ip, ip2 | ||
assert_equal user.last_sign_in_at.to_s, now2 | ||
assert_equal user.last_sign_in_ip, ip2 | ||
assert_equal user.previous_sign_in_at, now1 | ||
assert_equal user.previous_sign_in_ip, ip1 | ||
end | ||
end | ||
# rubocop:enable Minitest/MultipleAssertions | ||
|
||
test 'should validate if it does not have an api key and it is not a system account' do | ||
user = User.new( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!