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

Add cr remarks

Fix conflicts with master

Fix rubocop offence

Add cr remarks
parent 69181697
......@@ -62,7 +62,7 @@ class GroupMember < Member
end
def post_create_hook
if available_for_welcome_email?
if send_welcome_email?
run_after_commit_or_now { notification_service.new_group_member(self) }
end
......@@ -90,7 +90,7 @@ class GroupMember < Member
super
end
def available_for_welcome_email?
def send_welcome_email?
true
end
end
......
......@@ -8,5 +8,7 @@
<%= _('By authenticating with an account tied to an Enterprise e-mail address, it is understood that this account is an Enterprise User. ') %>
<%= _('To ensure no loss of personal content, an Individual User should create a separate account under their own personal email address, not tied to the Enterprise email domain or name-space.') %>
<%= _('To get started, click the link below to confirm your account.') %>
<%= confirmation_url(@user, confirmation_token: @user.confirmation_token) %>
<%- unless @user.confirmed? %>
<%= _('To get started, click the link below to confirm your account.') %>
<%= confirmation_url(@user, confirmation_token: @user.confirmation_token) %>
<%- end %>
......@@ -3,15 +3,15 @@
module EE
module Emails
module Members
def member_access_granted_email_with_confirmation(member_source_type, member_id)
@member_source_type = member_source_type
def member_access_granted_email_with_confirmation(member_id)
@member_id = member_id
@user = member.user
return unless member_exists?
@user = member.user
member_email_with_layout(
to: member.user.notification_email_for(notification_group),
to: member.user.email,
subject: subject("Welcome to GitLab"))
end
end
......
......@@ -52,7 +52,7 @@ module EE
end
def new_group_member_with_confirmation_email
::Notify.member_access_granted_email_with_confirmation(member.source_type, member.id).message
::Notify.member_access_granted_email_with_confirmation(member.id).message
end
end
......
......@@ -147,8 +147,8 @@ module EE
end
end
override :available_for_welcome_email?
def available_for_welcome_email?
override :send_welcome_email?
def send_welcome_email?
!provisioned_by_this_group?
end
......
......@@ -63,9 +63,7 @@ module EE
end
def new_group_member_with_confirmation(group_member)
return true unless group_member.notifiable?(:mention)
mailer.member_access_granted_email_with_confirmation(group_member.real_source_type, group_member.id).deliver_later
mailer.member_access_granted_email_with_confirmation(group_member.id).deliver_later
end
private
......
......@@ -371,16 +371,11 @@ RSpec.describe Notify do
end
describe 'new user was created via saml' do
let(:group_member) { create(:group_member) }
let(:group_member) { create(:group_member, user: create(:user, :unconfirmed)) }
let(:group) { group_member.source }
let(:recipient) { group_member.user }
before do
recipient.update!(confirmed_at: nil)
recipient.update!(confirmation_token: 'random_string')
end
subject { described_class.member_access_granted_email_with_confirmation('group', group_member.id) }
subject { described_class.member_access_granted_email_with_confirmation(group_member.id) }
it_behaves_like 'an email sent from GitLab'
it_behaves_like 'it should not have Gmail Actions links'
......@@ -389,7 +384,7 @@ RSpec.describe Notify do
it_behaves_like 'appearance header and footer not enabled'
it 'delivers mail to user email' do
expect(subject).to deliver_to(recipient.notification_email)
expect(subject).to deliver_to(recipient.email)
end
it 'contains all the useful information' do
......
......@@ -345,27 +345,6 @@ 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' },
body: {
created_at: group_member.created_at&.xmlschema,
updated_at: group_member.updated_at&.xmlschema,
group_name: group.name,
group_path: group.path,
group_id: group.id,
user_username: group_member.user.username,
user_name: group_member.user.name,
user_email: group_member.user.email,
user_id: group_member.user.id,
group_access: group_member.human_access,
expires_at: group_member.expires_at&.xmlschema,
group_plan: 'gold',
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) }
......@@ -395,6 +374,26 @@ RSpec.describe GroupMember do
group.add_developer(user)
end
end
>>>>>>> 456bbd408c4 (Add specs for group member email)
end
def webhook_data(group_member, event)
{
headers: { 'Content-Type' => 'application/json', 'User-Agent' => "GitLab/#{Gitlab::VERSION}", 'X-Gitlab-Event' => 'Member Hook' },
body: {
created_at: group_member.created_at&.xmlschema,
updated_at: group_member.updated_at&.xmlschema,
group_name: group.name,
group_path: group.path,
group_id: group.id,
user_username: group_member.user.username,
user_name: group_member.user.name,
user_email: group_member.user.email,
user_id: group_member.user.id,
group_access: group_member.human_access,
expires_at: group_member.expires_at&.xmlschema,
group_plan: 'gold',
event_name: event
}.to_json
}
end
end
......@@ -860,17 +860,6 @@ RSpec.describe EE::NotificationService, :mailer do
group.add_guest(added_user)
should_only_email(added_user)
end
describe 'when notifications are disabled' do
before do
create_global_setting_for(added_user, :disabled)
end
it 'does not send a notification' do
group.add_guest(added_user)
should_not_email_anyone
end
end
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