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
91a7b933
Commit
91a7b933
authored
Jun 01, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorportate feedback
parent
cbd7801b
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
52 additions
and
149 deletions
+52
-149
issuable.rb
app/models/concerns/issuable.rb
+4
-0
legacy_diff_note.rb
app/models/legacy_diff_note.rb
+4
-0
note.rb
app/models/note.rb
+2
-14
post_process_service.rb
app/services/notes/post_process_service.rb
+1
-1
notification_service.rb
app/services/notification_service.rb
+1
-1
_awards_block.html.haml
app/views/award_emoji/_awards_block.html.haml
+4
-4
_awards_block.html.haml
app/views/emoji_awards/_awards_block.html.haml
+0
-18
routes.rb
config/routes.rb
+0
-1
20160416180807_add_award_emoji.rb
db/migrate/20160416180807_add_award_emoji.rb
+1
-2
20160416182152_convert_award_note_to_emoji_award.rb
...grate/20160416182152_convert_award_note_to_emoji_award.rb
+2
-0
schema.rb
db/schema.rb
+1
-2
merge_requests.rb
features/steps/project/merge_requests.rb
+1
-1
entities.rb
lib/api/entities.rb
+2
-0
award_emoji.rb
lib/gitlab/award_emoji.rb
+10
-8
groups_controller_spec.rb
spec/controllers/groups_controller_spec.rb
+2
-2
issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+3
-3
award_emoji.rb
spec/factories/award_emoji.rb
+0
-6
award_spec.rb
spec/features/issues/award_spec.rb
+6
-29
award_spec.rb
spec/features/merge_requests/award_spec.rb
+7
-30
notes_on_merge_requests_spec.rb
spec/features/notes_on_merge_requests_spec.rb
+0
-25
award_emoji_spec.rb
spec/models/award_emoji_spec.rb
+1
-2
No files found.
app/models/concerns/issuable.rb
View file @
91a7b933
...
...
@@ -133,6 +133,10 @@ module Issuable
opened?
||
reopened?
end
def
user_notes_count
notes
.
user
.
count
end
def
subscribed_without_subscriptions?
(
user
)
participants
(
user
).
include?
(
user
)
end
...
...
app/models/legacy_diff_note.rb
View file @
91a7b933
...
...
@@ -110,6 +110,10 @@ class LegacyDiffNote < Note
@active
end
def
award_emoji_supported?
false
end
private
def
find_diff
...
...
app/models/note.rb
View file @
91a7b933
...
...
@@ -21,10 +21,8 @@ class Note < ActiveRecord::Base
delegate
:name
,
:email
,
to: :author
,
prefix:
true
delegate
:title
,
to: :noteable
,
allow_nil:
true
before_validation
:clear_blank_line_code!
validates
:note
,
:project
,
presence:
true
validates
:line_code
,
line_code:
true
,
allow_blank:
true
# Attachments are deprecated and are handled by Markdown uploader
validates
:attachment
,
file_size:
{
maximum: :max_attachment_size
}
...
...
@@ -173,10 +171,6 @@ class Note < ActiveRecord::Base
Event
.
reset_event_cache_for
(
self
)
end
def
system?
read_attribute
(
:system
)
end
def
editable?
!
system
?
end
...
...
@@ -193,14 +187,8 @@ class Note < ActiveRecord::Base
self
.
line_code
=
nil
if
self
.
line_code
.
blank?
end
# Find the diff on noteable that matches our own
def
find_noteable_diff
diffs
=
noteable
.
diffs
(
Commit
.
max_diff_options
)
diffs
.
find
{
|
d
|
d
.
new_path
==
self
.
diff
.
new_path
}
end
def
award_emoji_supported?
noteable
.
is_a?
(
Awardable
)
&&
!
line_code
.
present?
noteable
.
is_a?
(
Awardable
)
end
def
contains_emoji_only?
...
...
app/services/notes/post_process_service.rb
View file @
91a7b933
...
...
@@ -8,7 +8,7 @@ module Notes
def
execute
# Skip system notes, like status changes and cross-references and awards
unless
@note
.
system
unless
@note
.
system
?
EventCreateService
.
new
.
leave_note
(
@note
,
@note
.
author
)
@note
.
create_cross_references!
execute_note_hooks
...
...
app/services/notification_service.rb
View file @
91a7b933
...
...
@@ -130,7 +130,7 @@ class NotificationService
# ignore gitlab service messages
return
true
if
note
.
note
.
start_with?
(
'Status changed to closed'
)
return
true
if
note
.
cross_reference?
&&
note
.
system
==
true
return
true
if
note
.
cross_reference?
&&
note
.
system
?
target
=
note
.
noteable
...
...
app/views/award_emoji/_awards_block.html.haml
View file @
91a7b933
-
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.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
empty?
),
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"
,
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
...
...
@@ -12,7 +12,7 @@
.award-menu-holder.js-award-holder
%button
.btn.award-control.js-add-award
{
type:
"button"
,
data:
{
award_menu_url:
emojis_path
}
}
=
icon
(
'smile-o'
,
{
class:
"award-control-icon award-control-icon-normal"
}
)
=
icon
(
'spinner spin'
,
{
class:
"award-control-icon award-control-icon-loading"
}
)
=
icon
(
'smile-o'
,
class:
"award-control-icon award-control-icon-normal"
)
=
icon
(
'spinner spin'
,
class:
"award-control-icon award-control-icon-loading"
)
%span
.award-control-text
Add
app/views/emoji_awards/_awards_block.html.haml
deleted
100644 → 0
View file @
cbd7801b
-
grouped_emojis
=
awardable
.
grouped_awards
(
inline
)
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
size
==
0
),
data:
{
award_url:
url_for
([
:toggle_emoji_award
,
@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
)),
title:
award_user_list
(
awards
,
current_user
),
data:
{
placement:
"bottom"
}
}
=
emoji_icon
(
emoji
)
%span
.award-control-text.js-counter
=
awards
.
count
-
if
current_user
:javascript
gl
.
awardMenuUrl
=
emojis_path
.award-menu-holder.js-award-holder
%button
.btn.award-control.js-add-award
{
type:
"button"
,
data:
{
award_menu_url:
emojis_path
}
}
=
icon
(
'smile-o'
,
{
class:
"award-control-icon award-control-icon-normal"
})
=
icon
(
'spinner spin'
,
{
class:
"award-control-icon award-control-icon-loading"
})
%span
.award-control-text
Add
config/routes.rb
View file @
91a7b933
...
...
@@ -754,7 +754,6 @@ Rails.application.routes.draw do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
constraints:
{
id:
/\d+/
}
do
member
do
delete
:delete_attachment
post
:toggle_award_emoji
end
end
...
...
db/migrate/20160416180807_add_award_emoji.rb
View file @
91a7b933
...
...
@@ -9,7 +9,6 @@ class AddAwardEmoji < ActiveRecord::Migration
end
add_index
:award_emoji
,
:user_id
add_index
:award_emoji
,
:awardable_type
add_index
:award_emoji
,
:awardable_id
add_index
:award_emoji
,
[
:awardable_type
,
:awardable_id
]
end
end
db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
View file @
91a7b933
...
...
@@ -2,6 +2,8 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration
def
change
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)"
execute
"DELETE FROM notes WHERE is_award = true"
end
end
end
db/schema.rb
View file @
91a7b933
...
...
@@ -108,8 +108,7 @@ ActiveRecord::Schema.define(version: 20160528043124) do
t
.
datetime
"updated_at"
end
add_index
"award_emoji"
,
[
"awardable_id"
],
name:
"index_award_emoji_on_awardable_id"
,
using: :btree
add_index
"award_emoji"
,
[
"awardable_type"
],
name:
"index_award_emoji_on_awardable_type"
,
using: :btree
add_index
"award_emoji"
,
[
"awardable_type"
,
"awardable_id"
],
name:
"index_award_emoji_on_awardable_type_and_awardable_id"
,
using: :btree
add_index
"award_emoji"
,
[
"user_id"
],
name:
"index_award_emoji_on_user_id"
,
using: :btree
create_table
"broadcast_messages"
,
force: :cascade
do
|
t
|
...
...
features/steps/project/merge_requests.rb
View file @
91a7b933
...
...
@@ -186,7 +186,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'merge request "Bug NS-06" have 1 upvote and 2 downvotes'
do
awardable
=
MergeRequest
.
find_by
(
title:
'Bug NS-06'
)
create
(
:award_emoji
,
awardable:
awardable
)
create_list
(
:award_emoji
,
2
,
awardable:
awardable
,
name:
"thumbsdown"
)
create_list
(
:award_emoji
,
2
,
:downvote
,
awardable:
awardable
)
end
step
'The list should be sorted by "Least popular"'
do
...
...
lib/api/entities.rb
View file @
91a7b933
...
...
@@ -175,6 +175,7 @@ module API
expose
:subscribed
do
|
issue
,
options
|
issue
.
subscribed?
(
options
[
:current_user
])
end
expose
:user_notes_count
expose
:upvotes
,
:downvotes
end
...
...
@@ -192,6 +193,7 @@ module API
expose
:subscribed
do
|
merge_request
,
options
|
merge_request
.
subscribed?
(
options
[
:current_user
])
end
expose
:user_notes_count
end
class
MergeRequestChanges
<
MergeRequest
...
...
lib/gitlab/award_emoji.rb
View file @
91a7b933
...
...
@@ -47,17 +47,19 @@ module Gitlab
end
def
self
.
emojis
@emojis
||=
begin
json_path
=
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
,
'index.json'
)
JSON
.
parse
(
File
.
read
(
json_path
))
end
@emojis
||=
begin
json_path
=
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
,
'index.json'
)
JSON
.
parse
(
File
.
read
(
json_path
))
end
end
def
self
.
aliases
@aliases
||=
begin
json_path
=
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
,
'aliases.json'
)
JSON
.
parse
(
File
.
read
(
json_path
))
end
@aliases
||=
begin
json_path
=
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
,
'aliases.json'
)
JSON
.
parse
(
File
.
read
(
json_path
))
end
end
# Returns an Array of Emoji names and their asset URLs.
...
...
spec/controllers/groups_controller_spec.rb
View file @
91a7b933
...
...
@@ -33,7 +33,7 @@ describe GroupsController do
before
do
create_list
(
:award_emoji
,
3
,
awardable:
issue_2
)
create_list
(
:award_emoji
,
2
,
awardable:
issue_1
)
create_list
(
:award_emoji
,
2
,
awardable:
issue_2
,
name:
"thumbsdown"
)
create_list
(
:award_emoji
,
2
,
:downvote
,
awardable:
issue_2
,
)
sign_in
(
user
)
end
...
...
@@ -58,7 +58,7 @@ describe GroupsController do
before
do
create_list
(
:award_emoji
,
3
,
awardable:
merge_request_2
)
create_list
(
:award_emoji
,
2
,
awardable:
merge_request_1
)
create_list
(
:award_emoji
,
2
,
awardable:
merge_request_2
,
name:
"thumbsdown"
)
create_list
(
:award_emoji
,
2
,
:downvote
,
awardable:
merge_request_2
)
sign_in
(
user
)
end
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
91a7b933
...
...
@@ -258,10 +258,10 @@ describe Projects::IssuesController do
end
it
"toggles the award emoji"
do
expect
do
expect
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
end
.
to
change
{
AwardE
moji
.
count
}.
by
(
1
)
project_id:
project
.
path
,
id:
issue
.
iid
,
name:
"thumbsup"
)
end
.
to
change
{
issue
.
award_e
moji
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
spec/factories/award_emoji.rb
View file @
91a7b933
...
...
@@ -4,13 +4,7 @@ FactoryGirl.define do
user
awardable
factory: :issue
trait
:thumbs_up
trait
:upvote
trait
:thumbs_down
do
name
"thumbsdown"
end
trait
:downvote
do
name
"thumbsdown"
end
...
...
spec/features/issues/award_spec.rb
View file @
91a7b933
...
...
@@ -4,7 +4,6 @@ feature 'Issue awards', js: true, feature: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:note
)
{
create
(
:note_on_issue
,
project:
project
,
noteable:
issue
,
note:
'Looks good!'
)
}
describe
'logged in'
do
before
do
...
...
@@ -16,12 +15,18 @@ feature 'Issue awards', js: true, feature: true do
first
(
'.js-emoji-btn'
).
click
expect
(
page
).
to
have_selector
(
'.js-emoji-btn.active'
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'1'
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'1'
end
it
'should remove award from issue'
do
first
(
'.js-emoji-btn'
).
click
find
(
'.js-emoji-btn.active'
).
click
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'0'
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'0'
end
it
'should only have one menu on the page'
do
...
...
@@ -40,33 +45,5 @@ feature 'Issue awards', js: true, feature: true do
it
'should not see award menu button'
do
expect
(
page
).
not_to
have_selector
(
'.js-award-holder'
)
end
it
'should not see award menu button in note'
do
page
.
within
(
'.note'
)
do
expect
(
page
).
not_to
have_selector
(
'.js-award-action-btn'
)
end
end
end
def
show_note_award_menu
page
.
within
(
'.note'
)
do
find
(
'.js-add-award'
).
click
end
expect
(
page
).
to
have_selector
(
'.emoji-menu'
)
end
def
award_on_note
(
index
=
1
)
page
.
within
(
'.emoji-menu'
)
do
buttons
=
all
(
'.js-emoji-btn'
)
buttons
[
index
].
click
end
end
def
remove_award_on_note
page
.
within
(
'.note'
)
do
page
.
within
(
'.js-awards-block'
)
do
first
(
'.js-emoji-btn'
).
click
end
end
end
end
spec/features/merge_requests/award_spec.rb
View file @
91a7b933
...
...
@@ -3,8 +3,7 @@ require 'rails_helper'
feature
'Merge request awards'
,
js:
true
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
source_project:
project
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
note:
'Looks good!'
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
describe
'logged in'
do
before
do
...
...
@@ -16,12 +15,18 @@ feature 'Merge request awards', js: true, feature: true do
first
(
'.js-emoji-btn'
).
click
expect
(
page
).
to
have_selector
(
'.js-emoji-btn.active'
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'1'
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'1'
end
it
'should remove award from merge request'
do
first
(
'.js-emoji-btn'
).
click
find
(
'.js-emoji-btn.active'
).
click
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'0'
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
first
(
'.js-emoji-btn'
)).
to
have_content
'0'
end
it
'should only have one menu on the page'
do
...
...
@@ -40,33 +45,5 @@ feature 'Merge request awards', js: true, feature: true do
it
'should not see award menu button'
do
expect
(
page
).
not_to
have_selector
(
'.js-award-holder'
)
end
it
'should not see award menu button in note'
do
page
.
within
(
'.note'
)
do
expect
(
page
).
not_to
have_selector
(
'.js-award-action-btn'
)
end
end
end
def
show_note_award_menu
page
.
within
(
'.note'
)
do
find
(
'.js-add-award'
).
click
end
expect
(
page
).
to
have_selector
(
'.emoji-menu'
)
end
def
award_on_note
(
index
=
1
)
page
.
within
(
'.emoji-menu'
)
do
buttons
=
all
(
'.js-emoji-btn'
)
buttons
[
index
].
click
end
end
def
remove_award_on_note
page
.
within
(
'.note'
)
do
page
.
within
(
'.js-awards-block'
)
do
first
(
'.js-emoji-btn'
).
click
end
end
end
end
spec/features/notes_on_merge_requests_spec.rb
View file @
91a7b933
...
...
@@ -4,20 +4,6 @@ describe 'Comments', feature: true do
include
RepoHelpers
include
WaitForAjax
describe
'On merge requests page'
,
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
)
login_as
:admin
visit
namespace_project_merge_requests_path
(
project
.
namespace
,
project
)
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
describe
'On a merge request'
,
js:
true
,
feature:
true
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:merge_request
)
do
...
...
@@ -147,17 +133,6 @@ describe 'Comments', feature: true do
end
end
end
describe
'comment info'
do
it
'excludes award_emoji from comment count'
do
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
1
expect
(
find
(
'.notes-tab span.badge'
).
text
).
to
eq
"1"
end
end
end
describe
'On a merge request diff'
,
js:
true
,
feature:
true
do
...
...
spec/models/award_emoji_spec.rb
View file @
91a7b933
...
...
@@ -14,7 +14,6 @@ describe AwardEmoji, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:awardable
)
}
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_presence_of
(
:awardable
)
}
# To circumvent a bug in the shoulda matchers
describe
"scoped uniqueness validation"
do
...
...
@@ -22,7 +21,7 @@ describe AwardEmoji, models: true do
user
=
create
(
:user
)
issue
=
create
(
:issue
)
create
(
:award_emoji
,
user:
user
,
awardable:
issue
)
new_award
=
AwardEmoji
.
new
(
user:
user
,
awardable:
issue
,
name:
"thumbsup"
)
new_award
=
build
(
:award_emoji
,
user:
user
,
awardable:
issue
)
expect
(
new_award
).
not_to
be_valid
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