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
Boxiang Sun
gitlab-ce
Commits
c2c7014e
Commit
c2c7014e
authored
May 06, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve documentation and add changelog
parent
07ff874f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-5
app/models/user.rb
app/models/user.rb
+3
-4
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+29
-1
No files found.
app/controllers/projects_controller.rb
View file @
c2c7014e
...
@@ -101,11 +101,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -101,11 +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
if
can?
(
current_user
,
:read_project
,
@project
)
@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?
...
...
app/models/user.rb
View file @
c2c7014e
...
@@ -777,11 +777,10 @@ class User < ActiveRecord::Base
...
@@ -777,11 +777,10 @@ class User < ActiveRecord::Base
end
end
def
notification_settings_for
(
source
)
def
notification_settings_for
(
source
)
notification_setting
=
notification_settings
.
find_or_initialize_by
(
{
source:
source
}
)
notification_setting
=
notification_settings
.
find_or_initialize_by
(
source:
source
)
if
source
.
is_a?
(
Project
)
if
source
.
is_a?
(
Project
)
&&
!
source
.
team
.
member?
(
id
)
&&
!
notification_setting
.
persisted?
membership
=
source
.
team
.
find_member
(
self
.
id
)
notification_setting
.
level
=
:disabled
notification_setting
.
level
=
:disabled
unless
membership
.
present?
||
notification_setting
.
persisted?
end
end
notification_setting
notification_setting
...
...
spec/services/notification_service_spec.rb
View file @
c2c7014e
...
@@ -106,6 +106,35 @@ describe NotificationService, services: true do
...
@@ -106,6 +106,35 @@ describe NotificationService, services: true do
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
end
end
end
end
context
'when user is not project member'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignee:
create
(
:user
))
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project_id:
issue
.
project_id
,
note:
'anything'
)
}
before
{
ActionMailer
::
Base
.
deliveries
.
clear
}
context
"and has notification setting"
do
before
do
setting
=
user
.
notification_settings_for
(
project
)
setting
.
level
=
:watch
setting
.
save
end
it
"sends user email"
do
notification
.
new_note
(
note
)
should_email
(
user
)
end
end
context
"and does note have notification setting"
do
it
"does not send email"
do
notification
.
new_note
(
note
)
should_not_email
(
user
)
end
end
end
end
end
context
'confidential issue note'
do
context
'confidential issue note'
do
...
@@ -147,7 +176,6 @@ describe NotificationService, services: true do
...
@@ -147,7 +176,6 @@ describe NotificationService, services: true do
before
do
before
do
build_team
(
note
.
project
)
build_team
(
note
.
project
)
note
.
project
.
team
<<
[[
note
.
author
,
note
.
noteable
.
author
,
note
.
noteable
.
assignee
],
:master
]
note
.
project
.
team
<<
[[
note
.
author
,
note
.
noteable
.
author
,
note
.
noteable
.
assignee
],
:master
]
ActionMailer
::
Base
.
deliveries
.
clear
ActionMailer
::
Base
.
deliveries
.
clear
end
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