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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
378fe076
Commit
378fe076
authored
Oct 11, 2012
by
Robb Kidd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce complexity: replace case statement with method lookup.
parent
baf94bd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
11 deletions
+6
-11
app/observers/note_observer.rb
app/observers/note_observer.rb
+5
-10
spec/observers/note_observer_spec.rb
spec/observers/note_observer_spec.rb
+1
-1
No files found.
app/observers/note_observer.rb
View file @
378fe076
...
...
@@ -16,16 +16,11 @@ class NoteObserver < ActiveRecord::Observer
protected
def
notify_team_of_new_note
(
note
)
team_without_note_author
(
note
).
map
do
|
u
|
case
note
.
noteable_type
when
"Commit"
;
Notify
.
note_commit_email
(
u
.
id
,
note
.
id
).
deliver
when
"Issue"
;
Notify
.
note_issue_email
(
u
.
id
,
note
.
id
).
deliver
when
"Wiki"
;
Notify
.
note_wiki_email
(
u
.
id
,
note
.
id
).
deliver
when
"MergeRequest"
;
Notify
.
note_merge_request_email
(
u
.
id
,
note
.
id
).
deliver
when
"Wall"
;
Notify
.
note_wall_email
(
u
.
id
,
note
.
id
).
deliver
when
"Snippet"
;
true
# no notifications for snippets?
else
true
notify_method
=
'note_'
+
note
.
noteable_type
.
underscore
+
'_email'
if
Notify
.
respond_to?
notify_method
team_without_note_author
(
note
).
map
do
|
u
|
Notify
.
send
(
notify_method
.
to_sym
,
u
.
id
,
note
.
id
).
deliver
end
end
end
...
...
spec/observers/note_observer_spec.rb
View file @
378fe076
...
...
@@ -90,7 +90,7 @@ describe NoteObserver do
it
'does nothing for a new note on a snippet'
do
note
.
stub
(
:noteable_type
).
and_return
(
'Snippet'
)
subject
.
send
(
:notify_team_of_new_note
,
note
).
should
==
[
true
,
true
]
subject
.
send
(
:notify_team_of_new_note
,
note
).
should
be_nil
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