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
iv
gitlab-ce
Commits
e0cabb67
Commit
e0cabb67
authored
May 17, 2016
by
ZJ van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix latests concerns
parent
7a4e7ad0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
23 additions
and
66 deletions
+23
-66
app/controllers/concerns/toggle_award_emoji.rb
app/controllers/concerns/toggle_award_emoji.rb
+2
-0
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+9
-4
app/models/award_emoji.rb
app/models/award_emoji.rb
+0
-9
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+4
-2
app/services/toggle_award_emoji_service.rb
app/services/toggle_award_emoji_service.rb
+0
-9
app/views/projects/merge_requests/_merge_request.html.haml
app/views/projects/merge_requests/_merge_request.html.haml
+3
-3
app/views/projects/merge_requests/_merge_requests.html.haml
app/views/projects/merge_requests/_merge_requests.html.haml
+0
-1
spec/features/notes_on_merge_requests_spec.rb
spec/features/notes_on_merge_requests_spec.rb
+4
-4
spec/services/notes/create_service_spec.rb
spec/services/notes/create_service_spec.rb
+1
-1
spec/services/toggle_award_emoji_service_spec.rb
spec/services/toggle_award_emoji_service_spec.rb
+0
-33
No files found.
app/controllers/concerns/toggle_award_emoji.rb
View file @
e0cabb67
...
...
@@ -7,7 +7,9 @@ module ToggleAwardEmoji
def
toggle_award_emoji
name
=
params
.
require
(
:name
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
TodoService
.
new
.
new_award_emoji
(
awardable
,
current_user
)
render
json:
{
ok:
true
}
end
...
...
app/controllers/projects/notes_controller.rb
View file @
e0cabb67
...
...
@@ -22,10 +22,8 @@ class Projects::NotesController < Projects::ApplicationController
def
create
@note
=
Notes
::
CreateService
.
new
(
project
,
current_user
,
note_params
).
execute
@note
=
@note
.
is_a?
(
AwardEmoji
)
?
@note
.
to_note_json
:
note_json
(
@note
)
respond_to
do
|
format
|
format
.
json
{
render
json:
@note
}
format
.
json
{
render
json:
note_json
(
@note
)
}
format
.
html
{
redirect_back_or_default
}
end
end
...
...
@@ -109,7 +107,14 @@ class Projects::NotesController < Projects::ApplicationController
end
def
note_json
(
note
)
if
note
.
valid?
if
note
.
is_a?
(
AwardEmoji
)
{
valid:
note
.
valid?
,
award:
true
,
id:
note
.
id
,
name:
note
.
name
}
elsif
note
.
valid?
{
valid:
true
,
id:
note
.
id
,
...
...
app/models/award_emoji.rb
View file @
e0cabb67
...
...
@@ -23,13 +23,4 @@ class AwardEmoji < ActiveRecord::Base
def
upvote?
self
.
name
==
UPVOTE_NAME
end
def
to_note_json
{
valid:
valid?
,
award:
true
,
id:
id
,
name:
name
}
end
end
app/services/notes/create_service.rb
View file @
e0cabb67
...
...
@@ -6,8 +6,10 @@ module Notes
note
.
system
=
false
if
note
.
award_emoji?
return
ToggleAwardEmojiService
.
new
(
project
,
current_user
,
params
).
execute
(
note
.
noteable
,
note
.
award_emoji_name
)
noteable
=
note
.
noteable
todo_service
.
new_award_emoji
(
noteable
,
current_user
)
return
noteable
.
create_award_emoji
(
note
.
award_emoji_name
,
current_user
)
end
return
unless
valid_project?
(
note
)
...
...
app/services/toggle_award_emoji_service.rb
deleted
100644 → 0
View file @
7a4e7ad0
require_relative
'base_service'
class
ToggleAwardEmojiService
<
BaseService
def
execute
(
awardable
,
emoji
)
todo_service
.
new_award_emoji
(
awardable
,
current_user
)
awardable
.
toggle_award_emoji
(
emoji
,
current_user
)
end
end
app/views/projects/merge_requests/_merge_request.html.haml
View file @
e0cabb67
...
...
@@ -37,9 +37,9 @@
-
note_count
=
merge_request
.
mr_and_commit_notes
.
user
.
count
%li
=
link_to
merge_request_path
(
merge_request
,
anchor:
'notes'
),
class:
(
'merge-request-no-comments'
if
note_count
.
zero?
)
do
=
icon
(
'comments'
)
=
note_count
=
link_to
merge_request_path
(
merge_request
,
anchor:
'notes'
),
class:
(
'merge-request-no-comments'
if
note_count
.
zero?
)
do
=
icon
(
'comments'
)
=
note_count
.merge-request-info
#{
merge_request
.
to_reference
}
·
...
...
app/views/projects/merge_requests/_merge_requests.html.haml
View file @
e0cabb67
...
...
@@ -6,4 +6,3 @@
-
if
@merge_requests
.
present?
=
paginate
@merge_requests
,
theme:
"gitlab"
spec/features/notes_on_merge_requests_spec.rb
View file @
e0cabb67
...
...
@@ -8,12 +8,12 @@ describe 'Comments', feature: true do
it
'excludes award_emoji from comment count'
do
merge_request
=
create
(
:merge_request
)
project
=
merge_request
.
source_project
create
(
:award_emoji
,
awardable:
merge_request
,
project:
project
)
create
(
:award_emoji
,
awardable:
merge_request
)
login_as
:admin
visit
namespace_project_merge_requests_path
(
project
.
namespace
,
project
)
expect
(
merge_request
.
mr_and_commit_notes
.
count
).
to
eq
1
expect
(
merge_request
.
mr_and_commit_notes
.
count
).
to
eq
0
expect
(
page
.
all
(
'.merge-request-no-comments'
).
first
.
text
).
to
eq
"0"
end
end
...
...
@@ -146,11 +146,11 @@ describe 'Comments', feature: true do
describe
'comment info'
do
it
'excludes award_emoji from comment count'
do
create
(
:award_emoji
,
awardable:
merge_request
,
project:
project
)
create
(
:award_emoji
,
awardable:
merge_request
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
merge_request
.
mr_and_commit_notes
.
count
).
to
eq
2
expect
(
merge_request
.
mr_and_commit_notes
.
count
).
to
eq
1
expect
(
find
(
'.notes-tab span.badge'
).
text
).
to
eq
"1"
end
end
...
...
spec/services/notes/create_service_spec.rb
View file @
e0cabb67
...
...
@@ -59,7 +59,7 @@ describe Notes::CreateService, services: true do
noteable_id:
issue
.
id
}
expect_any_instance_of
(
To
ggleAwardEmojiService
).
to
receive
(
:execute
).
with
(
issue
,
"thumbsup"
)
expect_any_instance_of
(
To
doService
).
to
receive
(
:new_award_emoji
).
with
(
issue
,
user
)
Notes
::
CreateService
.
new
(
project
,
user
,
opts
).
execute
end
...
...
spec/services/toggle_award_emoji_service_spec.rb
deleted
100644 → 0
View file @
7a4e7ad0
require
'spec_helper'
describe
ToggleAwardEmoji
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
before
do
project
.
team
<<
[
user
,
:master
]
end
describe
'#execute'
do
it
'removes related todos'
do
expect_any_instance_of
(
TodoService
).
to
receive
(
:new_award_emoji
).
with
(
issue
,
user
)
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"thumbsdown"
)
end
context
'when the emoji is set'
do
it
'removes the emoji'
do
create
(
:award_emoji
,
awardable:
issue
,
user:
user
)
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"thumbsup"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
-
1
)
end
end
context
'when the award is not set yet'
do
it
'awards the emoji'
do
expect
{
ToggleAwardEmojiService
.
new
(
project
,
user
).
execute
(
issue
,
"thumbsup"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
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