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
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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
10 deletions
+9
-10
notification_settings_controller.rb
app/controllers/groups/notification_settings_controller.rb
+1
-1
notification_settings_controller.rb
app/controllers/projects/notification_settings_controller.rb
+3
-4
member.rb
app/models/member.rb
+1
-1
notification_service.rb
app/services/notification_service.rb
+2
-2
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