Commit cb5362e7 authored by Douwe Maan's avatar Douwe Maan
Browse files

Follow newline guidelines.

parent 96c455c24dbc
......@@ -48,13 +48,16 @@ def destroy
end
def resend_invite
redirect_path = group_group_members_path(@group)
@group_member = @group.group_members.find(params[:id])
if @group_member.invite?
@group_member.resend_invite
redirect_to group_group_members_path(@group), notice: 'The invitation was successfully resent.'
redirect_to redirect_path, notice: 'The invitation was successfully resent.'
else
redirect_to group_group_members_path(@group), alert: 'The invitation has already been accepted.'
redirect_to redirect_path, alert: 'The invitation has already been accepted.'
end
end
......
......@@ -43,10 +43,13 @@ def member
return @member if defined?(@member)
@token = params[:id]
@member = Member.find_by_invite_token(@token)
render_404 unless @member
unless @member
render_404 and return
end
@member
end
def authenticate_user!
......
......@@ -62,6 +62,7 @@ def resend_invite
redirect_path = namespace_project_project_members_path(@project.namespace, @project)
@project_member = @project.project_members.find(params[:id])
if @project_member.invite?
@project_member.resend_invite
......
......@@ -3,8 +3,10 @@ module Groups
def group_access_granted_email(group_member_id)
@group_member = GroupMember.find(group_member_id)
@group = @group_member.group
@target_url = group_url(@group)
@current_user = @group_member.user
mail(to: @group_member.user.notification_email,
subject: subject("Access to group was granted"))
end
......@@ -13,8 +15,10 @@ def group_member_invited_email(group_member_id, token)
@group_member = GroupMember.find group_member_id
@group = @group_member.group
@token = token
@target_url = group_url(@group)
@current_user = @group_member.user
mail(to: @group_member.invite_email,
subject: "Invitation to join group #{@group.name}")
end
......@@ -24,8 +28,10 @@ def group_invite_accepted_email(group_member_id)
return if @group_member.created_by.nil?
@group = @group_member.group
@target_url = group_url(@group)
@current_user = @group_member.created_by
mail(to: @group_member.created_by.notification_email,
subject: subject("Invitation accepted"))
end
......@@ -37,6 +43,7 @@ def group_invite_declined_email(group_id, invite_email, access_level, created_by
@current_user = @created_by = User.find(created_by_id)
@access_level = access_level
@invite_email = invite_email
@target_url = group_url(@group)
mail(to: @created_by.notification_email,
subject: subject("Invitation declined"))
......
......@@ -3,8 +3,10 @@ module Projects
def project_access_granted_email(project_member_id)
@project_member = ProjectMember.find project_member_id
@project = @project_member.project
@target_url = namespace_project_url(@project.namespace, @project)
@current_user = @project_member.user
mail(to: @project_member.user.notification_email,
subject: subject("Access to project was granted"))
end
......@@ -13,8 +15,10 @@ def project_member_invited_email(project_member_id, token)
@project_member = ProjectMember.find project_member_id
@project = @project_member.project
@token = token
@target_url = namespace_project_url(@project.namespace, @project)
@current_user = @project_member.user
mail(to: @project_member.invite_email,
subject: "Invitation to join project #{@project.name_with_namespace}")
end
......@@ -24,6 +28,7 @@ def project_invite_accepted_email(project_member_id)
return if @project_member.created_by.nil?
@project = @project_member.project
@target_url = namespace_project_url(@project.namespace, @project)
@current_user = @project_member.created_by
......@@ -38,6 +43,7 @@ def project_invite_declined_email(project_id, invite_email, access_level, create
@current_user = @created_by = User.find(created_by_id)
@access_level = access_level
@invite_email = invite_email
@target_url = namespace_project_url(@project.namespace, @project)
mail(to: @created_by.notification_email,
......
......@@ -80,6 +80,7 @@ def add_users_into_projects(project_ids, user_ids, access, current_user = nil)
def truncate_teams(project_ids)
ProjectMember.transaction do
members = ProjectMember.where(source_id: project_ids)
members.each do |member|
member.destroy
end
......
......@@ -13,7 +13,6 @@
it { is_expected.to validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) }
context "when an invite email is provided" do
let(:member) { build(:project_member, invite_email: "user@example.com", user: nil) }
it "doesn't require a user" do
......@@ -38,7 +37,6 @@
end
context "when an invite email is not provided" do
let(:member) { build(:project_member) }
it "requires a user" do
......@@ -96,7 +94,6 @@
end
describe "#accept_invite!" do
let!(:member) { create(:project_member, invite_email: "user@example.com", user: nil) }
let(:user) { create(: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