mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Extract subject
from User#mark_email_as_confirmed!
spec (#29231)
This commit is contained in:
parent
1690fb39e6
commit
117b507df5
@ -451,35 +451,32 @@ RSpec.describe User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#mark_email_as_confirmed!' do
|
describe '#mark_email_as_confirmed!' do
|
||||||
subject(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
|
subject { user.mark_email_as_confirmed! }
|
||||||
|
|
||||||
before do
|
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
|
||||||
ActionMailer::Base.deliveries.clear
|
|
||||||
user.mark_email_as_confirmed!
|
before { ActionMailer::Base.deliveries.clear }
|
||||||
end
|
|
||||||
|
|
||||||
after { ActionMailer::Base.deliveries.clear }
|
after { ActionMailer::Base.deliveries.clear }
|
||||||
|
|
||||||
context 'when user is new' do
|
context 'when user is new' do
|
||||||
let(:confirmed_at) { nil }
|
let(:confirmed_at) { nil }
|
||||||
|
|
||||||
it 'confirms user' do
|
it 'confirms user and delivers welcome email', :sidekiq_inline do
|
||||||
expect(user.confirmed_at).to be_present
|
subject
|
||||||
end
|
|
||||||
|
|
||||||
it 'delivers mails', :sidekiq_inline do
|
expect(user.confirmed_at).to be_present
|
||||||
expect(ActionMailer::Base.deliveries.count).to eq 2
|
expect(ActionMailer::Base.deliveries.count).to eq 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is not new' do
|
context 'when user is not new' do
|
||||||
let(:confirmed_at) { Time.zone.now }
|
let(:confirmed_at) { Time.zone.now }
|
||||||
|
|
||||||
it 'confirms user' do
|
it 'confirms user but does not deliver welcome email' do
|
||||||
expect(user.confirmed_at).to be_present
|
subject
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not deliver mail' do
|
expect(user.confirmed_at).to be_present
|
||||||
expect(ActionMailer::Base.deliveries.count).to eq 0
|
expect(ActionMailer::Base.deliveries.count).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user