Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
cb5362e7
Commit
cb5362e7
authored
Apr 14, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow newline guidelines.
parent
0013ea51
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
7 deletions
+25
-7
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+5
-2
app/controllers/invites_controller.rb
app/controllers/invites_controller.rb
+5
-2
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+1
-0
app/mailers/emails/groups.rb
app/mailers/emails/groups.rb
+7
-0
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+6
-0
app/models/members/project_member.rb
app/models/members/project_member.rb
+1
-0
spec/models/member_spec.rb
spec/models/member_spec.rb
+0
-3
No files found.
app/controllers/groups/group_members_controller.rb
View file @
cb5362e7
...
@@ -48,13 +48,16 @@ class Groups::GroupMembersController < Groups::ApplicationController
...
@@ -48,13 +48,16 @@ class Groups::GroupMembersController < Groups::ApplicationController
end
end
def
resend_invite
def
resend_invite
redirect_path
=
group_group_members_path
(
@group
)
@group_member
=
@group
.
group_members
.
find
(
params
[
:id
])
@group_member
=
@group
.
group_members
.
find
(
params
[
:id
])
if
@group_member
.
invite?
if
@group_member
.
invite?
@group_member
.
resend_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
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
end
end
...
...
app/controllers/invites_controller.rb
View file @
cb5362e7
...
@@ -43,10 +43,13 @@ class InvitesController < ApplicationController
...
@@ -43,10 +43,13 @@ class InvitesController < ApplicationController
return
@member
if
defined?
(
@member
)
return
@member
if
defined?
(
@member
)
@token
=
params
[
:id
]
@token
=
params
[
:id
]
@member
=
Member
.
find_by_invite_token
(
@token
)
@member
=
Member
.
find_by_invite_token
(
@token
)
render_404
unless
@member
unless
@member
render_404
and
return
end
@member
end
end
def
authenticate_user!
def
authenticate_user!
...
...
app/controllers/projects/project_members_controller.rb
View file @
cb5362e7
...
@@ -62,6 +62,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -62,6 +62,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
redirect_path
=
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
redirect_path
=
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
@project_member
=
@project
.
project_members
.
find
(
params
[
:id
])
@project_member
=
@project
.
project_members
.
find
(
params
[
:id
])
if
@project_member
.
invite?
if
@project_member
.
invite?
@project_member
.
resend_invite
@project_member
.
resend_invite
...
...
app/mailers/emails/groups.rb
View file @
cb5362e7
...
@@ -3,8 +3,10 @@ module Emails
...
@@ -3,8 +3,10 @@ module Emails
def
group_access_granted_email
(
group_member_id
)
def
group_access_granted_email
(
group_member_id
)
@group_member
=
GroupMember
.
find
(
group_member_id
)
@group_member
=
GroupMember
.
find
(
group_member_id
)
@group
=
@group_member
.
group
@group
=
@group_member
.
group
@target_url
=
group_url
(
@group
)
@target_url
=
group_url
(
@group
)
@current_user
=
@group_member
.
user
@current_user
=
@group_member
.
user
mail
(
to:
@group_member
.
user
.
notification_email
,
mail
(
to:
@group_member
.
user
.
notification_email
,
subject:
subject
(
"Access to group was granted"
))
subject:
subject
(
"Access to group was granted"
))
end
end
...
@@ -13,8 +15,10 @@ module Emails
...
@@ -13,8 +15,10 @@ module Emails
@group_member
=
GroupMember
.
find
group_member_id
@group_member
=
GroupMember
.
find
group_member_id
@group
=
@group_member
.
group
@group
=
@group_member
.
group
@token
=
token
@token
=
token
@target_url
=
group_url
(
@group
)
@target_url
=
group_url
(
@group
)
@current_user
=
@group_member
.
user
@current_user
=
@group_member
.
user
mail
(
to:
@group_member
.
invite_email
,
mail
(
to:
@group_member
.
invite_email
,
subject:
"Invitation to join group
#{
@group
.
name
}
"
)
subject:
"Invitation to join group
#{
@group
.
name
}
"
)
end
end
...
@@ -24,8 +28,10 @@ module Emails
...
@@ -24,8 +28,10 @@ module Emails
return
if
@group_member
.
created_by
.
nil?
return
if
@group_member
.
created_by
.
nil?
@group
=
@group_member
.
group
@group
=
@group_member
.
group
@target_url
=
group_url
(
@group
)
@target_url
=
group_url
(
@group
)
@current_user
=
@group_member
.
created_by
@current_user
=
@group_member
.
created_by
mail
(
to:
@group_member
.
created_by
.
notification_email
,
mail
(
to:
@group_member
.
created_by
.
notification_email
,
subject:
subject
(
"Invitation accepted"
))
subject:
subject
(
"Invitation accepted"
))
end
end
...
@@ -37,6 +43,7 @@ module Emails
...
@@ -37,6 +43,7 @@ module Emails
@current_user
=
@created_by
=
User
.
find
(
created_by_id
)
@current_user
=
@created_by
=
User
.
find
(
created_by_id
)
@access_level
=
access_level
@access_level
=
access_level
@invite_email
=
invite_email
@invite_email
=
invite_email
@target_url
=
group_url
(
@group
)
@target_url
=
group_url
(
@group
)
mail
(
to:
@created_by
.
notification_email
,
mail
(
to:
@created_by
.
notification_email
,
subject:
subject
(
"Invitation declined"
))
subject:
subject
(
"Invitation declined"
))
...
...
app/mailers/emails/projects.rb
View file @
cb5362e7
...
@@ -3,8 +3,10 @@ module Emails
...
@@ -3,8 +3,10 @@ module Emails
def
project_access_granted_email
(
project_member_id
)
def
project_access_granted_email
(
project_member_id
)
@project_member
=
ProjectMember
.
find
project_member_id
@project_member
=
ProjectMember
.
find
project_member_id
@project
=
@project_member
.
project
@project
=
@project_member
.
project
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@current_user
=
@project_member
.
user
@current_user
=
@project_member
.
user
mail
(
to:
@project_member
.
user
.
notification_email
,
mail
(
to:
@project_member
.
user
.
notification_email
,
subject:
subject
(
"Access to project was granted"
))
subject:
subject
(
"Access to project was granted"
))
end
end
...
@@ -13,8 +15,10 @@ module Emails
...
@@ -13,8 +15,10 @@ module Emails
@project_member
=
ProjectMember
.
find
project_member_id
@project_member
=
ProjectMember
.
find
project_member_id
@project
=
@project_member
.
project
@project
=
@project_member
.
project
@token
=
token
@token
=
token
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@current_user
=
@project_member
.
user
@current_user
=
@project_member
.
user
mail
(
to:
@project_member
.
invite_email
,
mail
(
to:
@project_member
.
invite_email
,
subject:
"Invitation to join project
#{
@project
.
name_with_namespace
}
"
)
subject:
"Invitation to join project
#{
@project
.
name_with_namespace
}
"
)
end
end
...
@@ -24,6 +28,7 @@ module Emails
...
@@ -24,6 +28,7 @@ module Emails
return
if
@project_member
.
created_by
.
nil?
return
if
@project_member
.
created_by
.
nil?
@project
=
@project_member
.
project
@project
=
@project_member
.
project
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@current_user
=
@project_member
.
created_by
@current_user
=
@project_member
.
created_by
...
@@ -38,6 +43,7 @@ module Emails
...
@@ -38,6 +43,7 @@ module Emails
@current_user
=
@created_by
=
User
.
find
(
created_by_id
)
@current_user
=
@created_by
=
User
.
find
(
created_by_id
)
@access_level
=
access_level
@access_level
=
access_level
@invite_email
=
invite_email
@invite_email
=
invite_email
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
@target_url
=
namespace_project_url
(
@project
.
namespace
,
@project
)
mail
(
to:
@created_by
.
notification_email
,
mail
(
to:
@created_by
.
notification_email
,
...
...
app/models/members/project_member.rb
View file @
cb5362e7
...
@@ -80,6 +80,7 @@ class ProjectMember < Member
...
@@ -80,6 +80,7 @@ class ProjectMember < Member
def
truncate_teams
(
project_ids
)
def
truncate_teams
(
project_ids
)
ProjectMember
.
transaction
do
ProjectMember
.
transaction
do
members
=
ProjectMember
.
where
(
source_id:
project_ids
)
members
=
ProjectMember
.
where
(
source_id:
project_ids
)
members
.
each
do
|
member
|
members
.
each
do
|
member
|
member
.
destroy
member
.
destroy
end
end
...
...
spec/models/member_spec.rb
View file @
cb5362e7
...
@@ -13,7 +13,6 @@ describe Member do
...
@@ -13,7 +13,6 @@ describe Member do
it
{
is_expected
.
to
validate_inclusion_of
(
:access_level
).
in_array
(
Gitlab
::
Access
.
values
)
}
it
{
is_expected
.
to
validate_inclusion_of
(
:access_level
).
in_array
(
Gitlab
::
Access
.
values
)
}
context
"when an invite email is provided"
do
context
"when an invite email is provided"
do
let
(
:member
)
{
build
(
:project_member
,
invite_email:
"user@example.com"
,
user:
nil
)
}
let
(
:member
)
{
build
(
:project_member
,
invite_email:
"user@example.com"
,
user:
nil
)
}
it
"doesn't require a user"
do
it
"doesn't require a user"
do
...
@@ -38,7 +37,6 @@ describe Member do
...
@@ -38,7 +37,6 @@ describe Member do
end
end
context
"when an invite email is not provided"
do
context
"when an invite email is not provided"
do
let
(
:member
)
{
build
(
:project_member
)
}
let
(
:member
)
{
build
(
:project_member
)
}
it
"requires a user"
do
it
"requires a user"
do
...
@@ -96,7 +94,6 @@ describe Member do
...
@@ -96,7 +94,6 @@ describe Member do
end
end
describe
"#accept_invite!"
do
describe
"#accept_invite!"
do
let!
(
:member
)
{
create
(
:project_member
,
invite_email:
"user@example.com"
,
user:
nil
)
}
let!
(
:member
)
{
create
(
:project_member
,
invite_email:
"user@example.com"
,
user:
nil
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment