mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 19:50:44 +08:00
ba148e082d
Currently we don’t apply watched words to custom user fields nor user profile fields. This led to users being able to use blocked words in their bio, location or some custom user fields. This patch addresses this issue by adding some validations so it’s not possible anymore to save the User model or the UserProfile model if they contain blocked words.
36 lines
1.3 KiB
Ruby
36 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe Jobs::ActivationReminderEmails do
|
|
before { Jobs.run_immediately! }
|
|
|
|
# should be between 2 and 3 days
|
|
let(:created_at) { 50.hours.ago }
|
|
|
|
it 'should email inactive users' do
|
|
user = Fabricate(:user, active: false, created_at: created_at)
|
|
|
|
expect { described_class.new.execute({}) }
|
|
.to change { ActionMailer::Base.deliveries.size }.by(1)
|
|
.and change { user.email_tokens.count }.by(1)
|
|
.and change { user.reload.custom_fields[:activation_reminder] }.to "t"
|
|
expect { described_class.new.execute({}) }.to change { ActionMailer::Base.deliveries.size }.by(0)
|
|
expect { user.activate }.to change { user.reload.custom_fields[:activation_reminder] }.to nil
|
|
end
|
|
|
|
it 'should not email active users' do
|
|
user = Fabricate(:user, active: true, created_at: created_at)
|
|
|
|
expect { described_class.new.execute({}) }
|
|
.to change { ActionMailer::Base.deliveries.size }.by(0)
|
|
.and change { user.email_tokens.count }.by(0)
|
|
end
|
|
|
|
it 'should not email staged users' do
|
|
user = Fabricate(:user, active: false, staged: true, created_at: created_at)
|
|
|
|
expect { described_class.new.execute({}) }
|
|
.to change { ActionMailer::Base.deliveries.size }.by(0)
|
|
.and change { user.email_tokens.count }.by(0)
|
|
end
|
|
end
|