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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
4558b5b9
Commit
4558b5b9
authored
May 11, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate feedback
parent
2f0d89ec
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
23 additions
and
97 deletions
+23
-97
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+5
-5
app/models/note.rb
app/models/note.rb
+0
-4
app/models/user.rb
app/models/user.rb
+1
-1
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-1
app/services/toggle_award_emoji_service.rb
app/services/toggle_award_emoji_service.rb
+0
-12
app/views/award_emoji/_awards_block.html.haml
app/views/award_emoji/_awards_block.html.haml
+2
-2
app/views/projects/issues/_issue.html.haml
app/views/projects/issues/_issue.html.haml
+4
-10
app/views/projects/merge_requests/_merge_request.html.haml
app/views/projects/merge_requests/_merge_request.html.haml
+4
-10
db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
...grate/20160416182152_convert_award_note_to_emoji_award.rb
+0
-10
lib/api/entities.rb
lib/api/entities.rb
+1
-2
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+3
-3
spec/features/issues/award_emoji_spec.rb
spec/features/issues/award_emoji_spec.rb
+0
-2
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+2
-33
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+0
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+0
-1
No files found.
app/models/concerns/awardable.rb
View file @
4558b5b9
...
...
@@ -34,23 +34,23 @@ module Awardable
end
end
def
grouped_awards
(
with_thumbs
=
true
)
def
grouped_awards
(
with_thumbs
:
true
)
awards
=
award_emoji
.
group_by
(
&
:name
)
if
with_thumbs
awards
[
AwardEmoji
::
UPVOTE_NAME
]
||=
AwardEmoji
.
none
awards
[
AwardEmoji
::
DOWNVOTE_NAME
]
||=
AwardEmoji
.
none
awards
[
AwardEmoji
::
UPVOTE_NAME
]
||=
[]
awards
[
AwardEmoji
::
DOWNVOTE_NAME
]
||=
[]
end
awards
end
def
downvotes
award_emoji
.
where
(
name:
AwardEmoji
::
DOWNVOTE_NAME
)
.
count
award_emoji
.
downvotes
.
count
end
def
upvotes
award_emoji
.
where
(
name:
AwardEmoji
::
UPVOTE_NAME
)
.
count
award_emoji
.
upvotes
.
count
end
def
emoji_awardable?
...
...
app/models/note.rb
View file @
4558b5b9
...
...
@@ -323,10 +323,6 @@ class Note < ActiveRecord::Base
award_emoji_supported?
&&
contains_emoji_only?
end
def
create_award_emoji
self
.
noteable
.
award_emoji
(
award_emoji_name
,
author
)
end
def
clear_blank_line_code!
self
.
line_code
=
nil
if
self
.
line_code
.
blank?
end
...
...
app/models/user.rb
View file @
4558b5b9
...
...
@@ -79,7 +79,7 @@ class User < ActiveRecord::Base
has_many
:builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
has_many
:todos
,
dependent: :destroy
has_many
:notification_settings
,
dependent: :destroy
has_many
:award_emoji
,
as: :awardable
,
dependent: :destroy
has_many
:award_emoji
,
as: :awardable
,
dependent: :destroy
#
# Validations
...
...
app/services/notes/create_service.rb
View file @
4558b5b9
...
...
@@ -7,7 +7,7 @@ module Notes
if
note
.
award_emoji?
return
ToggleAwardEmojiService
.
new
(
project
,
current_user
,
params
).
execute
(
note
.
noteabl
e
,
note
.
note
)
execute
(
note
.
award_emoji_nam
e
,
note
.
note
)
end
return
unless
valid_project?
(
note
)
...
...
app/services/toggle_award_emoji_service.rb
View file @
4558b5b9
require_relative
'base_service'
class
ToggleAwardEmojiService
<
BaseService
# For an award emoji being posted we should:
# - Mark the TODO as done for this issuable (skip on snippets)
# - Save the award emoji
def
execute
(
awardable
,
emoji
)
todo_service
.
new_award_emoji
(
awardable
,
current_user
)
# Needed if its posted as a note containing only :+1:
emoji
=
award_emoji_name
(
emoji
)
if
emoji
.
start_with?
':'
awardable
.
toggle_award_emoji
(
emoji
,
current_user
)
end
private
def
award_emoji_name
(
emoji
)
original_name
=
emoji
.
match
(
Banzai
::
Filter
::
EmojiFilter
.
emoji_pattern
)[
1
]
Gitlab
::
AwardEmoji
.
normalize_emoji_name
(
original_name
)
end
end
app/views/award_emoji/_awards_block.html.haml
View file @
4558b5b9
-
grouped_emojis
=
awardable
.
grouped_awards
(
inline
)
-
grouped_emojis
=
awardable
.
grouped_awards
(
with_thumbs:
inline
)
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
size
==
0
),
data:
{
award_url:
url_for
([
:toggle_award_emoji
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
awardable
])
}
}
-
awards_sort
(
grouped_emojis
).
each
do
|
emoji
,
awards
|
%button
.btn.award-control.js-emoji-btn.has-tooltip
{
type:
"button"
,
class:
(
award_active_class
(
awards
,
current_user
)),
data:
{
placement:
"bottom"
,
original_title:
award_user_list
(
awards
,
current_user
)
}
}
%button
.btn.award-control.js-emoji-btn.has-tooltip
{
type:
"button"
,
class:
(
award_active_class
(
awards
,
current_user
)),
data:
{
placement:
"bottom"
,
title:
award_user_list
(
awards
,
current_user
)
}
}
=
emoji_icon
(
emoji
)
%span
.award-control-text.js-counter
=
awards
.
count
...
...
app/views/projects/issues/_issue.html.haml
View file @
4558b5b9
...
...
@@ -28,16 +28,10 @@
=
downvotes
-
note_count
=
issue
.
notes
.
user
.
count
-
if
note_count
>
0
%li
=
link_to
issue_path
(
issue
)
+
"#notes"
do
=
icon
(
'comments'
)
=
note_count
-
else
%li
=
link_to
issue_path
(
issue
)
+
"#notes"
,
class:
"issue-no-comments"
do
=
icon
(
'comments'
)
=
note_count
%li
=
link_to
issue_path
(
issue
,
anchor:
'notes'
),
class:
(
'issue-no-comments'
if
note_count
.
zero?
)
do
=
icon
(
'comments'
)
=
note_count
.issue-info
#{
issue
.
to_reference
}
·
...
...
app/views/projects/merge_requests/_merge_request.html.haml
View file @
4558b5b9
...
...
@@ -36,16 +36,10 @@
=
downvotes
-
note_count
=
merge_request
.
mr_and_commit_notes
.
user
.
count
-
if
note_count
>
0
%li
=
link_to
merge_request_path
(
merge_request
)
+
"#notes"
do
=
icon
(
'comments'
)
=
note_count
-
else
%li
=
link_to
merge_request_path
(
merge_request
)
+
"#notes"
,
class:
"merge-request-no-comments"
do
=
icon
(
'comments'
)
=
note_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
.merge-request-info
#{
merge_request
.
to_reference
}
·
...
...
db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
View file @
4558b5b9
...
...
@@ -3,15 +3,5 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration
def
up
execute
"INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true)"
end
def
down
execute
<<-
SQL
INSERT INTO notes (noteable_type, noteable_id, author_id, note, created_at, updated_at, is_award)
(SELECT awardable_type, awardable_id, user_id, name, created_at, updated_at, TRUE
FROM award_emoji
WHERE awardable_type IN ('Issue', 'MergeRequest')
)
SQL
end
end
end
lib/api/entities.rb
View file @
4558b5b9
...
...
@@ -174,7 +174,7 @@ module API
expose
:subscribed
do
|
issue
,
options
|
issue
.
subscribed?
(
options
[
:current_user
])
end
expose
:u
ser_notes_count
expose
:u
pvotes
,
:downvotes
end
class
MergeRequest
<
ProjectEntity
...
...
@@ -191,7 +191,6 @@ module API
expose
:subscribed
do
|
merge_request
,
options
|
merge_request
.
subscribed?
(
options
[
:current_user
])
end
expose
:user_notes_count
end
class
MergeRequestChanges
<
MergeRequest
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
4558b5b9
...
...
@@ -257,9 +257,9 @@ describe Projects::IssuesController do
project
.
team
<<
[
user
,
:developer
]
end
it
"
yields status code 200
"
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
it
"
toggles the award emoji
"
do
expect
{
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
}.
to
change
{
AwardEmoji
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
spec/features/issues/award_emoji_spec.rb
View file @
4558b5b9
...
...
@@ -28,7 +28,6 @@ describe 'Awards Emoji', feature: true do
end
context
'click the thumbsup emoji'
do
it
'should increment the thumbsup emoji'
,
js:
true
do
find
(
'[data-emoji="thumbsup"]'
).
click
sleep
2
...
...
@@ -41,7 +40,6 @@ describe 'Awards Emoji', feature: true do
end
context
'click the thumbsdown emoji'
do
it
'should increment the thumbsdown emoji'
,
js:
true
do
find
(
'[data-emoji="thumbsdown"]'
).
click
sleep
2
...
...
spec/models/concerns/issuable_spec.rb
View file @
4558b5b9
...
...
@@ -203,11 +203,10 @@ describe Issue, "Issuable" do
end
end
# TODO ZJ
describe
"votes"
do
before
do
create
!
(
:award_emoji
,
:upvote
,
awardable:
issue
)
create
!
(
:award_emoji
,
:downvote
,
awardable:
issue
)
create
(
:award_emoji
,
:upvote
,
awardable:
issue
)
create
(
:award_emoji
,
:downvote
,
awardable:
issue
)
end
it
"returns correct values"
do
...
...
@@ -215,34 +214,4 @@ describe Issue, "Issuable" do
expect
(
issue
.
downvotes
).
to
eq
(
1
)
end
end
describe
".with_label"
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
let
(
:feature
)
{
create
(
:label
,
project:
project
,
title:
'feature'
)
}
let
(
:enhancement
)
{
create
(
:label
,
project:
project
,
title:
'enhancement'
)
}
let
(
:issue1
)
{
create
(
:issue
,
title:
"Bugfix1"
,
project:
project
)
}
let
(
:issue2
)
{
create
(
:issue
,
title:
"Bugfix2"
,
project:
project
)
}
let
(
:issue3
)
{
create
(
:issue
,
title:
"Feature1"
,
project:
project
)
}
before
(
:each
)
do
issue1
.
labels
<<
bug
issue1
.
labels
<<
feature
issue2
.
labels
<<
bug
issue2
.
labels
<<
enhancement
issue3
.
labels
<<
feature
end
it
'finds the correct issue containing just enhancement label'
do
expect
(
Issue
.
with_label
(
enhancement
.
title
)).
to
match_array
([
issue2
])
end
it
'finds the correct issues containing the same label'
do
expect
(
Issue
.
with_label
(
bug
.
title
)).
to
match_array
([
issue1
,
issue2
])
end
it
'finds the correct issues containing only both labels'
do
expect
(
Issue
.
with_label
([
bug
.
title
,
enhancement
.
title
])).
to
match_array
([
issue2
])
end
end
end
spec/requests/api/issues_spec.rb
View file @
4558b5b9
...
...
@@ -249,7 +249,6 @@ describe API::API, api: true do
expect
(
json_response
[
'milestone'
]).
to
be_a
Hash
expect
(
json_response
[
'assignee'
]).
to
be_a
Hash
expect
(
json_response
[
'author'
]).
to
be_a
Hash
expect
(
json_response
[
'user_notes_count'
]).
to
be
(
1
)
end
it
"should return a project issue by id"
do
...
...
spec/requests/api/merge_requests_spec.rb
View file @
4558b5b9
...
...
@@ -138,7 +138,6 @@ describe API::API, api: true do
expect
(
json_response
[
'work_in_progress'
]).
to
be_falsy
expect
(
json_response
[
'merge_when_build_succeeds'
]).
to
be_falsy
expect
(
json_response
[
'merge_status'
]).
to
eq
(
'can_be_merged'
)
expect
(
json_response
[
'user_notes_count'
]).
to
be
(
2
)
end
it
"should return merge_request"
do
...
...
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