Commit 0e48535a authored by Alex Buijs's avatar Alex Buijs

Add invitation reminder emails worker implementation

parent b928a9bd
......@@ -10,6 +10,10 @@ class MemberInvitationReminderEmailsWorker # rubocop:disable Scalability/Idempot
def perform
return unless Gitlab::Experimentation.enabled?(:invitation_reminders)
# To keep this MR small, implementation will be done in another MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42981/diffs?commit_id=8063606e0f83957b2dd38d660ee986f24dee6138
Member.not_accepted_invitations.not_expired.last_ten_days_excluding_today.find_in_batches do |invitations|
invitations.each do |invitation|
Members::InvitationReminderEmailService.new(invitation).execute
end
end
end
end
......@@ -6,13 +6,19 @@ RSpec.describe MemberInvitationReminderEmailsWorker do
describe '#perform' do
subject { described_class.new.perform }
before do
create(:group_member, :invited, created_at: 2.days.ago)
end
context 'feature flag disabled' do
before do
stub_experiment(invitation_reminders: false)
end
it 'does not raise an error' do
expect { subject }.not_to raise_error
it 'does not attempt to execute the invitation reminder service' do
expect(Members::InvitationReminderEmailService).not_to receive(:new)
subject
end
end
......@@ -21,8 +27,12 @@ RSpec.describe MemberInvitationReminderEmailsWorker do
stub_experiment(invitation_reminders: true)
end
it 'does not raise an error' do
expect { subject }.not_to raise_error
it 'executes the invitation reminder email service' do
expect_next_instance_of(Members::InvitationReminderEmailService) do |service|
expect(service).to receive(:execute)
end
subject
end
end
end
......
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