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
Tatuya Kamada
gitlab-ce
Commits
9d3186e4
Commit
9d3186e4
authored
Nov 22, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disabled award emoji button when user is not logged in
Closes #24680
parent
0f590750
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
42 deletions
+60
-42
app/views/award_emoji/_awards_block.html.haml
app/views/award_emoji/_awards_block.html.haml
+4
-1
changelogs/unreleased/emoji-btn-disabled.yml
changelogs/unreleased/emoji-btn-disabled.yml
+4
-0
spec/features/issues/award_emoji_spec.rb
spec/features/issues/award_emoji_spec.rb
+52
-41
No files found.
app/views/award_emoji/_awards_block.html.haml
View file @
9d3186e4
-
grouped_emojis
=
awardable
.
grouped_awards
(
with_thumbs:
inline
)
-
grouped_emojis
=
awardable
.
grouped_awards
(
with_thumbs:
inline
)
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
empty?
),
data:
{
award_url:
toggle_award_url
(
awardable
)
}
}
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
empty?
),
data:
{
award_url:
toggle_award_url
(
awardable
)
}
}
-
awards_sort
(
grouped_emojis
).
each
do
|
emoji
,
awards
|
-
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"
,
disabled:
!
current_user
,
class:
(
award_active_class
(
awards
,
current_user
)),
data:
{
placement:
"bottom"
,
title:
award_user_list
(
awards
,
current_user
)
}
}
=
emoji_icon
(
emoji
,
sprite:
false
)
=
emoji_icon
(
emoji
,
sprite:
false
)
%span
.award-control-text.js-counter
%span
.award-control-text.js-counter
=
awards
.
count
=
awards
.
count
...
...
changelogs/unreleased/emoji-btn-disabled.yml
0 → 100644
View file @
9d3186e4
---
title
:
Disabled emoji buttons when user is not logged in
merge_request
:
author
:
spec/features/issues/award_emoji_spec.rb
View file @
9d3186e4
...
@@ -3,72 +3,83 @@ require 'rails_helper'
...
@@ -3,72 +3,83 @@ require 'rails_helper'
describe
'Awards Emoji'
,
feature:
true
do
describe
'Awards Emoji'
,
feature:
true
do
include
WaitForAjax
include
WaitForAjax
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
do
before
do
create
(
:issue
,
project
.
team
<<
[
user
,
:master
]
assignee:
@user
,
login_as
(
user
)
project:
project
)
end
end
describe
'Click award emoji from issue#show'
do
context
'authorized user'
do
let!
(
:issue
)
do
create
(
:issue
,
assignee:
@user
,
project:
project
)
end
let!
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
issue
.
project
,
note:
"Hello world"
)
}
before
do
before
do
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
end
end
it
'increments the thumbsdown emoji'
,
js:
true
do
describe
'Click award emoji from issue#show'
do
find
(
'[data-emoji="thumbsdown"]'
).
click
let!
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
issue
.
project
,
note:
"Hello world"
)
}
wait_for_ajax
expect
(
thumbsdown_emoji
).
to
have_text
(
"1"
)
end
context
'click the thumbsup emoji'
do
before
do
it
'increments the thumbsup emoji'
,
js:
true
do
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
find
(
'[data-emoji="thumbsup"]'
).
click
wait_for_ajax
expect
(
thumbsup_emoji
).
to
have_text
(
"1"
)
end
end
it
'decrements the thumbsdown emoji'
,
js:
true
do
expect
(
thumbsdown_emoji
).
to
have_text
(
"0"
)
end
end
context
'click the thumbsdown emoji'
do
it
'increments the thumbsdown emoji'
,
js:
true
do
it
'increments the thumbsdown emoji'
,
js:
true
do
find
(
'[data-emoji="thumbsdown"]'
).
click
find
(
'[data-emoji="thumbsdown"]'
).
click
wait_for_ajax
wait_for_ajax
expect
(
thumbsdown_emoji
).
to
have_text
(
"1"
)
expect
(
thumbsdown_emoji
).
to
have_text
(
"1"
)
end
end
it
'decrements the thumbsup emoji'
,
js:
true
do
context
'click the thumbsup emoji'
do
expect
(
thumbsup_emoji
).
to
have_text
(
"0"
)
it
'increments the thumbsup emoji'
,
js:
true
do
find
(
'[data-emoji="thumbsup"]'
).
click
wait_for_ajax
expect
(
thumbsup_emoji
).
to
have_text
(
"1"
)
end
it
'decrements the thumbsdown emoji'
,
js:
true
do
expect
(
thumbsdown_emoji
).
to
have_text
(
"0"
)
end
end
end
end
it
'toggles the smiley emoji on a note'
,
js:
true
do
context
'click the thumbsdown emoji'
do
toggle_smiley_emoji
(
true
)
it
'increments the thumbsdown emoji'
,
js:
true
do
find
(
'[data-emoji="thumbsdown"]'
).
click
wait_for_ajax
expect
(
thumbsdown_emoji
).
to
have_text
(
"1"
)
end
within
(
'.note-awards'
)
do
it
'decrements the thumbsup emoji'
,
js:
true
do
expect
(
find
(
emoji_counter
)).
to
have_text
(
"1"
)
expect
(
thumbsup_emoji
).
to
have_text
(
"0"
)
end
end
end
toggle_smiley_emoji
(
false
)
it
'toggles the smiley emoji on a note'
,
js:
true
do
toggle_smiley_emoji
(
true
)
within
(
'.note-awards'
)
do
expect
(
find
(
emoji_counter
)).
to
have_text
(
"1"
)
end
toggle_smiley_emoji
(
false
)
within
(
'.note-awards'
)
do
within
(
'.note-awards'
)
do
expect
(
page
).
not_to
have_selector
(
emoji_counter
)
expect
(
page
).
not_to
have_selector
(
emoji_counter
)
end
end
end
end
end
end
end
context
'unauthorized user'
,
js:
true
do
before
do
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
end
it
'has disabled emoji button'
do
expect
(
first
(
'.award-control'
)[
:disabled
]).
to
be
(
true
)
end
end
def
thumbsup_emoji
def
thumbsup_emoji
page
.
all
(
emoji_counter
).
first
page
.
all
(
emoji_counter
).
first
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