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
93a10f17
Commit
93a10f17
authored
Apr 11, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse `User#notification_settings_for` when it's possible
parent
9a44d697
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
10 deletions
+9
-10
app/controllers/groups/notification_settings_controller.rb
app/controllers/groups/notification_settings_controller.rb
+1
-1
app/controllers/projects/notification_settings_controller.rb
app/controllers/projects/notification_settings_controller.rb
+3
-4
app/models/member.rb
app/models/member.rb
+1
-1
app/services/notification_service.rb
app/services/notification_service.rb
+2
-2
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+2
-2
No files found.
app/controllers/groups/notification_settings_controller.rb
View file @
93a10f17
class
Groups::NotificationSettingsController
<
Groups
::
ApplicationController
def
update
notification_setting
=
group
.
notification_settings
.
find_by
(
user_id:
current_user
)
notification_setting
=
current_user
.
notification_settings_for
(
group
)
saved
=
notification_setting
.
update_attributes
(
notification_setting_params
)
render
json:
{
saved:
saved
}
...
...
app/controllers/projects/notification_settings_controller.rb
View file @
93a10f17
class
Projects::NotificationSettingsController
<
Projects
::
ApplicationController
def
create
notification_setting
=
project
.
notification_settings
.
new
(
notification_setting_params
)
notification_setting
.
user
=
current_user
saved
=
notification_setting
.
save
notification_setting
=
current_user
.
notification_settings_for
(
project
)
saved
=
notification_setting
.
update_attributes
(
notification_setting_params
)
render
json:
{
saved:
saved
}
end
def
update
notification_setting
=
project
.
notification_settings
.
find_by
(
user_id:
current_user
)
notification_setting
=
current_user
.
notification_settings_for
(
project
)
saved
=
notification_setting
.
update_attributes
(
notification_setting_params
)
render
json:
{
saved:
saved
}
...
...
app/models/member.rb
View file @
93a10f17
...
...
@@ -167,7 +167,7 @@ class Member < ActiveRecord::Base
end
def
notification_setting
@notification_setting
||=
user
.
notification_settings
.
find_by
(
source:
source
)
@notification_setting
||=
user
.
notification_settings
_for
(
source
)
end
private
...
...
app/services/notification_service.rb
View file @
93a10f17
...
...
@@ -355,10 +355,10 @@ class NotificationService
users
.
reject
do
|
user
|
next
user
.
notification_level
==
level
unless
project
setting
=
user
.
notification_settings
.
find_by
(
source:
project
)
setting
=
user
.
notification_settings
_for
(
project
)
if
!
setting
&&
project
.
group
setting
=
user
.
notification_settings
.
find_by
(
source:
project
.
group
)
setting
=
user
.
notification_settings
_for
(
project
.
group
)
end
# reject users who globally set mention notification and has no setting per project/group
...
...
spec/services/notification_service_spec.rb
View file @
93a10f17
...
...
@@ -89,8 +89,8 @@ describe NotificationService, services: true do
note
.
project
.
group
.
add_user
(
@u_watcher
,
GroupMember
::
MASTER
)
note
.
project
.
save
@u_watcher
.
notification_settings
.
find_by
(
source:
note
.
project
).
participating!
@u_watcher
.
notification_settings
.
find_by
(
source:
note
.
project
.
group
).
global!
@u_watcher
.
notification_settings
_for
(
note
.
project
).
participating!
@u_watcher
.
notification_settings
_for
(
note
.
project
.
group
).
global!
ActionMailer
::
Base
.
deliveries
.
clear
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