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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2ef19a24
Commit
2ef19a24
authored
Jun 14, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add view spec for more_actions_dropdown render branches
parent
20dcf5f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
18 deletions
+87
-18
app/views/projects/notes/_more_actions_dropdown.html.haml
app/views/projects/notes/_more_actions_dropdown.html.haml
+17
-18
spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
...s/projects/notes/_more_actions_dropdown.html.haml_spec.rb
+70
-0
No files found.
app/views/projects/notes/_more_actions_dropdown.html.haml
View file @
2ef19a24
-
is_current_user
=
current_user
==
note
.
author
-
return
unless
note_editable
||
!
is_current_user
.dropdown.more-actions
=
button_tag
title:
'More actions'
,
class:
'note-action-button more-actions-toggle has-tooltip btn btn-transparent'
,
data:
{
toggle:
'dropdown'
,
container:
'body'
}
do
=
icon
(
'ellipsis-v'
,
class:
'icon'
)
%ul
.dropdown-menu.more-actions-dropdown.dropdown-open-left
-
if
note_editable
%li
=
button_tag
'Edit comment'
,
class:
'js-note-edit btn btn-transparent'
%li
.divider
-
unless
is_current_user
%li
=
link_to
new_abuse_report_path
(
user_id:
note
.
author
.
id
,
ref_url:
noteable_note_url
(
note
))
do
Report as abuse
-
if
note_editable
%li
=
link_to
note_url
(
note
),
method: :delete
,
data:
{
confirm:
'Are you sure you want to delete this comment?'
},
remote:
true
,
class:
'js-note-delete'
do
%span
.text-danger
Delete comment
-
if
note_editable
||
!
is_current_user
.dropdown.more-actions
=
button_tag
title:
'More actions'
,
class:
'note-action-button more-actions-toggle has-tooltip btn btn-transparent'
,
data:
{
toggle:
'dropdown'
,
container:
'body'
}
do
=
icon
(
'ellipsis-v'
,
class:
'icon'
)
%ul
.dropdown-menu.more-actions-dropdown.dropdown-open-left
-
if
note_editable
%li
=
button_tag
'Edit comment'
,
class:
'js-note-edit btn btn-transparent'
%li
.divider
-
unless
is_current_user
%li
=
link_to
new_abuse_report_path
(
user_id:
note
.
author
.
id
,
ref_url:
noteable_note_url
(
note
))
do
Report as abuse
-
if
note_editable
%li
=
link_to
note_url
(
note
),
method: :delete
,
data:
{
confirm:
'Are you sure you want to delete this comment?'
},
remote:
true
,
class:
'js-note-delete'
do
%span
.text-danger
Delete comment
spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
0 → 100644
View file @
2ef19a24
require
'spec_helper'
describe
'projects/notes/_more_actions_dropdown'
,
:view
do
let
(
:author_user
)
{
create
(
:user
)
}
let
(
:not_author_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:note
)
{
create
(
:note_on_issue
,
author:
author_user
,
noteable:
issue
,
project:
project
)
}
before
do
allow
(
view
).
to
receive
(
:note
).
and_return
(
note
)
assign
(
:project
,
project
)
end
context
'not editable and not current users comment'
do
before
do
allow
(
view
).
to
receive
(
:note_editable
).
and_return
(
false
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
not_author_user
)
render
end
it
'shows Report as abuse button'
do
expect
(
rendered
).
to
have_link
(
'Report as abuse'
)
end
end
context
'not editable and current users comment'
do
before
do
allow
(
view
).
to
receive
(
:note_editable
).
and_return
(
false
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
author_user
)
render
end
it
'does not show the More actions button'
do
expect
(
rendered
).
not_to
have_selector
(
'.dropdown.more-actions'
)
end
end
context
'editable and not current users comment'
do
before
do
allow
(
view
).
to
receive
(
:note_editable
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
not_author_user
)
render
end
it
'shows Report as abuse, Edit and Delete buttons'
do
expect
(
rendered
).
to
have_link
(
'Report as abuse'
)
expect
(
rendered
).
to
have_button
(
'Edit comment'
)
expect
(
rendered
).
to
have_link
(
'Delete comment'
)
end
end
context
'editable and current users comment'
do
before
do
allow
(
view
).
to
receive
(
:note_editable
).
and_return
(
true
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
author_user
)
render
end
it
'shows Edit and Delete buttons'
do
expect
(
rendered
).
to
have_button
(
'Edit comment'
)
expect
(
rendered
).
to
have_link
(
'Delete comment'
)
end
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