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
3950b8e8
Commit
3950b8e8
authored
Oct 12, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1680 from robbkidd/reduce_note_observer_complexity
Reduce complexity: replace case statement with method lookup.
parents
baf94bd7
378fe076
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
11 deletions
+6
-11
note_observer.rb
app/observers/note_observer.rb
+5
-10
note_observer_spec.rb
spec/observers/note_observer_spec.rb
+1
-1
No files found.
app/observers/note_observer.rb
View file @
3950b8e8
...
...
@@ -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 @
3950b8e8
...
...
@@ -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