Commit c5944009 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Add specs for group member email

parent ed3933a0
......@@ -113,6 +113,12 @@ module EE
def post_create_hook
super
if provisioned_by_this_group?
run_after_commit_or_now do
notification_service.new_group_member_with_confirmation(self)
end
end
execute_hooks_for(:create)
end
......@@ -137,8 +143,6 @@ module EE
run_after_commit do
data = ::Gitlab::HookData::GroupMemberBuilder.new(self).build(event)
notification_service.new_group_member_with_confirmation(self) if provisioned_by_this_group?
data = ::Gitlab::HookData::GroupMemberBuilder.new(self).build(:create)
self.source.execute_hooks(data, :member_hooks)
end
end
......
......@@ -345,6 +345,7 @@ RSpec.describe GroupMember do
end
end
<<<<<<< HEAD
def webhook_data(group_member, event)
{
headers: { 'Content-Type' => 'application/json', 'User-Agent' => "GitLab/#{Gitlab::VERSION}", 'X-Gitlab-Event' => 'Member Hook' },
......@@ -364,5 +365,36 @@ RSpec.describe GroupMember do
event_name: event
}.to_json
}
=======
context 'group member welcome email', :sidekiq_inline do
let_it_be(:group) { create(:group_with_plan, plan: :gold_plan) }
let(:user) { create(:user) }
context 'when user is provisioned by group' do
before do
user.user_detail.update!(provisioned_by_group_id: group.id)
end
it 'schedules the welcome email with confirmation' do
expect_next_instance_of(NotificationService) do |notification|
expect(notification).to receive(:new_group_member_with_confirmation)
expect(notification).not_to receive(:new_group_member)
end
group.add_developer(user)
end
end
context 'when user is not provisioned by group' do
it 'schedules plain welcome to the group email' do
expect_next_instance_of(NotificationService) do |notification|
expect(notification).to receive(:new_group_member)
expect(notification).not_to receive(:new_group_member_with_confirmation)
end
group.add_developer(user)
end
end
>>>>>>> 456bbd408c4 (Add specs for group member email)
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