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
23c5473c
Commit
23c5473c
authored
Nov 19, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added spinach tests
parent
2c7d8678
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
96 deletions
+83
-96
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+2
-2
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+5
-1
app/models/note.rb
app/models/note.rb
+1
-0
app/views/votes/_votes_block.html.haml
app/views/votes/_votes_block.html.haml
+20
-18
features/project/issues/award_emoji.feature
features/project/issues/award_emoji.feature
+14
-0
features/steps/project/issues/award_emoji.rb
features/steps/project/issues/award_emoji.rb
+41
-0
spec/models/note_spec.rb
spec/models/note_spec.rb
+0
-75
No files found.
app/assets/javascripts/awards_handler.coffee
View file @
23c5473c
...
@@ -75,7 +75,7 @@ class @AwardsHandler
...
@@ -75,7 +75,7 @@ class @AwardsHandler
if
custom_path
if
custom_path
$
(
".awards-menu li"
).
first
().
html
().
replace
(
/emoji\/.*\.png/
,
custom_path
)
$
(
".awards-menu li"
).
first
().
html
().
replace
(
/emoji\/.*\.png/
,
custom_path
)
else
else
$
(
"li[data-emoji='"
+
emoji
+
"'"
).
html
()
$
(
"li[data-emoji='"
+
emoji
+
"'
]
"
).
html
()
postEmoji
:
(
emoji
,
callback
)
->
postEmoji
:
(
emoji
,
callback
)
->
...
@@ -88,4 +88,4 @@ class @AwardsHandler
...
@@ -88,4 +88,4 @@ class @AwardsHandler
callback
.
call
()
callback
.
call
()
findEmojiIcon
:
(
emoji
)
->
findEmojiIcon
:
(
emoji
)
->
$
(
".icon[data-emoji='"
+
emoji
+
"'"
)
$
(
".icon[data-emoji='"
+
emoji
+
"']"
)
\ No newline at end of file
\ No newline at end of file
app/helpers/issues_helper.rb
View file @
23c5473c
...
@@ -105,7 +105,11 @@ module IssuesHelper
...
@@ -105,7 +105,11 @@ module IssuesHelper
end
end
def
note_active_class
(
notes
,
current_user
)
def
note_active_class
(
notes
,
current_user
)
notes
.
pluck
(
:author_id
).
include?
(
current_user
.
id
)
?
"active"
:
""
if
current_user
&&
notes
.
pluck
(
:author_id
).
include?
(
current_user
.
id
)
"active"
else
""
end
end
end
# Required for Gitlab::Markdown::IssueReferenceFilter
# Required for Gitlab::Markdown::IssueReferenceFilter
...
...
app/models/note.rb
View file @
23c5473c
...
@@ -46,6 +46,7 @@ class Note < ActiveRecord::Base
...
@@ -46,6 +46,7 @@ class Note < ActiveRecord::Base
validates
:noteable_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
.
present?
&&
n
.
noteable_type
!=
'Commit'
}
validates
:noteable_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
.
present?
&&
n
.
noteable_type
!=
'Commit'
}
validates
:commit_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
==
'Commit'
}
validates
:commit_id
,
presence:
true
,
if:
->
(
n
)
{
n
.
noteable_type
==
'Commit'
}
validates
:author
,
presence:
true
,
if:
->
(
n
)
{
n
.
is_award
}
mount_uploader
:attachment
,
AttachmentUploader
mount_uploader
:attachment
,
AttachmentUploader
...
...
app/views/votes/_votes_block.html.haml
View file @
23c5473c
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
.counter
.counter
=
note
.
last
.
count
=
note
.
last
.
count
-
if
current_user
.dropdown.awards-controls
.dropdown.awards-controls
%a
.add-award
{
"data-toggle"
=>
"dropdown"
,
"data-target"
=>
"#"
,
"href"
=>
"#"
}
%a
.add-award
{
"data-toggle"
=>
"dropdown"
,
"data-target"
=>
"#"
,
"href"
=>
"#"
}
=
icon
(
'plus-square-o'
)
=
icon
(
'plus-square-o'
)
...
@@ -13,7 +14,8 @@
...
@@ -13,7 +14,8 @@
-
emoji_list
.
each
do
|
emoji
|
-
emoji_list
.
each
do
|
emoji
|
%li
{
"data-emoji"
=>
"#{emoji}"
}=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
%li
{
"data-emoji"
=>
"#{emoji}"
}=
image_tag
url_to_emoji
(
emoji
),
height:
"20px"
,
width:
"20px"
:coffeescript
-
if
current_user
:coffeescript
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
noteable_type = "
#{
votable
.
class
}
"
noteable_type = "
#{
votable
.
class
}
"
noteable_id = "
#{
votable
.
id
}
"
noteable_id = "
#{
votable
.
id
}
"
...
...
features/project/issues/award_emoji.feature
0 → 100644
View file @
23c5473c
Feature
:
Award Emoji
Background
:
Given
I sign in as a user
And
I own project
"Shop"
And
project
"Shop"
has issue
"Bugfix"
And
I visit
"Bugfix"
issue page
@javascript
Scenario
:
I
add and remove award in the issue
Given
I click to emoji-picker
And
I click to emoji in the picker
Then
I have award added
And
I can remove it by clicking to icon
\ No newline at end of file
features/steps/project/issues/award_emoji.rb
0 → 100644
View file @
23c5473c
class
Spinach::Features::AwardEmoji
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedProject
include
SharedPaths
include
Select2Helper
step
'I visit "Bugfix" issue page'
do
visit
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
)
end
step
'I click to emoji-picker'
do
page
.
within
".awards-controls"
do
page
.
find
(
".add-award"
).
click
end
end
step
'I click to emoji in the picker'
do
page
.
within
".awards-menu"
do
page
.
first
(
"img"
).
click
end
end
step
'I can remove it by clicking to icon'
do
page
.
within
".awards"
do
page
.
first
(
".award"
).
click
expect
(
page
).
to_not
have_selector
".award"
end
end
step
'I have award added'
do
page
.
within
".awards"
do
expect
(
page
).
to
have_selector
".award"
expect
(
page
.
find
(
".award .counter"
)).
to
have_content
"1"
end
end
step
'project "Shop" has issue "Bugfix"'
do
@project
=
Project
.
find_by
(
name:
"Shop"
)
@issue
=
create
(
:issue
,
title:
"Bugfix"
,
project:
project
)
end
end
spec/models/note_spec.rb
View file @
23c5473c
...
@@ -32,77 +32,6 @@ describe Note do
...
@@ -32,77 +32,6 @@ describe Note do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
end
end
describe
'#votable?'
do
it
'is true for issue notes'
do
note
=
build
(
:note_on_issue
)
expect
(
note
).
to
be_votable
end
it
'is true for merge request notes'
do
note
=
build
(
:note_on_merge_request
)
expect
(
note
).
to
be_votable
end
it
'is false for merge request diff notes'
do
note
=
build
(
:note_on_merge_request_diff
)
expect
(
note
).
not_to
be_votable
end
it
'is false for commit notes'
do
note
=
build
(
:note_on_commit
)
expect
(
note
).
not_to
be_votable
end
it
'is false for commit diff notes'
do
note
=
build
(
:note_on_commit_diff
)
expect
(
note
).
not_to
be_votable
end
end
describe
'voting score'
do
it
'recognizes a neutral note'
do
note
=
build
(
:votable_note
,
note:
'This is not a +1 note'
)
expect
(
note
).
not_to
be_upvote
expect
(
note
).
not_to
be_downvote
end
it
'recognizes a neutral emoji note'
do
note
=
build
(
:votable_note
,
note:
"I would :+1: this, but I don't want to"
)
expect
(
note
).
not_to
be_upvote
expect
(
note
).
not_to
be_downvote
end
it
'recognizes a +1 note'
do
note
=
build
(
:votable_note
,
note:
'+1 for this'
)
expect
(
note
).
to
be_upvote
end
it
'recognizes a +1 emoji as a vote'
do
note
=
build
(
:votable_note
,
note:
':+1: for this'
)
expect
(
note
).
to
be_upvote
end
it
'recognizes a thumbsup emoji as a vote'
do
note
=
build
(
:votable_note
,
note:
':thumbsup: for this'
)
expect
(
note
).
to
be_upvote
end
it
'recognizes a -1 note'
do
note
=
build
(
:votable_note
,
note:
'-1 for this'
)
expect
(
note
).
to
be_downvote
end
it
'recognizes a -1 emoji as a vote'
do
note
=
build
(
:votable_note
,
note:
':-1: for this'
)
expect
(
note
).
to
be_downvote
end
it
'recognizes a thumbsdown emoji as a vote'
do
note
=
build
(
:votable_note
,
note:
':thumbsdown: for this'
)
expect
(
note
).
to
be_downvote
end
end
describe
"Commit notes"
do
describe
"Commit notes"
do
let!
(
:note
)
{
create
(
:note_on_commit
,
note:
"+1 from me"
)
}
let!
(
:note
)
{
create
(
:note_on_commit
,
note:
"+1 from me"
)
}
let!
(
:commit
)
{
note
.
noteable
}
let!
(
:commit
)
{
note
.
noteable
}
...
@@ -139,10 +68,6 @@ describe Note do
...
@@ -139,10 +68,6 @@ describe Note do
it
"should be recognized by #for_commit_diff_line?"
do
it
"should be recognized by #for_commit_diff_line?"
do
expect
(
note
).
to
be_for_commit_diff_line
expect
(
note
).
to
be_for_commit_diff_line
end
end
it
"should not be votable"
do
expect
(
note
).
not_to
be_votable
end
end
end
describe
'authorization'
do
describe
'authorization'
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