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
34bf5d86
Commit
34bf5d86
authored
Mar 13, 2017
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display error message when deleting tag in web UI fails
parent
32da7602
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
11 deletions
+48
-11
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+18
-4
app/services/tags/destroy_service.rb
app/services/tags/destroy_service.rb
+2
-0
app/views/projects/tags/destroy.js.haml
app/views/projects/tags/destroy.js.haml
+3
-1
changelogs/unreleased/handle-failure-when-deleting-tags.yml
changelogs/unreleased/handle-failure-when-deleting-tags.yml
+4
-0
spec/features/tags/master_deletes_tag_spec.rb
spec/features/tags/master_deletes_tag_spec.rb
+21
-6
No files found.
app/controllers/projects/tags_controller.rb
View file @
34bf5d86
...
@@ -41,13 +41,27 @@ class Projects::TagsController < Projects::ApplicationController
...
@@ -41,13 +41,27 @@ class Projects::TagsController < Projects::ApplicationController
end
end
def
destroy
def
destroy
Tags
::
DestroyService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
result
=
Tags
::
DestroyService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
respond_to
do
|
format
|
respond_to
do
|
format
|
if
result
[
:status
]
==
:success
format
.
html
do
format
.
html
do
redirect_to
namespace_project_tags_path
(
@project
.
namespace
,
@project
)
redirect_to
namespace_project_tags_path
(
@project
.
namespace
,
@project
)
end
end
format
.
js
format
.
js
else
@error
=
result
[
:message
]
format
.
html
do
redirect_to
namespace_project_tags_path
(
@project
.
namespace
,
@project
),
alert:
@error
end
format
.
js
do
render
status: :unprocessable_entity
end
end
end
end
end
end
end
end
app/services/tags/destroy_service.rb
View file @
34bf5d86
...
@@ -21,6 +21,8 @@ module Tags
...
@@ -21,6 +21,8 @@ module Tags
else
else
error
(
'Failed to remove tag'
)
error
(
'Failed to remove tag'
)
end
end
rescue
GitHooksService
::
PreReceiveError
=>
ex
error
(
ex
.
message
)
end
end
def
error
(
message
,
return_code
=
400
)
def
error
(
message
,
return_code
=
400
)
...
...
app/views/projects/tags/destroy.js.haml
View file @
34bf5d86
-
if
@repository
.
tags
.
empty?
-
if
@error
.
present?
new Flash('
#{
escape_javascript
(
@error
)
}
', 'alert');
-
elsif
@repository
.
tags
.
empty?
$('.tags').load(document.URL + ' .nothing-here-block').hide().fadeIn(1000)
$('.tags').load(document.URL + ' .nothing-here-block').hide().fadeIn(1000)
changelogs/unreleased/handle-failure-when-deleting-tags.yml
0 → 100644
View file @
34bf5d86
---
title
:
Display error message when deleting tag in web UI fails
merge_request
:
9906
author
:
spec/features/tags/master_deletes_tag_spec.rb
View file @
34bf5d86
...
@@ -10,16 +10,12 @@ feature 'Master deletes tag', feature: true do
...
@@ -10,16 +10,12 @@ feature 'Master deletes tag', feature: true do
visit
namespace_project_tags_path
(
project
.
namespace
,
project
)
visit
namespace_project_tags_path
(
project
.
namespace
,
project
)
end
end
context
'from the tags list page'
do
context
'from the tags list page'
,
js:
true
do
scenario
'deletes the tag'
do
scenario
'deletes the tag'
do
expect
(
page
).
to
have_content
'v1.1.0'
expect
(
page
).
to
have_content
'v1.1.0'
page
.
within
(
'.content'
)
do
delete_first_tag
first
(
'.btn-remove'
).
click
end
expect
(
current_path
).
to
eq
(
namespace_project_tags_path
(
project
.
namespace
,
project
))
expect
(
page
).
not_to
have_content
'v1.1.0'
expect
(
page
).
not_to
have_content
'v1.1.0'
end
end
end
end
...
@@ -37,4 +33,23 @@ feature 'Master deletes tag', feature: true do
...
@@ -37,4 +33,23 @@ feature 'Master deletes tag', feature: true do
expect
(
page
).
not_to
have_content
'v1.0.0'
expect
(
page
).
not_to
have_content
'v1.0.0'
end
end
end
end
context
'when pre-receive hook fails'
,
js:
true
do
before
do
allow_any_instance_of
(
GitHooksService
).
to
receive
(
:execute
)
.
and_raise
(
GitHooksService
::
PreReceiveError
,
'Do not delete tags'
)
end
scenario
'shows the error message'
do
delete_first_tag
expect
(
page
).
to
have_content
(
'Do not delete tags'
)
end
end
def
delete_first_tag
page
.
within
(
'.content'
)
do
first
(
'.btn-remove'
).
click
end
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