Skip to content

Commit

Permalink
Add test for deletion date *un*assignment of invalid user
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Jan 13, 2025
1 parent 6afc5cc commit de0bb31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@
"selectize",
"Timecop",
"turbolinks",
"Unsets",
"unassigns",
"uncached",
"Unsets",
"whitespaces"
],
"cSpell.enableFiletypes": [
Expand Down
16 changes: 16 additions & 0 deletions spec/models/user_cleaner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ def test_non_confirmed_user(confirmation_sent_date, expected_inactive_users_coun
expect(user_inactive2.deletion_date).to eq(deletion_date)
expect(user_active.deletion_date).to be_nil
end

it "unassigns a deletion from a recently active user even if validations fail" do
user = FactoryBot.create(:confirmed_user, current_sign_in_at: 2.days.ago,
deletion_date: Date.current + 5.days)
user.name = ""
user.save(validate: false)
user.reload

user_invalid = User.find(user.id)
expect(user_invalid).not_to be_valid

UserCleaner.new.unset_deletion_date_for_recently_active_users
user_invalid.reload

expect(user_invalid.deletion_date).to be_nil
end
end

describe("#delete_users") do
Expand Down

0 comments on commit de0bb31

Please sign in to comment.