Commit 48d846d6 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'reminder-emails-send-method' into 'master'

Add Member#send_invitation_reminder method

See merge request gitlab-org/gitlab!42854
parents ba2bd1bf cc92b94a
...@@ -370,6 +370,14 @@ class Member < ApplicationRecord ...@@ -370,6 +370,14 @@ class Member < ApplicationRecord
send_invite send_invite
end end
def send_invitation_reminder(reminder_index)
return unless invite?
generate_invite_token! unless @raw_invite_token
run_after_commit_or_now { notification_service.invite_member_reminder(self, @raw_invite_token, reminder_index) }
end
def create_notification_setting def create_notification_setting
user.notification_settings.find_or_create_for(source) user.notification_settings.find_or_create_for(source)
end end
......
...@@ -676,6 +676,45 @@ RSpec.describe Member do ...@@ -676,6 +676,45 @@ RSpec.describe Member do
end end
end end
describe '#send_invitation_reminder' do
subject { member.send_invitation_reminder(0) }
context 'an invited group member' do
let!(:member) { create(:group_member, :invited) }
it 'sends a reminder' do
expect_any_instance_of(NotificationService).to receive(:invite_member_reminder).with(member, member.raw_invite_token, 0)
subject
end
end
context 'an invited member without a raw invite token set' do
let!(:member) { create(:group_member, :invited) }
before do
member.instance_variable_set(:@raw_invite_token, nil)
allow_any_instance_of(NotificationService).to receive(:invite_member_reminder)
end
it 'generates a new token' do
expect(member).to receive(:generate_invite_token!)
subject
end
end
context 'an uninvited member' do
let!(:member) { create(:group_member) }
it 'does not send a reminder' do
expect_any_instance_of(NotificationService).not_to receive(:invite_member_reminder)
subject
end
end
end
describe "#invite_to_unknown_user?" do describe "#invite_to_unknown_user?" do
subject { member.invite_to_unknown_user? } subject { member.invite_to_unknown_user? }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment