Skip to content

Commit b842e74

Browse files
Fix timing edge case in password_reset spec (#1638)
1 parent df9f2c3 commit b842e74

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

features/step_definitions/password_reset_steps.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Given(/^User foo@example\.com has not changed password for (\d+) months$/) do |changed|
22
@user = User.make!(
33
password: 'abc123abc',
4-
password_changed_at: changed.to_i.months.ago
4+
password_changed_at: (changed.to_i.months + 1.days).ago,
55
)
66
Institution.make! user: @user
77
end
@@ -12,13 +12,14 @@
1212

1313
Given(/^the previous passwords$/) do |table|
1414
@prev_passwords = table.raw.flatten[1..-1].unshift(@user.password)
15+
password_changed_at = @user.password_changed_at
1516
table.hashes.each do |hash|
1617
@user.password = hash['password']
1718
@user.password_confirmation = hash['password']
1819
@user.save!
1920
end
20-
@user.password_changed_at = 3.months.ago
21-
@user.save!
21+
# reset
22+
@user.update!(password_changed_at: password_changed_at)
2223
end
2324

2425
When(/^they try to use one of previous (\d+) passwords$/) do |arg1|

0 commit comments

Comments
 (0)