Sha256: 771b2a5d9e0d4a86b71bec10bdc0fc64e8f906106f499668dc27e6b6fa66b403
Contents?: true
Size: 1.26 KB
Versions: 23
Compression:
Stored size: 1.26 KB
Contents
describe Spotlight::InviteUsersService do subject { described_class.call(resource: resource) } let(:resource) do FactoryBot.create(:exhibit, roles: [FactoryBot.create(:role, user: user)]) end context 'when the user was not created by an invite' do let(:user) { FactoryBot.create(:user) } it 'does not send an invite' do expect do subject end.to change { Devise::Mailer.deliveries.count }.by(0) expect(user.reload.invitation_sent_at).to be_nil end end context 'when the user has already received an invite' do let!(:user) do User.invite!(email: 'a-user-that-does-not-exist@example.com', skip_invitation: true).tap do |u| u.invitation_sent_at = Time.zone.now end end it 'does not send an invite' do expect do subject end.to change { Devise::Mailer.deliveries.count }.by(0) end end context 'when the user was created by but not yet received an invite' do let(:user) do User.invite!(email: 'a-user-that-does-not-exist@example.com', skip_invitation: true) end it 'sends an invite' do expect do subject end.to change { Devise::Mailer.deliveries.count }.by(1) expect(user.reload.invitation_sent_at).to be_present end end end
Version data entries
23 entries across 23 versions & 1 rubygems