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
a97cb8f8
Commit
a97cb8f8
authored
May 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_9013' into 'master'
Let users set notification levels in projects which they are not members Fixes #9013 See merge request !3986
parents
56eb4200
6fb9bf87
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
8 deletions
+81
-8
CHANGELOG
CHANGELOG
+1
-0
projects_controller.rb
app/controllers/projects_controller.rb
+1
-7
notifications.md
doc/workflow/notifications.md
+1
-1
notification_settings_controller_spec.rb
...rollers/projects/notification_settings_controller_spec.rb
+14
-0
projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+34
-0
notification_service_spec.rb
spec/services/notification_service_spec.rb
+30
-0
No files found.
CHANGELOG
View file @
a97cb8f8
...
@@ -41,6 +41,7 @@ v 8.8.0 (unreleased)
...
@@ -41,6 +41,7 @@ v 8.8.0 (unreleased)
- Added button to toggle whitespaces changes on diff view
- Added button to toggle whitespaces changes on diff view
- Backport GitHub Enterprise import support from EE
- Backport GitHub Enterprise import support from EE
- Create tags using Rugged for performance reasons. !3745
- Create tags using Rugged for performance reasons. !3745
- Allow guests to set notification level in projects
- API: Expose Issue#user_notes_count. !3126 (Anton Popov)
- API: Expose Issue#user_notes_count. !3126 (Anton Popov)
- Don't show forks button when user can't view forks
- Don't show forks button when user can't view forks
- Fix atom feed links and rendering
- Fix atom feed links and rendering
...
...
app/controllers/projects_controller.rb
View file @
a97cb8f8
...
@@ -101,13 +101,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -101,13 +101,7 @@ class ProjectsController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
if
current_user
@notification_setting
=
current_user
.
notification_settings_for
(
@project
)
if
current_user
@membership
=
@project
.
team
.
find_member
(
current_user
.
id
)
if
@membership
@notification_setting
=
current_user
.
notification_settings_for
(
@project
)
end
end
if
@project
.
repository_exists?
if
@project
.
repository_exists?
if
@project
.
empty_repo?
if
@project
.
empty_repo?
...
...
doc/workflow/notifications.md
View file @
a97cb8f8
...
@@ -69,7 +69,7 @@ In all of the below cases, the notification will be sent to:
...
@@ -69,7 +69,7 @@ In all of the below cases, the notification will be sent to:
...with notification level "Participating" or higher
...with notification level "Participating" or higher
-
Watchers:
project memb
ers with notification level "Watch"
-
Watchers:
us
ers with notification level "Watch"
-
Subscribers: anyone who manually subscribed to the issue/merge request
-
Subscribers: anyone who manually subscribed to the issue/merge request
| Event | Sent to |
| Event | Sent to |
...
...
spec/controllers/projects/notification_settings_controller_spec.rb
View file @
a97cb8f8
...
@@ -34,5 +34,19 @@ describe Projects::NotificationSettingsController do
...
@@ -34,5 +34,19 @@ describe Projects::NotificationSettingsController do
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
end
end
end
end
context
'not authorized'
do
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
before
{
sign_in
(
user
)
}
it
'returns 404'
do
put
:update
,
namespace_id:
private_project
.
namespace
.
to_param
,
project_id:
private_project
.
to_param
,
notification_setting:
{
level: :participating
}
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
end
end
spec/controllers/projects_controller_spec.rb
View file @
a97cb8f8
...
@@ -8,6 +8,40 @@ describe ProjectsController do
...
@@ -8,6 +8,40 @@ describe ProjectsController do
let
(
:txt
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
let
(
:txt
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
describe
"GET show"
do
describe
"GET show"
do
context
"user not project member"
do
before
{
sign_in
(
user
)
}
context
"user does not have access to project"
do
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
it
"does not initialize notification setting"
do
get
:show
,
namespace_id:
private_project
.
namespace
.
path
,
id:
private_project
.
path
expect
(
assigns
(
:notification_setting
)).
to
be_nil
end
end
context
"user has access to project"
do
context
"and does not have notification setting"
do
it
"initializes notification as disabled"
do
get
:show
,
namespace_id:
public_project
.
namespace
.
path
,
id:
public_project
.
path
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"global"
)
end
end
context
"and has notification setting"
do
before
do
setting
=
user
.
notification_settings_for
(
public_project
)
setting
.
level
=
:watch
setting
.
save
end
it
"shows current notification setting"
do
get
:show
,
namespace_id:
public_project
.
namespace
.
path
,
id:
public_project
.
path
expect
(
assigns
(
:notification_setting
).
level
).
to
eq
(
"watch"
)
end
end
end
end
context
"rendering default project view"
do
context
"rendering default project view"
do
render_views
render_views
...
...
spec/services/notification_service_spec.rb
View file @
a97cb8f8
...
@@ -66,6 +66,7 @@ describe NotificationService, services: true do
...
@@ -66,6 +66,7 @@ describe NotificationService, services: true do
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@subscribed_participant
)
should_email
(
@subscribed_participant
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
note
.
author
)
should_not_email
(
note
.
author
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
...
@@ -100,6 +101,7 @@ describe NotificationService, services: true do
...
@@ -100,6 +101,7 @@ describe NotificationService, services: true do
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
assignee
)
should_email
(
note
.
noteable
.
assignee
)
should_email
(
@u_mentioned
)
should_email
(
@u_mentioned
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
@u_watcher
)
should_not_email
(
@u_watcher
)
should_not_email
(
note
.
author
)
should_not_email
(
note
.
author
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
...
@@ -160,6 +162,7 @@ describe NotificationService, services: true do
...
@@ -160,6 +162,7 @@ describe NotificationService, services: true do
should_email
(
member
)
should_email
(
member
)
end
end
should_email
(
@u_guest_watcher
)
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
assignee
)
should_email
(
note
.
noteable
.
assignee
)
should_not_email
(
note
.
author
)
should_not_email
(
note
.
author
)
...
@@ -201,6 +204,7 @@ describe NotificationService, services: true do
...
@@ -201,6 +204,7 @@ describe NotificationService, services: true do
should_email
(
member
)
should_email
(
member
)
end
end
should_email
(
@u_guest_watcher
)
should_email
(
note
.
noteable
.
author
)
should_email
(
note
.
noteable
.
author
)
should_not_email
(
note
.
author
)
should_not_email
(
note
.
author
)
should_email
(
@u_mentioned
)
should_email
(
@u_mentioned
)
...
@@ -224,6 +228,7 @@ describe NotificationService, services: true do
...
@@ -224,6 +228,7 @@ describe NotificationService, services: true do
it
do
it
do
notification
.
new_note
(
note
)
notification
.
new_note
(
note
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_committer
)
should_email
(
@u_committer
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_not_email
(
@u_mentioned
)
should_not_email
(
@u_mentioned
)
...
@@ -236,6 +241,7 @@ describe NotificationService, services: true do
...
@@ -236,6 +241,7 @@ describe NotificationService, services: true do
note
.
update_attribute
(
:note
,
'@mention referenced'
)
note
.
update_attribute
(
:note
,
'@mention referenced'
)
notification
.
new_note
(
note
)
notification
.
new_note
(
note
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_committer
)
should_email
(
@u_committer
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_mentioned
)
should_email
(
@u_mentioned
)
...
@@ -269,6 +275,7 @@ describe NotificationService, services: true do
...
@@ -269,6 +275,7 @@ describe NotificationService, services: true do
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_not_email
(
@u_mentioned
)
should_not_email
(
@u_mentioned
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
...
@@ -328,6 +335,7 @@ describe NotificationService, services: true do
...
@@ -328,6 +335,7 @@ describe NotificationService, services: true do
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
...
@@ -342,6 +350,7 @@ describe NotificationService, services: true do
...
@@ -342,6 +350,7 @@ describe NotificationService, services: true do
should_email
(
@u_mentioned
)
should_email
(
@u_mentioned
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
...
@@ -356,6 +365,7 @@ describe NotificationService, services: true do
...
@@ -356,6 +365,7 @@ describe NotificationService, services: true do
expect
(
issue
.
assignee
).
to
be
@u_mentioned
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
...
@@ -370,6 +380,7 @@ describe NotificationService, services: true do
...
@@ -370,6 +380,7 @@ describe NotificationService, services: true do
expect
(
issue
.
assignee
).
to
be
@u_mentioned
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
...
@@ -383,6 +394,7 @@ describe NotificationService, services: true do
...
@@ -383,6 +394,7 @@ describe NotificationService, services: true do
expect
(
issue
.
assignee
).
to
be
@u_mentioned
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_not_email
(
issue
.
assignee
)
should_not_email
(
issue
.
assignee
)
...
@@ -411,6 +423,7 @@ describe NotificationService, services: true do
...
@@ -411,6 +423,7 @@ describe NotificationService, services: true do
should_not_email
(
issue
.
assignee
)
should_not_email
(
issue
.
assignee
)
should_not_email
(
issue
.
author
)
should_not_email
(
issue
.
author
)
should_not_email
(
@u_watcher
)
should_not_email
(
@u_watcher
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
@u_participant_mentioned
)
should_not_email
(
@u_participant_mentioned
)
should_not_email
(
@subscriber
)
should_not_email
(
@subscriber
)
should_not_email
(
@watcher_and_subscriber
)
should_not_email
(
@watcher_and_subscriber
)
...
@@ -459,6 +472,7 @@ describe NotificationService, services: true do
...
@@ -459,6 +472,7 @@ describe NotificationService, services: true do
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
issue
.
author
)
should_email
(
issue
.
author
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
...
@@ -475,6 +489,7 @@ describe NotificationService, services: true do
...
@@ -475,6 +489,7 @@ describe NotificationService, services: true do
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
should_email
(
issue
.
author
)
should_email
(
issue
.
author
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
...
@@ -502,6 +517,7 @@ describe NotificationService, services: true do
...
@@ -502,6 +517,7 @@ describe NotificationService, services: true do
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_guest_watcher
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
end
end
...
@@ -525,6 +541,7 @@ describe NotificationService, services: true do
...
@@ -525,6 +541,7 @@ describe NotificationService, services: true do
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@u_guest_watcher
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
...
@@ -566,6 +583,7 @@ describe NotificationService, services: true do
...
@@ -566,6 +583,7 @@ describe NotificationService, services: true do
should_email
(
merge_request
.
assignee
)
should_email
(
merge_request
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
...
@@ -584,6 +602,7 @@ describe NotificationService, services: true do
...
@@ -584,6 +602,7 @@ describe NotificationService, services: true do
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@u_guest_watcher
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
...
@@ -599,6 +618,7 @@ describe NotificationService, services: true do
...
@@ -599,6 +618,7 @@ describe NotificationService, services: true do
should_email
(
@u_participant_mentioned
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@u_guest_watcher
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
...
@@ -620,6 +640,7 @@ describe NotificationService, services: true do
...
@@ -620,6 +640,7 @@ describe NotificationService, services: true do
should_email
(
@u_watcher
)
should_email
(
@u_watcher
)
should_email
(
@u_participating
)
should_email
(
@u_participating
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
end
end
end
end
...
@@ -635,6 +656,8 @@ describe NotificationService, services: true do
...
@@ -635,6 +656,8 @@ describe NotificationService, services: true do
@u_not_mentioned
=
create
(
:user
,
username:
'regular'
,
notification_level: :participating
)
@u_not_mentioned
=
create
(
:user
,
username:
'regular'
,
notification_level: :participating
)
@u_outsider_mentioned
=
create
(
:user
,
username:
'outsider'
)
@u_outsider_mentioned
=
create
(
:user
,
username:
'outsider'
)
create_guest_watcher
project
.
team
<<
[
@u_watcher
,
:master
]
project
.
team
<<
[
@u_watcher
,
:master
]
project
.
team
<<
[
@u_participating
,
:master
]
project
.
team
<<
[
@u_participating
,
:master
]
project
.
team
<<
[
@u_participant_mentioned
,
:master
]
project
.
team
<<
[
@u_participant_mentioned
,
:master
]
...
@@ -644,6 +667,13 @@ describe NotificationService, services: true do
...
@@ -644,6 +667,13 @@ describe NotificationService, services: true do
project
.
team
<<
[
@u_not_mentioned
,
:master
]
project
.
team
<<
[
@u_not_mentioned
,
:master
]
end
end
def
create_guest_watcher
@u_guest_watcher
=
create
(
:user
,
username:
'guest_watching'
)
setting
=
@u_guest_watcher
.
notification_settings_for
(
project
)
setting
.
level
=
:watch
setting
.
save
end
def
add_users_with_subscription
(
project
,
issuable
)
def
add_users_with_subscription
(
project
,
issuable
)
@subscriber
=
create
:user
@subscriber
=
create
:user
@unsubscriber
=
create
:user
@unsubscriber
=
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