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
Jérome Perrin
gitlab-ce
Commits
aba1aa49
Commit
aba1aa49
authored
Feb 19, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve #set_award! on the Note model
parent
11ed1cbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
app/models/note.rb
app/models/note.rb
+1
-4
spec/models/note_spec.rb
spec/models/note_spec.rb
+4
-1
No files found.
app/models/note.rb
View file @
aba1aa49
...
@@ -376,9 +376,6 @@ class Note < ActiveRecord::Base
...
@@ -376,9 +376,6 @@ class Note < ActiveRecord::Base
def
set_award!
def
set_award!
return
unless
awards_supported?
&&
contains_emoji_only?
return
unless
awards_supported?
&&
contains_emoji_only?
# Responding with an emoji is not an award emoji if its on a diff comment
return
if
line_code
self
.
is_award
=
true
self
.
is_award
=
true
self
.
note
=
award_emoji_name
self
.
note
=
award_emoji_name
end
end
...
@@ -386,7 +383,7 @@ class Note < ActiveRecord::Base
...
@@ -386,7 +383,7 @@ class Note < ActiveRecord::Base
private
private
def
awards_supported?
def
awards_supported?
noteable
.
kind_of?
(
Issue
)
||
noteable
.
is_a?
(
MergeRequest
)
(
noteable
.
kind_of?
(
Issue
)
||
noteable
.
is_a?
(
MergeRequest
))
&&
!
for_diff_line?
end
end
def
contains_emoji_only?
def
contains_emoji_only?
...
...
spec/models/note_spec.rb
View file @
aba1aa49
...
@@ -212,7 +212,10 @@ describe Note, models: true do
...
@@ -212,7 +212,10 @@ describe Note, models: true do
it
"is not an award emoji when comment is on a diff"
do
it
"is not an award emoji when comment is on a diff"
do
note
=
create
(
:note
,
note:
":blowfish:"
,
noteable:
merge_request
,
line_code:
"11d5d2e667e9da4f7f610f81d86c974b146b13bd_0_2"
)
note
=
create
(
:note
,
note:
":blowfish:"
,
noteable:
merge_request
,
line_code:
"11d5d2e667e9da4f7f610f81d86c974b146b13bd_0_2"
)
expect
(
note
.
reload
.
note
).
to
eq
(
":blowfish:"
)
note
=
note
.
reload
expect
(
note
.
note
).
to
eq
(
":blowfish:"
)
expect
(
note
.
is_award?
).
to
be_falsy
end
end
end
end
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