BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bdbadebe
Unverified
Commit
bdbadebe
authored
Sep 15, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix adminarea and emails for new membership logic
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
1aa48174
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
63 additions
and
63 deletions
+63
-63
notifications_controller.rb
app/controllers/profiles/notifications_controller.rb
+3
-3
groups.rb
app/mailers/emails/groups.rb
+1
-1
projects.rb
app/mailers/emails/projects.rb
+4
-4
user.rb
app/models/user.rb
+1
-1
notification_service.rb
app/services/notification_service.rb
+12
-12
show.html.haml
app/views/admin/groups/show.html.haml
+1
-1
show.html.haml
app/views/admin/projects/show.html.haml
+5
-5
project_access_granted_email.html.haml
app/views/notify/project_access_granted_email.html.haml
+1
-1
project_access_granted_email.text.erb
app/views/notify/project_access_granted_email.text.erb
+1
-1
show.html.haml
app/views/profiles/notifications/show.html.haml
+3
-3
_group_members.html.haml
app/views/projects/team_members/_group_members.html.haml
+1
-1
factories.rb
spec/factories.rb
+2
-2
users_groups.rb
spec/factories/users_groups.rb
+2
-2
notify_spec.rb
spec/mailers/notify_spec.rb
+3
-3
branches_spec.rb
spec/requests/api/branches_spec.rb
+2
-2
commits_spec.rb
spec/requests/api/commits_spec.rb
+2
-2
project_members_spec.rb
spec/requests/api/project_members_spec.rb
+8
-8
projects_spec.rb
spec/requests/api/projects_spec.rb
+4
-4
repositories_spec.rb
spec/requests/api/repositories_spec.rb
+2
-2
system_hooks_service_spec.rb
spec/services/system_hooks_service_spec.rb
+5
-5
No files found.
app/controllers/profiles/notifications_controller.rb
View file @
bdbadebe
...
...
@@ -18,9 +18,9 @@ class Profiles::NotificationsController < ApplicationController
users_group
.
notification_level
=
params
[
:notification_level
]
users_group
.
save
else
users_project
=
current_user
.
project_members
.
find
(
params
[
:notification_id
])
users_project
.
notification_level
=
params
[
:notification_level
]
users_project
.
save
project_member
=
current_user
.
project_members
.
find
(
params
[
:notification_id
])
project_member
.
notification_level
=
params
[
:notification_level
]
project_member
.
save
end
end
end
app/mailers/emails/groups.rb
View file @
bdbadebe
module
Emails
module
Groups
def
access_level
_granted_email
(
user_group_id
)
def
group_access
_granted_email
(
user_group_id
)
@membership
=
GroupMember
.
find
(
user_group_id
)
@group
=
@membership
.
group
@target_url
=
group_url
(
@group
)
...
...
app/mailers/emails/projects.rb
View file @
bdbadebe
module
Emails
module
Projects
def
access_level
_granted_email
(
user_project_id
)
@
users_project
=
ProjectMember
.
find
user_project_id
@project
=
@
users_project
.
project
def
project_access
_granted_email
(
user_project_id
)
@
project_member
=
ProjectMember
.
find
user_project_id
@project
=
@
project_member
.
project
@target_url
=
project_url
(
@project
)
mail
(
to:
@
users_project
.
user
.
email
,
mail
(
to:
@
project_member
.
user
.
email
,
subject:
subject
(
"Access to project was granted"
))
end
...
...
app/models/user.rb
View file @
bdbadebe
...
...
@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
scope
:in_team
,
->
(
team
){
where
(
id:
team
.
member_ids
)
}
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:not_in_project
,
->
(
project
)
{
project
.
users
.
present?
?
where
(
"id not in (:ids)"
,
ids:
project
.
users
.
map
(
&
:
id
)
)
:
all
}
scope
:without_projects
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM
project_
members)'
)
}
scope
:without_projects
,
->
{
where
(
'id NOT IN (SELECT DISTINCT(user_id) FROM members)'
)
}
scope
:ldap
,
->
{
where
(
provider:
'ldap'
)
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
...
...
app/services/notification_service.rb
View file @
bdbadebe
...
...
@@ -157,20 +157,20 @@ class NotificationService
end
end
def
new_team_member
(
users_project
)
mailer
.
access_level_granted_email
(
users_project
.
id
)
def
new_team_member
(
project_member
)
mailer
.
project_access_granted_email
(
project_member
.
id
)
end
def
update_team_member
(
users_project
)
mailer
.
access_level_granted_email
(
users_project
.
id
)
def
update_team_member
(
project_member
)
mailer
.
project_access_granted_email
(
project_member
.
id
)
end
def
new_group_member
(
users_group
)
mailer
.
access_level
_granted_email
(
users_group
.
id
)
mailer
.
group_access
_granted_email
(
users_group
.
id
)
end
def
update_group_member
(
users_group
)
mailer
.
access_level
_granted_email
(
users_group
.
id
)
mailer
.
group_access
_granted_email
(
users_group
.
id
)
end
def
project_was_moved
(
project
)
...
...
@@ -186,19 +186,19 @@ class NotificationService
# Get project users with WATCH notification level
def
project_watchers
(
project
)
project_members
=
users_project
_notification
(
project
)
project_members
=
project_member
_notification
(
project
)
users_with_project_level_global
=
users_project
_notification
(
project
,
Notification
::
N_GLOBAL
)
users_with_project_level_global
=
project_member
_notification
(
project
,
Notification
::
N_GLOBAL
)
users_with_group_level_global
=
users_group_notification
(
project
,
Notification
::
N_GLOBAL
)
users
=
users_with_global_level_watch
([
users_with_project_level_global
,
users_with_group_level_global
].
flatten
.
uniq
)
users_with_project_setting
=
select_
users_project
_setting
(
project
,
users_with_project_level_global
,
users
)
users_with_project_setting
=
select_
project_member
_setting
(
project
,
users_with_project_level_global
,
users
)
users_with_group_setting
=
select_users_group_setting
(
project
,
project_members
,
users_with_group_level_global
,
users
)
User
.
where
(
id:
users_with_project_setting
.
concat
(
users_with_group_setting
).
uniq
).
to_a
end
def
users_project
_notification
(
project
,
notification_level
=
nil
)
def
project_member
_notification
(
project
,
notification_level
=
nil
)
project_members
=
project
.
project_members
if
notification_level
...
...
@@ -224,8 +224,8 @@ class NotificationService
end
# Build a list of users based on project notifcation settings
def
select_
users_project
_setting
(
project
,
global_setting
,
users_global_level_watch
)
users
=
users_project
_notification
(
project
,
Notification
::
N_WATCH
)
def
select_
project_member
_setting
(
project
,
global_setting
,
users_global_level_watch
)
users
=
project_member
_notification
(
project
,
Notification
::
N_WATCH
)
# If project setting is global, add to watch list if global setting is watch
global_setting
.
each
do
|
user_id
|
...
...
app/views/admin/groups/show.html.haml
View file @
bdbadebe
...
...
@@ -80,7 +80,7 @@
=
link_to
user
.
name
,
admin_user_path
(
user
)
%span
.pull-right.light
=
member
.
human_access
=
link_to
group_
users_group
_path
(
@group
,
member
),
data:
{
confirm:
remove_user_from_group_message
(
@group
,
user
)
},
method: :delete
,
remote:
true
,
class:
"btn-tiny btn btn-remove"
,
title:
'Remove user from group'
do
=
link_to
group_
group_members
_path
(
@group
,
member
),
data:
{
confirm:
remove_user_from_group_message
(
@group
,
user
)
},
method: :delete
,
remote:
true
,
class:
"btn-tiny btn btn-remove"
,
title:
'Remove user from group'
do
%i
.icon-minus.icon-white
.panel-footer
=
paginate
@members
,
param_name:
'members_page'
,
theme:
'gitlab'
app/views/admin/projects/show.html.haml
View file @
bdbadebe
...
...
@@ -101,7 +101,7 @@
%i
.icon-edit
%ul
.well-list
-
@group_members
.
each
do
|
member
|
=
render
'group
_members/users_group
'
,
member:
member
,
show_controls:
false
=
render
'group
s/group_members/group_member
'
,
member:
member
,
show_controls:
false
.panel-footer
=
paginate
@group_members
,
param_name:
'group_members_page'
,
theme:
'gitlab'
...
...
@@ -115,17 +115,17 @@
%i
.icon-edit
Manage Access
%ul
.well-list.team_members
-
@project_members
.
each
do
|
users_project
|
-
user
=
users_project
.
user
-
@project_members
.
each
do
|
project_member
|
-
user
=
project_member
.
user
%li
.project_member
.list-item-name
%strong
=
link_to
user
.
name
,
admin_user_path
(
user
)
.pull-right
-
if
users_project
.
owner?
-
if
project_member
.
owner?
%span
.light
Owner
-
else
%span
.light
=
users_project
.
human_access
%span
.light
=
project_member
.
human_access
=
link_to
project_team_member_path
(
@project
,
user
),
data:
{
confirm:
remove_from_project_team_message
(
@project
,
user
)},
method: :delete
,
remote:
true
,
class:
"btn btn-small btn-remove"
do
%i
.icon-remove
.panel-footer
...
...
app/views/notify/project_access_granted_email.html.haml
View file @
bdbadebe
%p
=
"You have been granted
#{
@
users_project
.
human_access
}
access to project"
=
"You have been granted
#{
@
project_member
.
human_access
}
access to project"
%p
=
link_to
project_url
(
@project
)
do
=
@project
.
name_with_namespace
app/views/notify/project_access_granted_email.text.erb
View file @
bdbadebe
You have been granted
<%=
@
users_project
.
human_access
%>
access to project
<%=
@project
.
name_with_namespace
%>
You have been granted
<%=
@
project_member
.
human_access
%>
access to project
<%=
@project
.
name_with_namespace
%>
<%=
url_for
(
project_url
(
@project
))
%>
app/views/profiles/notifications/show.html.haml
View file @
bdbadebe
...
...
@@ -46,6 +46,6 @@
.col-md-6
%h4
Projects:
%ul
.bordered-list
-
@project_members
.
each
do
|
users_project
|
-
notification
=
Notification
.
new
(
users_project
)
=
render
'settings'
,
type:
'project'
,
membership:
users_project
,
notification:
notification
-
@project_members
.
each
do
|
project_member
|
-
notification
=
Notification
.
new
(
project_member
)
=
render
'settings'
,
type:
'project'
,
membership:
project_member
,
notification:
notification
app/views/projects/team_members/_group_members.html.haml
View file @
bdbadebe
...
...
@@ -8,7 +8,7 @@
%i
.icon-edit
%ul
.well-list
-
@group
.
group_members
.
order
(
'access_level DESC'
).
limit
(
20
).
each
do
|
member
|
=
render
'group
_members/users_group
'
,
member:
member
,
show_controls:
false
=
render
'group
s/group_members/group_member
'
,
member:
member
,
show_controls:
false
-
if
group_users_count
>
20
%li
and
#{
group_users_count
-
20
}
more. For full list visit
#{
link_to
'group members page'
,
members_group_path
(
@group
)
}
spec/factories.rb
View file @
bdbadebe
...
...
@@ -39,10 +39,10 @@ FactoryGirl.define do
owner
end
factory
:
users_project
do
factory
:
project_member
do
user
project
project_access
{
ProjectMember
::
MASTER
}
access_level
{
ProjectMember
::
MASTER
}
end
factory
:issue
do
...
...
spec/factories/users_groups.rb
View file @
bdbadebe
...
...
@@ -12,8 +12,8 @@
#
FactoryGirl
.
define
do
factory
:
users_group
do
group_access
{
GroupMember
::
OWNER
}
factory
:
group_member
do
access_level
{
GroupMember
::
OWNER
}
group
user
end
...
...
spec/mailers/notify_spec.rb
View file @
bdbadebe
...
...
@@ -402,10 +402,10 @@ describe Notify do
describe
'project access changed'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
users_project
)
{
create
(
:users_project
,
let
(
:
project_member
)
{
create
(
:project_member
,
project:
project
,
user:
user
)
}
subject
{
Notify
.
project_access_granted_email
(
users_project
.
id
)
}
subject
{
Notify
.
project_access_granted_email
(
project_member
.
id
)
}
it_behaves_like
'an email sent from GitLab'
...
...
@@ -416,7 +416,7 @@ describe Notify do
should
have_body_text
/
#{
project
.
name
}
/
end
it
'contains new user role'
do
should
have_body_text
/
#{
users_project
.
human_access
}
/
should
have_body_text
/
#{
project_member
.
human_access
}
/
end
end
...
...
spec/requests/api/branches_spec.rb
View file @
bdbadebe
...
...
@@ -7,8 +7,8 @@ describe API::API, api: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:
users_project
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
users_project
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
let!
(
:master
)
{
create
(
:
project_member
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
project_member
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
let!
(
:branch_name
)
{
'feature'
}
let!
(
:branch_sha
)
{
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
}
...
...
spec/requests/api/commits_spec.rb
View file @
bdbadebe
...
...
@@ -6,8 +6,8 @@ describe API::API, api: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:
users_project
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
users_project
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
let!
(
:master
)
{
create
(
:
project_member
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
project_member
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
before
{
project
.
team
<<
[
user
,
:reporter
]
}
...
...
spec/requests/api/project_members_spec.rb
View file @
bdbadebe
...
...
@@ -6,12 +6,12 @@ describe API::API, api: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let
(
:
users_project
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let
(
:
users_project2
)
{
create
(
:users_project
,
user:
user3
,
project:
project
,
project_access:
ProjectMember
::
DEVELOPER
)
}
let
(
:
project_member
)
{
create
(
:project_member
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let
(
:
project_member2
)
{
create
(
:project_member
,
user:
user3
,
project:
project
,
project_access:
ProjectMember
::
DEVELOPER
)
}
describe
"GET /projects/:id/members"
do
before
{
users_project
}
before
{
users_project
2
}
before
{
project_member
}
before
{
project_member
2
}
it
"should return project team members"
do
get
api
(
"/projects/
#{
project
.
id
}
/members"
,
user
)
...
...
@@ -36,7 +36,7 @@ describe API::API, api: true do
end
describe
"GET /projects/:id/members/:user_id"
do
before
{
users_project
}
before
{
project_member
}
it
"should return project team member"
do
get
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user
.
id
}
"
,
user
)
...
...
@@ -93,7 +93,7 @@ describe API::API, api: true do
end
describe
"PUT /projects/:id/members/:user_id"
do
before
{
users_project
2
}
before
{
project_member
2
}
it
"should update project team member"
do
put
api
(
"/projects/
#{
project
.
id
}
/members/
#{
user3
.
id
}
"
,
user
),
access_level:
ProjectMember
::
MASTER
...
...
@@ -119,8 +119,8 @@ describe API::API, api: true do
end
describe
"DELETE /projects/:id/members/:user_id"
do
before
{
users_project
}
before
{
users_project
2
}
before
{
project_member
}
before
{
project_member
2
}
it
"should remove user from project team"
do
expect
{
...
...
spec/requests/api/projects_spec.rb
View file @
bdbadebe
...
...
@@ -8,8 +8,8 @@ describe API::API, api: true do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
author:
user
,
project:
project
,
title:
'example'
)
}
let
(
:
users_project
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let
(
:
users_project2
)
{
create
(
:users_project
,
user:
user3
,
project:
project
,
project_access:
ProjectMember
::
DEVELOPER
)
}
let
(
:
project_member
)
{
create
(
:project_member
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let
(
:
project_member2
)
{
create
(
:project_member
,
user:
user3
,
project:
project
,
project_access:
ProjectMember
::
DEVELOPER
)
}
describe
"GET /projects"
do
before
{
project
}
...
...
@@ -254,7 +254,7 @@ describe API::API, api: true do
describe
"GET /projects/:id"
do
before
{
project
}
before
{
users_project
}
before
{
project_member
}
it
"should return a project by id"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
...
...
@@ -305,7 +305,7 @@ describe API::API, api: true do
end
describe
"GET /projects/:id/events"
do
before
{
users_project
}
before
{
project_member
}
it
"should return a project events"
do
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
...
...
spec/requests/api/repositories_spec.rb
View file @
bdbadebe
...
...
@@ -8,8 +8,8 @@ describe API::API, api: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:
users_project
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
users_project
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
let!
(
:master
)
{
create
(
:
project_member
,
user:
user
,
project:
project
,
project_access:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:
project_member
,
user:
user2
,
project:
project
,
project_access:
ProjectMember
::
GUEST
)
}
before
{
project
.
team
<<
[
user
,
:reporter
]
}
...
...
spec/services/system_hooks_service_spec.rb
View file @
bdbadebe
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
SystemHooksService
do
let
(
:user
)
{
create
:user
}
let
(
:project
)
{
create
:project
}
let
(
:
users_project
)
{
create
:users_project
}
let
(
:
project_member
)
{
create
:project_member
}
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
context
'event data'
do
...
...
@@ -11,8 +11,8 @@ describe SystemHooksService do
it
{
event_data
(
user
,
:destroy
).
should
include
(
:event_name
,
:name
,
:created_at
,
:email
,
:user_id
)
}
it
{
event_data
(
project
,
:create
).
should
include
(
:event_name
,
:name
,
:created_at
,
:path
,
:project_id
,
:owner_name
,
:owner_email
,
:project_visibility
)
}
it
{
event_data
(
project
,
:destroy
).
should
include
(
:event_name
,
:name
,
:created_at
,
:path
,
:project_id
,
:owner_name
,
:owner_email
,
:project_visibility
)
}
it
{
event_data
(
users_project
,
:create
).
should
include
(
:event_name
,
:created_at
,
:project_name
,
:project_path
,
:project_id
,
:user_name
,
:user_email
,
:project_access
,
:project_visibility
)
}
it
{
event_data
(
users_project
,
:destroy
).
should
include
(
:event_name
,
:created_at
,
:project_name
,
:project_path
,
:project_id
,
:user_name
,
:user_email
,
:project_access
,
:project_visibility
)
}
it
{
event_data
(
project_member
,
:create
).
should
include
(
:event_name
,
:created_at
,
:project_name
,
:project_path
,
:project_id
,
:user_name
,
:user_email
,
:access_level
,
:project_visibility
)
}
it
{
event_data
(
project_member
,
:destroy
).
should
include
(
:event_name
,
:created_at
,
:project_name
,
:project_path
,
:project_id
,
:user_name
,
:user_email
,
:access_level
,
:project_visibility
)
}
it
{
event_data
(
key
,
:create
).
should
include
(
:username
,
:key
,
:id
)
}
it
{
event_data
(
key
,
:destroy
).
should
include
(
:username
,
:key
,
:id
)
}
end
...
...
@@ -22,8 +22,8 @@ describe SystemHooksService do
it
{
event_name
(
user
,
:destroy
).
should
eq
"user_destroy"
}
it
{
event_name
(
project
,
:create
).
should
eq
"project_create"
}
it
{
event_name
(
project
,
:destroy
).
should
eq
"project_destroy"
}
it
{
event_name
(
users_project
,
:create
).
should
eq
"user_add_to_team"
}
it
{
event_name
(
users_project
,
:destroy
).
should
eq
"user_remove_from_team"
}
it
{
event_name
(
project_member
,
:create
).
should
eq
"user_add_to_team"
}
it
{
event_name
(
project_member
,
:destroy
).
should
eq
"user_remove_from_team"
}
it
{
event_name
(
key
,
:create
).
should
eq
'key_create'
}
it
{
event_name
(
key
,
:destroy
).
should
eq
'key_destroy'
}
end
...
...
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