Change test to pass on Travis

This commit is contained in:
Urban Rotnik 2019-02-18 18:42:42 +01:00
parent d3d9868ba4
commit f7c7335bf0

View file

@ -15,7 +15,7 @@ describe UserSystemNotification do
it { is_expected.to belong_to(:system_notification) } it { is_expected.to belong_to(:system_notification) }
end end
describe '.send_email' do describe '.create' do
before do before do
Delayed::Worker.delay_jobs = false Delayed::Worker.delay_jobs = false
end end
@ -25,22 +25,22 @@ describe UserSystemNotification do
end end
context 'when user has enabled notifications' do context 'when user has enabled notifications' do
it 'delivers an email on creating new user_system_notification' do it 'calls send an email on creation' do
allow(user_system_notification.user) allow(user_system_notification.user)
.to receive(:system_message_email_notification).and_return(true) .to receive(:system_message_email_notification).and_return(true)
expect { user_system_notification.save } expect(user_system_notification).to receive(:send_email)
.to change { ActionMailer::Base.deliveries.count }.by(1) user_system_notification.save
end end
end end
context 'when user has disabled notifications' do context 'when user has disabled notifications' do
it 'doesn\'t deliver email on creating new user_system_notification' do it 'doesn\'t call send an email on createion' do
allow(user_system_notification.user) allow(user_system_notification.user)
.to receive(:system_message_email_notification).and_return(false) .to receive(:system_message_email_notification).and_return(false)
expect { user_system_notification.save } expect(user_system_notification).not_to receive(:send_email)
.not_to(change { ActionMailer::Base.deliveries.count }) user_system_notification.save
end end
end end
end end