mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: Ensure invalid timezone does not block critical emails (#26607)
See https://meta.discourse.org/t/invalid-user-timezone-jams-up-their-mail/303306 This ensures that "account silenced" and "account suspended" emails don't fail to send if the user has an invalid timezone.
This commit is contained in:
@ -1471,6 +1471,23 @@ RSpec.describe UserNotifications do
|
||||
expect(mail.body).to include(date)
|
||||
end
|
||||
end
|
||||
|
||||
context "when user timezone is invalid" do
|
||||
before { user.user_option.timezone = "" }
|
||||
|
||||
it "doesn't raise error" do
|
||||
expect { UserNotifications.account_silenced(user) }.not_to raise_error
|
||||
end
|
||||
|
||||
it "adds the silenced_till date in UTC" do
|
||||
date = "May 25, 2020, 12:00pm"
|
||||
user.silenced_till = DateTime.parse(date)
|
||||
|
||||
mail = UserNotifications.account_silenced(user, { user_history: user_history })
|
||||
|
||||
expect(mail.body).to include(date)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".account_suspended" do
|
||||
@ -1501,5 +1518,22 @@ RSpec.describe UserNotifications do
|
||||
expect(mail.body).to include(date)
|
||||
end
|
||||
end
|
||||
|
||||
context "when user timezone is invalid" do
|
||||
before { user.user_option.timezone = "" }
|
||||
|
||||
it "doesn't raise error" do
|
||||
expect { UserNotifications.account_suspended(user) }.not_to raise_error
|
||||
end
|
||||
|
||||
it "adds the suspended_till date in UTC" do
|
||||
date = "May 25, 2020, 12:00pm"
|
||||
user.suspended_till = DateTime.parse(date)
|
||||
|
||||
mail = UserNotifications.account_suspended(user, { user_history: user_history })
|
||||
|
||||
expect(mail.body).to include(date)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user