Skip to content

Commit

Permalink
Update failing user cleaner jobs with new method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 1, 2024
1 parent e0e066c commit 6dd845c
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions spec/models/user_cleaner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def test_non_confirmed_user(confirmation_sent_date, expected_inactive_users_coun

expect do
UserCleaner.new.set_deletion_date_for_inactive_users
end.to have_enqueued_mail(UserCleanerMailer, :pending_deletion_email)
.with(a_hash_including(args: [40]))
end.to(have_enqueued_mail(UserCleanerMailer, :pending_deletion_email)
.with { |args| expect(args).to include(40) })
end

it "does not enqueue a deletion warning mail (40 days) for non-generic users" do
Expand All @@ -217,8 +217,8 @@ def test_enqueues_additional_deletion_warning_mails(num_days)

expect do
UserCleaner.new.send_additional_warning_mails
end.to have_enqueued_mail(UserCleanerMailer, :pending_deletion_email)
.with(a_hash_including(args: [num_days]))
end.to(have_enqueued_mail(UserCleanerMailer, :pending_deletion_email)
.with { |args| expect(args).to include(num_days) })
end

it "enqueues additional deletion warning mails" do
Expand Down Expand Up @@ -263,7 +263,8 @@ def test_enqueues_additional_deletion_warning_mails(num_days)

def test_subject_line(num_days)
user = FactoryBot.create(:confirmed_user)
mailer = UserCleanerMailer.with(user: user).pending_deletion_email(num_days)
mailer = UserCleanerMailer
.pending_deletion_email(user.email, user.locale, 40, num_days)
expect(mailer.subject).to include(num_days.to_s)
end

Expand All @@ -275,11 +276,13 @@ def test_subject_line(num_days)
end

it "has mail subject localized to the user's locale" do
mailer = UserCleanerMailer.with(user: user_de).pending_deletion_email(40)
mailer = UserCleanerMailer
.pending_deletion_email(user_de.email, user_de.locale, 40)
expect(mailer.subject).to include("Tage")
expect(mailer.subject).not_to include("days")

mailer = UserCleanerMailer.with(user: user_en).pending_deletion_email(40)
mailer = UserCleanerMailer
.pending_deletion_email(user_en.email, user_en.locale, 40)
expect(mailer.subject).to include("days")
expect(mailer.subject).not_to include("Tage")
end
Expand All @@ -288,11 +291,13 @@ def test_subject_line(num_days)
expected_de = "verloren"
expected_en = "lost"

mailer = UserCleanerMailer.with(user: user_de).pending_deletion_email(40)
mailer = UserCleanerMailer
.pending_deletion_email(user_de.email, user_de.locale, 40)
expect(mailer.html_part.body).to include(expected_de)
expect(mailer.html_part.body).not_to include(expected_en)

mailer = UserCleanerMailer.with(user: user_en).pending_deletion_email(40)
mailer = UserCleanerMailer
.pending_deletion_email(user_en.email, user_en.locale, 40)
expect(mailer.html_part.body).to include(expected_en)
expect(mailer.html_part.body).not_to include(expected_de)
end
Expand All @@ -303,11 +308,11 @@ def test_subject_line(num_days)
let(:user_en) { FactoryBot.create(:confirmed_user, locale: "en") }

it "has mail subject localized to the user's locale" do
mailer = UserCleanerMailer.with(user: user_de).deletion_email
mailer = UserCleanerMailer.deletion_email(user_de.email, user_de.locale)
expect(mailer.subject).to include("gelöscht")
expect(mailer.subject).not_to include("deleted")

mailer = UserCleanerMailer.with(user: user_en).deletion_email
mailer = UserCleanerMailer.deletion_email(user_en.email, user_en.locale)
expect(mailer.subject).to include("deleted")
expect(mailer.subject).not_to include("gelöscht")
end
Expand All @@ -316,12 +321,13 @@ def test_subject_line(num_days)
expected_de = "vollständig gelöscht"
expected_en = "deleted entirely"

mailer = UserCleanerMailer.with(user: user_de).deletion_email
mailer = UserCleanerMailer.deletion_email(user_de.email, user_de.locale)

expect(mailer.html_part.body).to include(expected_de)
expect(mailer.html_part.body).not_to include(expected_en)

mailer = UserCleanerMailer.with(user: user_en).deletion_email
mailer = UserCleanerMailer.deletion_email(user_en.email, user_en.locale)

expect(mailer.html_part.body).to include(expected_en)
expect(mailer.html_part.body).not_to include(expected_de)
end
Expand Down

0 comments on commit 6dd845c

Please sign in to comment.