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
1311f8c2
Commit
1311f8c2
authored
Jun 06, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rename-ci-commit-phase-2' into rename-ci-commit-phase-3
parents
ef35ca23
4e38d88d
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1798 additions
and
156 deletions
+1798
-156
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/application.js.coffee
app/assets/javascripts/application.js.coffee
+1
-1
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+163
-109
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-2
app/assets/javascripts/due_date_select.js.coffee
app/assets/javascripts/due_date_select.js.coffee
+3
-2
app/assets/javascripts/lib/emoji_aliases.js.coffee.erb
app/assets/javascripts/lib/emoji_aliases.js.coffee.erb
+1
-1
app/assets/javascripts/milestone_select.js.coffee
app/assets/javascripts/milestone_select.js.coffee
+2
-2
app/assets/javascripts/notes.js.coffee
app/assets/javascripts/notes.js.coffee
+4
-3
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+1
-1
app/assets/stylesheets/framework/timeline.scss
app/assets/stylesheets/framework/timeline.scss
+1
-1
app/assets/stylesheets/pages/awards.scss
app/assets/stylesheets/pages/awards.scss
+3
-1
app/assets/stylesheets/pages/notes.scss
app/assets/stylesheets/pages/notes.scss
+32
-0
app/controllers/concerns/toggle_award_emoji.rb
app/controllers/concerns/toggle_award_emoji.rb
+10
-1
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+3
-0
app/models/note.rb
app/models/note.rb
+1
-0
app/views/award_emoji/_awards_block.html.haml
app/views/award_emoji/_awards_block.html.haml
+1
-1
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+3
-3
app/views/projects/notes/_note.html.haml
app/views/projects/notes/_note.html.haml
+6
-1
config/routes.rb
config/routes.rb
+1
-0
spec/controllers/projects/notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+36
-0
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+2
-6
spec/javascripts/awards_handler_spec.js.coffee
spec/javascripts/awards_handler_spec.js.coffee
+202
-0
spec/javascripts/behaviors/quick_submit_spec.js.coffee
spec/javascripts/behaviors/quick_submit_spec.js.coffee
+11
-11
spec/javascripts/fixtures/awards_handler.html.haml
spec/javascripts/fixtures/awards_handler.html.haml
+52
-0
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
+1
-1
spec/javascripts/fixtures/emoji_menu.coffee
spec/javascripts/fixtures/emoji_menu.coffee
+957
-0
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
+6
-6
spec/javascripts/new_branch_spec.js.coffee
spec/javascripts/new_branch_spec.js.coffee
+1
-1
spec/lib/gitlab/badge/build_spec.rb
spec/lib/gitlab/badge/build_spec.rb
+23
-2
spec/models/note_spec.rb
spec/models/note_spec.rb
+10
-0
vendor/assets/javascripts/task_list.js.coffee
vendor/assets/javascripts/task_list.js.coffee
+258
-0
No files found.
CHANGELOG
View file @
1311f8c2
...
...
@@ -44,6 +44,7 @@ v 8.8.4 (unreleased)
- Fix issue with arrow keys not working in search autocomplete dropdown
- Fix todos page throwing errors when you have a project pending deletion
- Reduce number of SQL queries when rendering user references
- Upgrade to jQuery 2
v 8.8.3
- Fix 404 page when viewing TODOs that contain milestones or labels in different projects. !4312
...
...
app/assets/javascripts/application.js.coffee
View file @
1311f8c2
...
...
@@ -4,7 +4,7 @@
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
# the compiled file.
#
#= require jquery
#= require jquery
2
#= require jquery-ui/autocomplete
#= require jquery-ui/datepicker
#= require jquery-ui/draggable
...
...
app/assets/javascripts/awards_handler.coffee
View file @
1311f8c2
This diff is collapsed.
Click to expand it.
app/assets/javascripts/dispatcher.js.coffee
View file @
1311f8c2
...
...
@@ -23,7 +23,7 @@ class Dispatcher
new
Issue
()
shortcut_handler
=
new
ShortcutsIssuable
()
new
ZenMode
()
window
.
awardsHandler
=
new
AwardsHandler
()
gl
.
awardsHandler
=
new
AwardsHandler
()
when
'projects:milestones:show'
,
'groups:milestones:show'
,
'dashboard:milestones:show'
new
Milestone
()
when
'dashboard:todos:index'
...
...
@@ -54,7 +54,7 @@ class Dispatcher
new
Diff
()
shortcut_handler
=
new
ShortcutsIssuable
(
true
)
new
ZenMode
()
window
.
awardsHandler
=
new
AwardsHandler
()
gl
.
awardsHandler
=
new
AwardsHandler
()
when
"projects:merge_requests:diffs"
new
Diff
()
new
ZenMode
()
...
...
app/assets/javascripts/due_date_select.js.coffee
View file @
1311f8c2
...
...
@@ -21,7 +21,7 @@ class @DueDateSelect
$dropdown
.
glDropdown
(
hidden
:
->
$selectbox
.
hide
()
$value
.
removeAttr
(
'style
'
)
$value
.
css
(
'display'
,
'
'
)
)
addDueDate
=
(
isDropdown
)
->
...
...
@@ -42,12 +42,13 @@ class @DueDateSelect
type
:
'PUT'
url
:
issueUpdateURL
data
:
data
dataType
:
'json'
beforeSend
:
->
$loading
.
fadeIn
()
if
isDropdown
$dropdown
.
trigger
(
'loading.gl.dropdown'
)
$selectbox
.
hide
()
$value
.
removeAttr
(
'style
'
)
$value
.
css
(
'display'
,
'
'
)
$valueContent
.
html
(
mediumDate
)
$sidebarValue
.
html
(
mediumDate
)
...
...
app/assets/javascripts/lib/emoji_aliases.js.coffee.erb
View file @
1311f8c2
window
.emojiAliases = ->
gl
.emojiAliases = ->
JSON.parse('
<%=
Gitlab
::
AwardEmoji
.
aliases
.
to_json
%>
')
app/assets/javascripts/milestone_select.js.coffee
View file @
1311f8c2
...
...
@@ -83,7 +83,7 @@ class @MilestoneSelect
$selectbox
.
hide
()
# display:block overrides the hide-collapse rule
$value
.
removeAttr
(
'style
'
)
$value
.
css
(
'display'
,
'
'
)
clicked
:
(
selected
)
->
page
=
$
(
'body'
).
data
'page'
isIssueIndex
=
page
is
'projects:issues:index'
...
...
@@ -118,7 +118,7 @@ class @MilestoneSelect
$dropdown
.
trigger
(
'loaded.gl.dropdown'
)
$loading
.
fadeOut
()
$selectbox
.
hide
()
$value
.
removeAttr
(
'style
'
)
$value
.
css
(
'display'
,
'
'
)
if
data
.
milestone
?
data
.
milestone
.
namespace
=
_this
.
currentProject
.
namespace
data
.
milestone
.
path
=
_this
.
currentProject
.
path
...
...
app/assets/javascripts/notes.js.coffee
View file @
1311f8c2
...
...
@@ -162,13 +162,14 @@ class @Notes
renderNote
:
(
note
)
->
unless
note
.
valid
if
note
.
award
flash
=
new
Flash
(
'You have already
used this award
emoji!'
,
'alert'
)
flash
=
new
Flash
(
'You have already
awarded this
emoji!'
,
'alert'
)
flash
.
pinTo
(
'.header-content'
)
return
if
note
.
award
awardsHandler
.
addAwardToEmojiBar
(
note
.
name
)
awardsHandler
.
scrollToAwards
()
votesBlock
=
$
(
'.js-awards-block'
).
eq
0
gl
.
awardsHandler
.
addAwardToEmojiBar
votesBlock
,
note
.
name
gl
.
awardsHandler
.
scrollToAwards
()
# render note if it not present in loaded list
# or skip if rendered
...
...
app/assets/javascripts/users_select.js.coffee
View file @
1311f8c2
...
...
@@ -149,7 +149,7 @@ class @UsersSelect
hidden
:
(
e
)
->
$selectbox
.
hide
()
# display:block overrides the hide-collapse rule
$value
.
removeAttr
(
'style
'
)
$value
.
css
(
'display'
,
'
'
)
clicked
:
(
user
)
->
page
=
$
(
'body'
).
data
'page'
...
...
app/assets/stylesheets/framework/timeline.scss
View file @
1311f8c2
...
...
@@ -5,7 +5,7 @@
padding
:
0
;
.timeline-entry
{
padding
:
$gl-padding
$gl-btn-padding
;
padding
:
$gl-padding
$gl-btn-padding
11px
;
border-color
:
$table-border-color
;
color
:
$gl-gray
;
border-bottom
:
1px
solid
$border-white-light
;
...
...
app/assets/stylesheets/pages/awards.scss
View file @
1311f8c2
...
...
@@ -95,6 +95,7 @@
.award-control
{
margin-right
:
5px
;
margin-bottom
:
5px
;
padding-left
:
5px
;
padding-right
:
5px
;
line-height
:
20px
;
...
...
@@ -108,7 +109,8 @@
}
&
.is-loading
{
.award-control-icon-normal
{
.award-control-icon-normal
,
.emoji-icon
{
display
:
none
;
}
...
...
app/assets/stylesheets/pages/notes.scss
View file @
1311f8c2
...
...
@@ -69,6 +69,10 @@ ul.notes {
.note-edit-form
{
display
:
block
;
&
.current-note-edit-form
+
.note-awards
{
display
:
none
;
}
}
}
...
...
@@ -116,10 +120,38 @@ ul.notes {
}
}
.note-awards
{
.js-awards-block
{
padding
:
2px
;
margin-top
:
10px
;
}
.award-control
{
font-size
:
13px
;
padding
:
2px
5px
;
}
}
.note-header
{
padding-bottom
:
3px
;
}
.note-emoji-button
{
.fa-spinner
{
display
:
none
;
}
&
.is-loading
{
.fa-smile-o
{
display
:
none
;
}
.fa-spinner
{
display
:
inline-block
;
}
}
}
}
}
...
...
app/controllers/concerns/toggle_award_emoji.rb
View file @
1311f8c2
...
...
@@ -9,13 +9,22 @@ module ToggleAwardEmoji
name
=
params
.
require
(
:name
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
TodoService
.
new
.
new_award_emoji
(
awardable
,
current_user
)
TodoService
.
new
.
new_award_emoji
(
to_todoable
(
awardable
)
,
current_user
)
render
json:
{
ok:
true
}
end
private
def
to_todoable
(
awardable
)
case
awardable
when
Note
awardable
.
noteable
else
awardable
end
end
def
awardable
raise
NotImplementedError
end
...
...
app/controllers/projects/notes_controller.rb
View file @
1311f8c2
class
Projects::NotesController
<
Projects
::
ApplicationController
include
ToggleAwardEmoji
# Authorize
before_action
:authorize_read_note!
before_action
:authorize_create_note!
,
only:
[
:create
]
...
...
@@ -61,6 +63,7 @@ class Projects::NotesController < Projects::ApplicationController
def
note
@note
||=
@project
.
notes
.
find
(
params
[
:id
])
end
alias_method
:awardable
,
:note
def
note_to_html
(
note
)
render_to_string
(
...
...
app/models/note.rb
View file @
1311f8c2
...
...
@@ -3,6 +3,7 @@ class Note < ActiveRecord::Base
include
Gitlab
::
CurrentSettings
include
Participable
include
Mentionable
include
Awardable
default_value_for
:system
,
false
...
...
app/views/award_emoji/_awards_block.html.haml
View file @
1311f8c2
...
...
@@ -11,7 +11,7 @@
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
}
}
%button
.btn.award-control.js-add-award
{
type:
"button"
}
=
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
...
...
app/views/projects/issues/show.html.haml
View file @
1311f8c2
...
...
@@ -68,9 +68,9 @@
#related-branches
{
data:
{
url:
related_branches_namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@issue
)
}
}
// This element is filled in using JavaScript.
.content-block.content-block-small
=
render
'new_branch'
=
render
'award_emoji/awards_block'
,
awardable:
@issue
,
inline:
true
.content-block.content-block-small
=
render
'new_branch'
=
render
'award_emoji/awards_block'
,
awardable:
@issue
,
inline:
true
%section
.issuable-discussion
=
render
'projects/issues/discussion'
...
...
app/views/projects/notes/_note.html.haml
View file @
1311f8c2
...
...
@@ -22,6 +22,9 @@
%span
.note-role
=
access
-
if
note_editable
=
link_to
'#'
,
title:
'Award Emoji'
,
class:
'note-action-button note-emoji-button js-add-award js-note-emoji'
,
data:
{
position:
'right'
}
do
=
icon
(
'spinner spin'
)
=
icon
(
'smile-o'
)
=
link_to
'#'
,
title:
'Edit comment'
,
class:
'note-action-button js-note-edit'
do
=
icon
(
'pencil'
)
=
link_to
namespace_project_note_path
(
note
.
project
.
namespace
,
note
.
project
,
note
),
title:
'Remove comment'
,
method: :delete
,
data:
{
confirm:
'Are you sure you want to remove this comment?'
},
remote:
true
,
class:
'note-action-button js-note-delete danger'
do
...
...
@@ -30,9 +33,11 @@
.note-text
=
preserve
do
=
markdown
(
note
.
note
,
pipeline: :note
,
cache_key:
[
note
,
"note"
],
author:
note
.
author
)
=
edited_time_ago_with_tooltip
(
note
,
placement:
'bottom'
,
html_class:
'note_edited_ago'
,
include_author:
true
)
-
if
note_editable
=
render
'projects/notes/edit_form'
,
note:
note
=
edited_time_ago_with_tooltip
(
note
,
placement:
'bottom'
,
html_class:
'note_edited_ago'
,
include_author:
true
)
.note-awards
=
render
'award_emoji/awards_block'
,
awardable:
note
,
inline:
false
-
if
note
.
attachment
.
url
.note-attachment
...
...
config/routes.rb
View file @
1311f8c2
...
...
@@ -758,6 +758,7 @@ Rails.application.routes.draw do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
constraints:
{
id:
/\d+/
}
do
member
do
post
:toggle_award_emoji
delete
:delete_attachment
end
end
...
...
spec/controllers/projects/notes_controller_spec.rb
0 → 100644
View file @
1311f8c2
require
(
'spec_helper'
)
describe
Projects
::
NotesController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
)
}
describe
'POST #toggle_award_emoji'
do
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
end
it
"toggles the award emoji"
do
expect
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
note
.
id
,
name:
"thumbsup"
)
end
.
to
change
{
note
.
award_emoji
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
"removes the already awarded emoji"
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
note
.
id
,
name:
"thumbsup"
)
expect
do
post
(
:toggle_award_emoji
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
note
.
id
,
name:
"thumbsup"
)
end
.
to
change
{
AwardEmoji
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
spec/features/issues_spec.rb
View file @
1311f8c2
...
...
@@ -365,13 +365,9 @@ describe 'Issues', feature: true do
page
.
within
(
'.assignee'
)
do
expect
(
page
).
to
have_content
"
#{
@user
.
name
}
"
end
find
(
'.block.assignee .edit-link'
).
click
sleep
2
# wait for ajax stuff to complete
first
(
'.dropdown-menu-user-link'
).
click
sleep
2
page
.
within
(
'.assignee'
)
do
click_link
'Edit'
click_link
'Unassigned'
expect
(
page
).
to
have_content
'No assignee'
end
...
...
spec/javascripts/awards_handler_spec.js.coffee
0 → 100644
View file @
1311f8c2
#= require awards_handler
#= require jquery
#= require jquery.cookie
#= require ./fixtures/emoji_menu
awardsHandler
=
null
window
.
gl
or=
{}
gl
.
emojiAliases
=
->
return
{
'+1'
:
'thumbsup'
,
'-1'
:
'thumbsdown'
}
gl
.
awardMenuUrl
=
'/emojis'
lazyAssert
=
(
done
,
assertFn
)
->
setTimeout
->
# Maybe jasmine.clock here?
assertFn
()
done
()
,
333
describe
'AwardsHandler'
,
->
fixture
.
preload
'awards_handler.html'
beforeEach
->
fixture
.
load
'awards_handler.html'
awardsHandler
=
new
AwardsHandler
spyOn
(
awardsHandler
,
'postEmoji'
).
and
.
callFake
(
url
,
emoji
,
cb
)
=>
cb
()
spyOn
(
jQuery
,
'get'
).
and
.
callFake
(
req
,
cb
)
->
expect
(
req
).
toBe
'/emojis'
cb
window
.
emojiMenu
describe
'::showEmojiMenu'
,
->
it
'should show emoji menu when Add emoji button clicked'
,
(
done
)
->
$
(
'.js-add-award'
).
eq
(
0
).
click
()
lazyAssert
done
,
->
$emojiMenu
=
$
'.emoji-menu'
expect
(
$emojiMenu
.
length
).
toBe
1
expect
(
$emojiMenu
.
hasClass
(
'is-visible'
)).
toBe
yes
expect
(
$emojiMenu
.
find
(
'#emoji_search'
).
length
).
toBe
1
expect
(
$
(
'.js-awards-block.current'
).
length
).
toBe
1
it
'should also show emoji menu for the smiley icon in notes'
,
(
done
)
->
$
(
'.note-action-button'
).
click
()
lazyAssert
done
,
->
$emojiMenu
=
$
'.emoji-menu'
expect
(
$emojiMenu
.
length
).
toBe
1
it
'should remove emoji menu when body is clicked'
,
(
done
)
->
$
(
'.js-add-award'
).
eq
(
0
).
click
()
lazyAssert
done
,
->
$emojiMenu
=
$
(
'.emoji-menu'
)
$
(
'body'
).
click
()
expect
(
$emojiMenu
.
length
).
toBe
1
expect
(
$emojiMenu
.
hasClass
(
'is-visible'
)).
toBe
no
expect
(
$
(
'.js-awards-block.current'
).
length
).
toBe
0
describe
'::addAwardToEmojiBar'
,
->
it
'should add emoji to votes block'
,
->
$votesBlock
=
$
(
'.js-awards-block'
).
eq
0
awardsHandler
.
addAwardToEmojiBar
$votesBlock
,
'heart'
,
no
$emojiButton
=
$votesBlock
.
find
'[data-emoji=heart]'
expect
(
$emojiButton
.
length
).
toBe
1
expect
(
$emojiButton
.
next
(
'.js-counter'
).
text
()).
toBe
'1'
expect
(
$votesBlock
.
hasClass
(
'hidden'
)).
toBe
no
it
'should remove the emoji when we click again'
,
->
$votesBlock
=
$
(
'.js-awards-block'
).
eq
0
awardsHandler
.
addAwardToEmojiBar
$votesBlock
,
'heart'
,
no
awardsHandler
.
addAwardToEmojiBar
$votesBlock
,
'heart'
,
no
$emojiButton
=
$votesBlock
.
find
'[data-emoji=heart]'
expect
(
$emojiButton
.
length
).
toBe
0
it
'should decrement the emoji counter'
,
->
$votesBlock
=
$
(
'.js-awards-block'
).
eq
0
awardsHandler
.
addAwardToEmojiBar
$votesBlock
,
'heart'
,
no
$emojiButton
=
$votesBlock
.
find
'[data-emoji=heart]'
$emojiButton
.
next
(
'.js-counter'
).
text
5
awardsHandler
.
addAwardToEmojiBar
$votesBlock
,
'heart'
,
no
expect
(
$emojiButton
.
length
).
toBe
1
expect
(
$emojiButton
.
next
(
'.js-counter'
).
text
()).
toBe
'4'
describe
'::getAwardUrl'
,
->
it
'should return the url for request'
,
->
expect
(
awardsHandler
.
getAwardUrl
()).
toBe
'/gitlab-org/gitlab-test/issues/8/toggle_award_emoji'
describe
'::addAward and ::checkMutuality'
,
->
it
'should handle :+1: and :-1: mutuality'
,
->
awardUrl
=
awardsHandler
.
getAwardUrl
()
$votesBlock
=
$
(
'.js-awards-block'
).
eq
0
$thumbsUpEmoji
=
$votesBlock
.
find
(
'[data-emoji=thumbsup]'
).
parent
()
$thumbsDownEmoji
=
$votesBlock
.
find
(
'[data-emoji=thumbsdown]'
).
parent
()
awardsHandler
.
addAward
$votesBlock
,
awardUrl
,
'thumbsup'
,
no
expect
(
$thumbsUpEmoji
.
hasClass
(
'active'
)).
toBe
yes
expect
(
$thumbsDownEmoji
.
hasClass
(
'active'
)).
toBe
no
$thumbsUpEmoji
.
tooltip
()
$thumbsDownEmoji
.
tooltip
()
awardsHandler
.
addAward
$votesBlock
,
awardUrl
,
'thumbsdown'
,
yes
expect
(
$thumbsUpEmoji
.
hasClass
(
'active'
)).
toBe
no
expect
(
$thumbsDownEmoji
.
hasClass
(
'active'
)).
toBe
yes
describe
'::removeEmoji'
,
->
it
'should remove emoji'
,
->
awardUrl
=
awardsHandler
.
getAwardUrl
()
$votesBlock
=
$
(
'.js-awards-block'
).
eq
0
awardsHandler
.
addAward
$votesBlock
,
awardUrl
,
'fire'
,
no
expect
(
$votesBlock
.
find
(
'[data-emoji=fire]'
).
length
).
toBe
1
awardsHandler
.
removeEmoji
$votesBlock
.
find
(
'[data-emoji=fire]'
).
closest
(
'button'
)
expect
(
$votesBlock
.
find
(
'[data-emoji=fire]'
).
length
).
toBe
0
describe
'search'
,
->
it
'should filter the emoji'
,
->
$
(
'.js-add-award'
).
eq
(
0
).
click
()
expect
(
$
(
'[data-emoji=angel]'
).
is
(
':visible'
)).
toBe
yes
expect
(
$
(
'[data-emoji=anger]'
).
is
(
':visible'
)).
toBe
yes
$
(
'#emoji_search'
).
val
(
'ali'
).
trigger
'keyup'
expect
(
$
(
'[data-emoji=angel]'
).
is
(
':visible'
)).
toBe
no
expect
(
$
(
'[data-emoji=anger]'
).
is
(
':visible'
)).
toBe
no
expect
(
$
(
'[data-emoji=alien]'
).
is
(
':visible'
)).
toBe
yes
expect
(
$
(
'h5.emoji-search'
).
is
(
':visible'
)).
toBe
yes
describe
'emoji menu'
,
->
selector
=
'[data-emoji=sunglasses]'
openEmojiMenuAndAddEmoji
=
->
$
(
'.js-add-award'
).
eq
(
0
).
click
()
$menu
=
$
'.emoji-menu'
$block
=
$
'.js-awards-block'
$emoji
=
$menu
.
find
".emoji-menu-list-item
#{
selector
}
"
expect
(
$emoji
.
length
).
toBe
1
expect
(
$block
.
find
(
selector
).
length
).
toBe
0
$emoji
.
click
()
expect
(
$menu
.
hasClass
(
'.is-visible'
)).
toBe
no
expect
(
$block
.
find
(
selector
).
length
).
toBe
1
it
'should add selected emoji to awards block'
,
->
openEmojiMenuAndAddEmoji
()
it
'should remove already selected emoji'
,
->
openEmojiMenuAndAddEmoji
()
$
(
'.js-add-award'
).
eq
(
0
).
click
()
$block
=
$
'.js-awards-block'
$emoji
=
$
(
'.emoji-menu'
).
find
".emoji-menu-list-item
#{
selector
}
"
$emoji
.
click
()
expect
(
$block
.
find
(
selector
).
length
).
toBe
0
spec/javascripts/behaviors/quick_submit_spec.js.coffee
View file @
1311f8c2
...
...
@@ -14,17 +14,17 @@ describe 'Quick Submit behavior', ->
}
it
'does not respond to other keyCodes'
,
->
$
(
'input'
).
trigger
(
keydownEvent
(
keyCode
:
32
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
keyCode
:
32
))
expect
(
@
spies
.
submit
).
not
.
toHaveBeenTriggered
()
it
'does not respond to Enter alone'
,
->
$
(
'input'
).
trigger
(
keydownEvent
(
ctrlKey
:
false
,
metaKey
:
false
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
ctrlKey
:
false
,
metaKey
:
false
))
expect
(
@
spies
.
submit
).
not
.
toHaveBeenTriggered
()
it
'does not respond to repeated events'
,
->
$
(
'input'
).
trigger
(
keydownEvent
(
repeat
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
repeat
:
true
))
expect
(
@
spies
.
submit
).
not
.
toHaveBeenTriggered
()
...
...
@@ -38,26 +38,26 @@ describe 'Quick Submit behavior', ->
# only run the tests that apply to the current platform
if
navigator
.
userAgent
.
match
(
/Macintosh/
)
it
'responds to Meta+Enter'
,
->
$
(
'input'
).
trigger
(
keydownEvent
())
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
())
expect
(
@
spies
.
submit
).
toHaveBeenTriggered
()
it
'excludes other modifier keys'
,
->
$
(
'input'
).
trigger
(
keydownEvent
(
altKey
:
true
))
$
(
'input'
).
trigger
(
keydownEvent
(
ctrlKey
:
true
))
$
(
'input'
).
trigger
(
keydownEvent
(
shiftKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
altKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
ctrlKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
shiftKey
:
true
))
expect
(
@
spies
.
submit
).
not
.
toHaveBeenTriggered
()
else
it
'responds to Ctrl+Enter'
,
->
$
(
'input'
).
trigger
(
keydownEvent
())
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
())
expect
(
@
spies
.
submit
).
toHaveBeenTriggered
()
it
'excludes other modifier keys'
,
->
$
(
'input'
).
trigger
(
keydownEvent
(
altKey
:
true
))
$
(
'input'
).
trigger
(
keydownEvent
(
metaKey
:
true
))
$
(
'input'
).
trigger
(
keydownEvent
(
shiftKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
altKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
metaKey
:
true
))
$
(
'input
.quick-submit-input
'
).
trigger
(
keydownEvent
(
shiftKey
:
true
))
expect
(
@
spies
.
submit
).
not
.
toHaveBeenTriggered
()
...
...
spec/javascripts/fixtures/awards_handler.html.haml
0 → 100644
View file @
1311f8c2
.issue-details.issuable-details
.detail-page-description.content-block
%h2
.title
Quibusdam sint officiis earum molestiae ipsa autem voluptatem nisi rem.
.description.js-task-list-container.is-task-list-enabled
.wiki
%p
Qui exercitationem magnam optio quae fuga earum odio.
%textarea
.hidden.js-task-list-field
Qui exercitationem magnam optio quae fuga earum odio.
%small
.edited-text
.content-block.content-block-small
.awards.js-awards-block
{
"data-award-url"
=>
"/gitlab-org/gitlab-test/issues/8/toggle_award_emoji"
}
%button
.award-control.btn.js-emoji-btn
{
"data-placement"
=>
"bottom"
,
"data-title"
=>
""
,
:type
=>
"button"
}
.icon.emoji-icon.emoji-1F44D
{
"data-aliases"
=>
""
,
"data-emoji"
=>
"thumbsup"
,
"data-unicode-name"
=>
"1F44D"
,
:title
=>
"thumbsup"
}
%span
.award-control-text.js-counter
0
%button
.award-control.btn.js-emoji-btn
{
"data-placement"
=>
"bottom"
,
"data-title"
=>
""
,
:type
=>
"button"
}
.icon.emoji-icon.emoji-1F44E
{
"data-aliases"
=>
""
,
"data-emoji"
=>
"thumbsdown"
,
"data-unicode-name"
=>
"1F44E"
,
:title
=>
"thumbsdown"
}
%span
.award-control-text.js-counter
0
.award-menu-holder.js-award-holder
%button
.btn.award-control.js-add-award
{
:type
=>
"button"
}
%i
.fa.fa-smile-o.award-control-icon.award-control-icon-normal
%i
.fa.fa-spinner.fa-spin.award-control-icon.award-control-icon-loading
%span
.award-control-text
Add
%section
.issuable-discussion
#notes
%ul
#notes-list
.notes.main-notes-list.timeline
%li
#note_348
.note.note-row-348.timeline-entry
{
"data-author-id"
=>
"18"
,
"data-editable"
=>
""
}
.timeline-entry-inner
.timeline-icon
%a
{
:href
=>
"/u/agustin"
}
%img
.avatar.s40
{
:alt
=>
""
,
:src
=>
"#"
}
/
.timeline-content
.note-header
%a
.author_link
{
:href
=>
"/u/agustin"
}
%span
.author
Brenna Stokes
.inline.note-headline-light
@agustin commented
%a
{
:href
=>
"#note_348"
}
%time
11 days ago
.note-actions
%span
.note-role
Reporter
%a
.note-action-button.note-emoji-button.js-add-award.js-note-emoji
{
"data-position"
=>
"right"
,
:href
=>
"#"
,
:title
=>
"Award Emoji"
}
%i
.fa.fa-spinner.fa-spin
%i
.fa.fa-smile-o
.js-task-list-container.note-body.is-task-list-enabled
.note-text
%p
Suscipit sunt quia quisquam sed eveniet ipsam.
.note-awards
.awards.hidden.js-awards-block
{
"data-award-url"
=>
"/gitlab-org/gitlab-test/notes/348/toggle_award_emoji"
}
.award-menu-holder.js-award-holder
%button
.btn.award-control.js-add-award
{
:type
=>
"button"
}
%i
.fa.fa-smile-o.award-control-icon.award-control-icon-normal
%i
.fa.fa-spinner.fa-spin.award-control-icon.award-control-icon-loading
%span
.award-control-text
Add
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
View file @
1311f8c2
%form
.js-quick-submit
{
action:
'/foo'
}
%input
{
type:
'text'
}
%input
{
type:
'text'
,
class:
'quick-submit-input'
}
%textarea
%input
{
type:
'submit'
}
Submit
...
...
spec/javascripts/fixtures/emoji_menu.coffee
0 → 100644
View file @
1311f8c2
This diff is collapsed.
Click to expand it.
spec/javascripts/graphs/stat_graph_contributors_util_spec.js
View file @
1311f8c2
...
...
@@ -9,14 +9,14 @@ describe("ContributorsStatGraphUtil", function () {
{
author_email
:
"
dzaporozhets@email.com
"
,
author_name
:
"
Dmitriy Zaporozhets
"
,
date
:
"
2013-05-08
"
,
additions
:
6
,
deletions
:
1
},
{
author_email
:
"
dzaporozhets@email.com
"
,
author_name
:
"
Dmitriy Zaporozhets
"
,
date
:
"
2013-05-08
"
,
additions
:
19
,
deletions
:
3
},
{
author_email
:
"
dzaporozhets@email.com
"
,
author_name
:
"
Dmitriy Zaporozhets
"
,
date
:
"
2013-05-08
"
,
additions
:
29
,
deletions
:
3
}]
var
correct_parsed_log
=
{
total
:
[
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
},
{
date
:
"
2013-05-08
"
,
additions
:
54
,
deletions
:
7
,
commits
:
3
}],
by_author
:
[
{
{
author_name
:
"
Karlo Soriano
"
,
author_email
:
"
karlo@email.com
"
,
"
2013-05-09
"
:
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
}
},
...
...
@@ -132,8 +132,8 @@ describe("ContributorsStatGraphUtil", function () {
total
:
[{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
},
{
date
:
"
2013-05-08
"
,
additions
:
54
,
deletions
:
7
,
commits
:
3
}],
by_author
:[
{
author
:
"
Karlo Soriano
"
,
{
author
:
"
Karlo Soriano
"
,
"
2013-05-09
"
:
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
}
},
{
...
...
@@ -161,11 +161,11 @@ describe("ContributorsStatGraphUtil", function () {
it
(
"
returns the log by author sorted by specified field
"
,
function
()
{
var
fake_parsed_log
=
{
total
:
[
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
},
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
},
{
date
:
"
2013-05-08
"
,
additions
:
54
,
deletions
:
7
,
commits
:
3
}
],
by_author
:
[
{
{
author_name
:
"
Karlo Soriano
"
,
author_email
:
"
karlo@email.com
"
,
"
2013-05-09
"
:
{
date
:
"
2013-05-09
"
,
additions
:
471
,
deletions
:
0
,
commits
:
1
}
},
...
...
spec/javascripts/new_branch_spec.js.coffee
View file @
1311f8c2
#= require jquery-ui
#= require jquery-ui
/autocomplete
#= require new_branch_form
describe
'Branch'
,
->
...
...
spec/lib/gitlab/badge/build_spec.rb
View file @
1311f8c2
...
...
@@ -42,8 +42,7 @@ describe Gitlab::Badge::Build do
end
context
'build exists'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
sha
,
ref:
branch
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create_build
(
project
,
sha
,
branch
)
}
context
'build success'
do
before
{
build
.
success!
}
...
...
@@ -95,6 +94,28 @@ describe Gitlab::Badge::Build do
end
end
context
'when outdated pipeline for given ref exists'
do
before
do
build
=
create_build
(
project
,
sha
,
branch
)
build
.
success!
old_build
=
create_build
(
project
,
'11eeffdd'
,
branch
)
old_build
.
drop!
end
it
'does not take outdated pipeline into account'
do
expect
(
badge
.
to_s
).
to
eq
'build-success'
end
end
def
create_build
(
project
,
sha
,
branch
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
sha
,
ref:
branch
)
create
(
:ci_build
,
pipeline:
pipeline
)
end
def
status_node
(
data
,
status
)
xml
=
Nokogiri
::
XML
.
parse
(
data
)
xml
.
at
(
%Q{text:contains("
#{
status
}
")}
)
...
...
spec/models/note_spec.rb
View file @
1311f8c2
...
...
@@ -9,6 +9,16 @@ describe Note, models: true do
it
{
is_expected
.
to
have_many
(
:todos
).
dependent
(
:destroy
)
}
end
describe
'modules'
do
subject
{
described_class
}
it
{
is_expected
.
to
include_module
(
Participable
)
}
it
{
is_expected
.
to
include_module
(
Mentionable
)
}
it
{
is_expected
.
to
include_module
(
Awardable
)
}
it
{
is_expected
.
to
include_module
(
Gitlab
::
CurrentSettings
)
}
end
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:note
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
...
...
vendor/assets/javascripts/task_list.js.coffee
0 → 100644
View file @
1311f8c2
# The MIT License (MIT)
#
# Copyright (c) 2014 GitHub, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# TaskList Behavior
#
#= provides tasklist:enabled
#= provides tasklist:disabled
#= provides tasklist:change
#= provides tasklist:changed
#
#
# Enables Task List update behavior.
#
# ### Example Markup
#
# <div class="js-task-list-container">
# <ul class="task-list">
# <li class="task-list-item">
# <input type="checkbox" class="js-task-list-item-checkbox" disabled />
# text
# </li>
# </ul>
# <form>
# <textarea class="js-task-list-field">- [ ] text</textarea>
# </form>
# </div>
#
# ### Specification
#
# TaskLists MUST be contained in a `(div).js-task-list-container`.
#
# TaskList Items SHOULD be an a list (`UL`/`OL`) element.
#
# Task list items MUST match `(input).task-list-item-checkbox` and MUST be
# `disabled` by default.
#
# TaskLists MUST have a `(textarea).js-task-list-field` form element whose
# `value` attribute is the source (Markdown) to be udpated. The source MUST
# follow the syntax guidelines.
#
# TaskList updates trigger `tasklist:change` events. If the change is
# successful, `tasklist:changed` is fired. The change can be canceled.
#
# jQuery is required.
#
# ### Methods
#
# `.taskList('enable')` or `.taskList()`
#
# Enables TaskList updates for the container.
#
# `.taskList('disable')`
#
# Disables TaskList updates for the container.
#
## ### Events
#
# `tasklist:enabled`
#
# Fired when the TaskList is enabled.
#
# * **Synchronicity** Sync
# * **Bubbles** Yes
# * **Cancelable** No
# * **Target** `.js-task-list-container`
#
# `tasklist:disabled`
#
# Fired when the TaskList is disabled.
#
# * **Synchronicity** Sync
# * **Bubbles** Yes
# * **Cancelable** No
# * **Target** `.js-task-list-container`
#
# `tasklist:change`
#
# Fired before the TaskList item change takes affect.
#
# * **Synchronicity** Sync
# * **Bubbles** Yes
# * **Cancelable** Yes
# * **Target** `.js-task-list-field`
#
# `tasklist:changed`
#
# Fired once the TaskList item change has taken affect.
#
# * **Synchronicity** Sync
# * **Bubbles** Yes
# * **Cancelable** No
# * **Target** `.js-task-list-field`
#
# ### NOTE
#
# Task list checkboxes are rendered as disabled by default because rendered
# user content is cached without regard for the viewer.
incomplete
=
"[ ]"
complete
=
"[x]"
# Escapes the String for regular expression matching.
escapePattern
=
(
str
)
->
str
.
replace
(
/([\[\]])/g
,
"
\\
$1"
).
# escape square brackets
replace
(
/\s/
,
"
\\
s"
).
# match all white space
replace
(
"x"
,
"[xX]"
)
# match all cases
incompletePattern
=
///
#{
escapePattern
(
incomplete
)
}
///
completePattern
=
///
#{
escapePattern
(
complete
)
}
///
# Pattern used to identify all task list items.
# Useful when you need iterate over all items.
itemPattern
=
///
^
(?:
# prefix, consisting of
\s
*
# optional leading whitespace
(?:>
\s
*)*
# zero or more blockquotes
(?:[-+*]|(?:
\d
+
\.
))
# list item indicator
)
\s
*
# optional whitespace prefix
(
# checkbox
#{
escapePattern
(
complete
)
}
|
#{
escapePattern
(
incomplete
)
}
)
\s
+
# is followed by whitespace
(?!
\(
.*?
\)
# is not part of a [foo](url) link
)
(?=
# and is followed by zero or more links
(?:
\[
.*?
\]\s
*(?:
\[
.*?
\]
|
\(
.*?
\)
)
\s
*)*
(?:[^
\[
]|$)
# and either a non-link or the end of the string
)
///
# Used to filter out code fences from the source for comparison only.
# http://rubular.com/r/x5EwZVrloI
# Modified slightly due to issues with JS
codeFencesPattern
=
///
^`{3}
# ```
(?:
\s
*
\w
+)?
# followed by optional language
[
\S\s
]
# whitespace
.*
# code
[
\S\s
]
# whitespace
^`{3}$
# ```
///mg
# Used to filter out potential mismatches (items not in lists).
# http://rubular.com/r/OInl6CiePy
itemsInParasPattern
=
///
^
(
#{
escapePattern
(
complete
)
}
|
#{
escapePattern
(
incomplete
)
}
)
.+
$
///g
# Given the source text, updates the appropriate task list item to match the
# given checked value.
#
# Returns the updated String text.
updateTaskListItem
=
(
source
,
itemIndex
,
checked
)
->
clean
=
source
.
replace
(
/\r/g
,
''
).
replace
(
codeFencesPattern
,
''
).
replace
(
itemsInParasPattern
,
''
).
split
(
"
\n
"
)
index
=
0
result
=
for
line
in
source
.
split
(
"
\n
"
)
if
line
in
clean
&&
line
.
match
(
itemPattern
)
index
+=
1
if
index
==
itemIndex
line
=
if
checked
line
.
replace
(
incompletePattern
,
complete
)
else
line
.
replace
(
completePattern
,
incomplete
)
line
result
.
join
(
"
\n
"
)
# Updates the $field value to reflect the state of $item.
# Triggers the `tasklist:change` event before the value has changed, and fires
# a `tasklist:changed` event once the value has changed.
updateTaskList
=
(
$item
)
->
$container
=
$item
.
closest
'.js-task-list-container'
$field
=
$container
.
find
'.js-task-list-field'
index
=
1
+
$container
.
find
(
'.task-list-item-checkbox'
).
index
(
$item
)
checked
=
$item
.
prop
'checked'
event
=
$
.
Event
'tasklist:change'
$field
.
trigger
event
,
[
index
,
checked
]
unless
event
.
isDefaultPrevented
()
$field
.
val
updateTaskListItem
(
$field
.
val
(),
index
,
checked
)
$field
.
trigger
'change'
$field
.
trigger
'tasklist:changed'
,
[
index
,
checked
]
# When the task list item checkbox is updated, submit the change
$
(
document
).
on
'change'
,
'.task-list-item-checkbox'
,
->
updateTaskList
$
(
this
)
# Enables TaskList item changes.
enableTaskList
=
(
$container
)
->
if
$container
.
find
(
'.js-task-list-field'
).
length
>
0
$container
.
find
(
'.task-list-item'
).
addClass
(
'enabled'
).
find
(
'.task-list-item-checkbox'
).
attr
(
'disabled'
,
null
)
$container
.
addClass
(
'is-task-list-enabled'
).
trigger
'tasklist:enabled'
# Enables a collection of TaskList containers.
enableTaskLists
=
(
$containers
)
->
for
container
in
$containers
enableTaskList
$
(
container
)
# Disable TaskList item changes.
disableTaskList
=
(
$container
)
->
$container
.
find
(
'.task-list-item'
).
removeClass
(
'enabled'
).
find
(
'.task-list-item-checkbox'
).
attr
(
'disabled'
,
'disabled'
)
$container
.
removeClass
(
'is-task-list-enabled'
).
trigger
'tasklist:disabled'
# Disables a collection of TaskList containers.
disableTaskLists
=
(
$containers
)
->
for
container
in
$containers
disableTaskList
$
(
container
)
$
.
fn
.
taskList
=
(
method
)
->
$container
=
$
(
this
).
closest
(
'.js-task-list-container'
)
methods
=
enable
:
enableTaskLists
disable
:
disableTaskLists
methods
[
method
||
'enable'
](
$container
)
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