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
Boxiang Sun
gitlab-ce
Commits
6c1ed00a
Commit
6c1ed00a
authored
Jul 11, 2016
by
Jack Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Award tooltips refer to current user as "You"
parent
1fc17a8a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
25 deletions
+25
-25
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+8
-8
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+2
-2
features/steps/project/issues/award_emoji.rb
features/steps/project/issues/award_emoji.rb
+1
-1
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+4
-4
spec/javascripts/awards_handler_spec.js
spec/javascripts/awards_handler_spec.js
+10
-10
No files found.
app/assets/javascripts/awards_handler.js
View file @
6c1ed00a
...
@@ -131,7 +131,7 @@
...
@@ -131,7 +131,7 @@
counter
=
$emojiButton
.
find
(
'
.js-counter
'
);
counter
=
$emojiButton
.
find
(
'
.js-counter
'
);
counter
.
text
(
parseInt
(
counter
.
text
())
+
1
);
counter
.
text
(
parseInt
(
counter
.
text
())
+
1
);
$emojiButton
.
addClass
(
'
active
'
);
$emojiButton
.
addClass
(
'
active
'
);
this
.
add
Me
ToUserList
(
votesBlock
,
emoji
);
this
.
add
You
ToUserList
(
votesBlock
,
emoji
);
return
this
.
animateEmoji
(
$emojiButton
);
return
this
.
animateEmoji
(
$emojiButton
);
}
}
}
else
{
}
else
{
...
@@ -177,11 +177,11 @@
...
@@ -177,11 +177,11 @@
counterNumber
=
parseInt
(
counter
.
text
(),
10
);
counterNumber
=
parseInt
(
counter
.
text
(),
10
);
if
(
counterNumber
>
1
)
{
if
(
counterNumber
>
1
)
{
counter
.
text
(
counterNumber
-
1
);
counter
.
text
(
counterNumber
-
1
);
this
.
remove
Me
FromUserList
(
$emojiButton
,
emoji
);
this
.
remove
You
FromUserList
(
$emojiButton
,
emoji
);
}
else
if
(
emoji
===
'
thumbsup
'
||
emoji
===
'
thumbsdown
'
)
{
}
else
if
(
emoji
===
'
thumbsup
'
||
emoji
===
'
thumbsdown
'
)
{
$emojiButton
.
tooltip
(
'
destroy
'
);
$emojiButton
.
tooltip
(
'
destroy
'
);
counter
.
text
(
'
0
'
);
counter
.
text
(
'
0
'
);
this
.
remove
Me
FromUserList
(
$emojiButton
,
emoji
);
this
.
remove
You
FromUserList
(
$emojiButton
,
emoji
);
if
(
$emojiButton
.
parents
(
'
.note
'
).
length
)
{
if
(
$emojiButton
.
parents
(
'
.note
'
).
length
)
{
this
.
removeEmoji
(
$emojiButton
);
this
.
removeEmoji
(
$emojiButton
);
}
}
...
@@ -214,17 +214,17 @@
...
@@ -214,17 +214,17 @@
}
}
};
};
AwardsHandler
.
prototype
.
remove
Me
FromUserList
=
function
(
$emojiButton
,
emoji
)
{
AwardsHandler
.
prototype
.
remove
You
FromUserList
=
function
(
$emojiButton
,
emoji
)
{
var
authors
,
awardBlock
,
newAuthors
,
originalTitle
;
var
authors
,
awardBlock
,
newAuthors
,
originalTitle
;
awardBlock
=
$emojiButton
;
awardBlock
=
$emojiButton
;
originalTitle
=
this
.
getAwardTooltip
(
awardBlock
);
originalTitle
=
this
.
getAwardTooltip
(
awardBlock
);
authors
=
originalTitle
.
split
(
FROM_SENTENCE_REGEX
);
authors
=
originalTitle
.
split
(
FROM_SENTENCE_REGEX
);
authors
.
splice
(
authors
.
indexOf
(
'
me
'
),
1
);
authors
.
splice
(
authors
.
indexOf
(
'
You
'
),
1
);
awardBlock
.
closest
(
'
.js-emoji-btn
'
).
removeData
(
'
original-title
'
).
attr
(
'
data-original-title
'
,
this
.
toSentence
(
authors
));
awardBlock
.
closest
(
'
.js-emoji-btn
'
).
removeData
(
'
original-title
'
).
attr
(
'
data-original-title
'
,
this
.
toSentence
(
authors
));
return
this
.
resetTooltip
(
awardBlock
);
return
this
.
resetTooltip
(
awardBlock
);
};
};
AwardsHandler
.
prototype
.
add
Me
ToUserList
=
function
(
votesBlock
,
emoji
)
{
AwardsHandler
.
prototype
.
add
You
ToUserList
=
function
(
votesBlock
,
emoji
)
{
var
awardBlock
,
origTitle
,
users
;
var
awardBlock
,
origTitle
,
users
;
awardBlock
=
this
.
findEmojiIcon
(
votesBlock
,
emoji
).
parent
();
awardBlock
=
this
.
findEmojiIcon
(
votesBlock
,
emoji
).
parent
();
origTitle
=
this
.
getAwardTooltip
(
awardBlock
);
origTitle
=
this
.
getAwardTooltip
(
awardBlock
);
...
@@ -232,7 +232,7 @@
...
@@ -232,7 +232,7 @@
if
(
origTitle
)
{
if
(
origTitle
)
{
users
=
origTitle
.
trim
().
split
(
FROM_SENTENCE_REGEX
);
users
=
origTitle
.
trim
().
split
(
FROM_SENTENCE_REGEX
);
}
}
users
.
unshift
(
'
me
'
);
users
.
unshift
(
'
You
'
);
awardBlock
.
attr
(
'
title
'
,
this
.
toSentence
(
users
));
awardBlock
.
attr
(
'
title
'
,
this
.
toSentence
(
users
));
return
this
.
resetTooltip
(
awardBlock
);
return
this
.
resetTooltip
(
awardBlock
);
};
};
...
@@ -249,7 +249,7 @@
...
@@ -249,7 +249,7 @@
AwardsHandler
.
prototype
.
createEmoji_
=
function
(
votesBlock
,
emoji
)
{
AwardsHandler
.
prototype
.
createEmoji_
=
function
(
votesBlock
,
emoji
)
{
var
$emojiButton
,
buttonHtml
,
emojiCssClass
;
var
$emojiButton
,
buttonHtml
,
emojiCssClass
;
emojiCssClass
=
this
.
resolveNameToCssClass
(
emoji
);
emojiCssClass
=
this
.
resolveNameToCssClass
(
emoji
);
buttonHtml
=
"
<button class='btn award-control js-emoji-btn has-tooltip active' title='
me
' data-placement='bottom'> <div class='icon emoji-icon
"
+
emojiCssClass
+
"
' data-emoji='
"
+
emoji
+
"
'></div> <span class='award-control-text js-counter'>1</span> </button>
"
;
buttonHtml
=
"
<button class='btn award-control js-emoji-btn has-tooltip active' title='
You
' data-placement='bottom'> <div class='icon emoji-icon
"
+
emojiCssClass
+
"
' data-emoji='
"
+
emoji
+
"
'></div> <span class='award-control-text js-counter'>1</span> </button>
"
;
$emojiButton
=
$
(
buttonHtml
);
$emojiButton
=
$
(
buttonHtml
);
$emojiButton
.
insertBefore
(
votesBlock
.
find
(
'
.js-award-holder
'
)).
find
(
'
.emoji-icon
'
).
data
(
'
emoji
'
,
emoji
);
$emojiButton
.
insertBefore
(
votesBlock
.
find
(
'
.js-award-holder
'
)).
find
(
'
.emoji-icon
'
).
data
(
'
emoji
'
,
emoji
);
this
.
animateEmoji
(
$emojiButton
);
this
.
animateEmoji
(
$emojiButton
);
...
...
app/helpers/issues_helper.rb
View file @
6c1ed00a
...
@@ -115,11 +115,11 @@ module IssuesHelper
...
@@ -115,11 +115,11 @@ module IssuesHelper
def
award_user_list
(
awards
,
current_user
)
def
award_user_list
(
awards
,
current_user
)
names
=
awards
.
map
do
|
award
|
names
=
awards
.
map
do
|
award
|
award
.
user
==
current_user
?
'
me
'
:
award
.
user
.
name
award
.
user
==
current_user
?
'
You
'
:
award
.
user
.
name
end
end
# Take first 9 OR current user + first 9
# Take first 9 OR current user + first 9
current_user_name
=
names
.
delete
(
'
me
'
)
current_user_name
=
names
.
delete
(
'
You
'
)
names
=
names
.
first
(
9
).
insert
(
0
,
current_user_name
).
compact
names
=
names
.
first
(
9
).
insert
(
0
,
current_user_name
).
compact
names
<<
"
#{
awards
.
size
-
names
.
size
}
more."
if
awards
.
size
>
names
.
size
names
<<
"
#{
awards
.
size
-
names
.
size
}
more."
if
awards
.
size
>
names
.
size
...
...
features/steps/project/issues/award_emoji.rb
View file @
6c1ed00a
...
@@ -48,7 +48,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
...
@@ -48,7 +48,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
page
.
within
'.awards'
do
page
.
within
'.awards'
do
expect
(
page
).
to
have_selector
'.js-emoji-btn'
expect
(
page
).
to
have_selector
'.js-emoji-btn'
expect
(
page
.
find
(
'.js-emoji-btn.active .js-counter'
)).
to
have_content
'1'
expect
(
page
.
find
(
'.js-emoji-btn.active .js-counter'
)).
to
have_content
'1'
expect
(
page
).
to
have_css
(
".js-emoji-btn.active[data-original-title='
me
']"
)
expect
(
page
).
to
have_css
(
".js-emoji-btn.active[data-original-title='
You
']"
)
end
end
end
end
...
...
spec/helpers/issues_helper_spec.rb
View file @
6c1ed00a
...
@@ -69,8 +69,8 @@ describe IssuesHelper do
...
@@ -69,8 +69,8 @@ describe IssuesHelper do
expect
(
award_user_list
(
awards
.
first
(
9
),
nil
)).
to
eq
(
awards
.
first
(
9
).
map
{
|
a
|
a
.
user
.
name
}.
to_sentence
)
expect
(
award_user_list
(
awards
.
first
(
9
),
nil
)).
to
eq
(
awards
.
first
(
9
).
map
{
|
a
|
a
.
user
.
name
}.
to_sentence
)
end
end
it
"displays the current user's name as '
me
'"
do
it
"displays the current user's name as '
You
'"
do
expect
(
award_user_list
(
awards
.
first
(
1
),
awards
[
0
].
user
)).
to
eq
(
'
me
'
)
expect
(
award_user_list
(
awards
.
first
(
1
),
awards
[
0
].
user
)).
to
eq
(
'
You
'
)
end
end
it
"truncates lists of larger than 9 users"
do
it
"truncates lists of larger than 9 users"
do
...
@@ -79,12 +79,12 @@ describe IssuesHelper do
...
@@ -79,12 +79,12 @@ describe IssuesHelper do
it
"displays the current user in front of 0-9 other users"
do
it
"displays the current user in front of 0-9 other users"
do
expect
(
award_user_list
(
awards
,
awards
[
0
].
user
)).
expect
(
award_user_list
(
awards
,
awards
[
0
].
user
)).
to
eq
(
"
me
, "
+
awards
[
1
..
9
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
to
eq
(
"
You
, "
+
awards
[
1
..
9
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
end
end
it
"displays the current user in front regardless of position in the list"
do
it
"displays the current user in front regardless of position in the list"
do
expect
(
award_user_list
(
awards
,
awards
[
12
].
user
)).
expect
(
award_user_list
(
awards
,
awards
[
12
].
user
)).
to
eq
(
"
me
, "
+
awards
[
0
..
8
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
to
eq
(
"
You
, "
+
awards
[
0
..
8
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
end
end
end
end
...
...
spec/javascripts/awards_handler_spec.js
View file @
6c1ed00a
...
@@ -143,8 +143,8 @@
...
@@ -143,8 +143,8 @@
return
expect
(
$votesBlock
.
find
(
'
[data-emoji=fire]
'
).
length
).
toBe
(
0
);
return
expect
(
$votesBlock
.
find
(
'
[data-emoji=fire]
'
).
length
).
toBe
(
0
);
});
});
});
});
describe
(
'
::add
Me
ToUserList
'
,
function
()
{
describe
(
'
::add
You
ToUserList
'
,
function
()
{
it
(
'
should prepend "
me
" to the award tooltip
'
,
function
()
{
it
(
'
should prepend "
You
" to the award tooltip
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
...
@@ -152,9 +152,9 @@
...
@@ -152,9 +152,9 @@
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam, jerry, max, and andy
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam, jerry, max, and andy
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
me
, sam, jerry, max, and andy
'
);
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
You
, sam, jerry, max, and andy
'
);
});
});
return
it
(
'
handles the special case where "
me
" is not cleanly comma seperated
'
,
function
()
{
return
it
(
'
handles the special case where "
You
" is not cleanly comma seperated
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
...
@@ -162,27 +162,27 @@
...
@@ -162,27 +162,27 @@
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
me
and sam
'
);
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
You
and sam
'
);
});
});
});
});
describe
(
'
::remove
Me
ToUserList
'
,
function
()
{
describe
(
'
::remove
You
ToUserList
'
,
function
()
{
it
(
'
removes "
me
" from the front of the tooltip
'
,
function
()
{
it
(
'
removes "
You
" from the front of the tooltip
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
me
, sam, jerry, max, and andy
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
You
, sam, jerry, max, and andy
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
sam, jerry, max, and andy
'
);
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
sam, jerry, max, and andy
'
);
});
});
return
it
(
'
handles the special case where "
me
" is not cleanly comma seperated
'
,
function
()
{
return
it
(
'
handles the special case where "
You
" is not cleanly comma seperated
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
me
and sam
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
You
and sam
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
$thumbsUpEmoji
.
tooltip
();
...
...
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