Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
76652f2a786b
Commit
76652f2a
authored
Jul 21, 2016
by
James Lopez
Browse files
New error message recreating projects on pending delete
parent
f4b01fb99058
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/models/concerns/valid_attribute.rb
0 → 100644
View file @
76652f2a
module
ValidAttribute
extend
ActiveSupport
::
Concern
# Checks whether an attribute has failed validation or not
#
# +attribute+ The symbolised name of the attribute i.e :name
def
valid_attribute?
(
attribute
)
self
.
errors
.
empty?
||
self
.
errors
.
messages
[
attribute
].
nil?
end
end
app/models/project.rb
View file @
76652f2a
...
...
@@ -12,6 +12,7 @@
include
AfterCommitQueue
include
CaseSensitivity
include
TokenAuthenticatable
include
ValidAttribute
include
ProjectFeaturesCompatibility
include
SelectForProjectAuthorization
include
Routable
...
...
@@ -65,6 +66,8 @@
end
end
after_validation
:check_pending_delete
ActsAsTaggableOn
.
strict_case_match
=
true
acts_as_taggable_on
:tags
...
...
@@ -1320,4 +1323,21 @@
stats
=
statistics
||
build_statistics
stats
.
update
(
namespace_id:
namespace_id
)
end
def
check_pending_delete
return
if
valid_attribute?
(
:name
)
&&
valid_attribute?
(
:path
)
return
unless
pending_delete_twin
%i[route route.path name path]
.
each
do
|
error
|
errors
.
delete
(
error
)
end
errors
.
add
(
:base
,
"The project is still being deleted. Please try again later."
)
end
def
pending_delete_twin
return
false
unless
path
Project
.
unscoped
.
where
(
pending_delete:
true
).
find_with_namespace
(
path_with_namespace
)
end
end
changelogs/unreleased/fix-project-delete-tooltip.yml
0 → 100644
View file @
76652f2a
---
title
:
Fix project queued for deletion re-creation tooltip
merge_request
:
author
:
spec/models/project_spec.rb
View file @
76652f2a
...
...
@@ -190,9 +190,9 @@
end
it
'does not allow an invalid URI as import_url'
do
project2
=
build
(
:project
,
import_url:
'invalid://'
)
project2
=
build
(
:
empty_
project
,
import_url:
'invalid://'
)
expect
(
project2
).
not_to
be_valid
end
it
'does allow a valid URI as import_url'
do
...
...
@@ -194,11 +194,11 @@
expect
(
project2
).
not_to
be_valid
end
it
'does allow a valid URI as import_url'
do
project2
=
build
(
:project
,
import_url:
'ssh://test@gitlab.com/project.git'
)
project2
=
build
(
:
empty_
project
,
import_url:
'ssh://test@gitlab.com/project.git'
)
expect
(
project2
).
to
be_valid
end
it
'allows an empty URI'
do
...
...
@@ -200,11 +200,11 @@
expect
(
project2
).
to
be_valid
end
it
'allows an empty URI'
do
project2
=
build
(
:project
,
import_url:
''
)
project2
=
build
(
:
empty_
project
,
import_url:
''
)
expect
(
project2
).
to
be_valid
end
it
'does not produce import data on an empty URI'
do
...
...
@@ -206,11 +206,11 @@
expect
(
project2
).
to
be_valid
end
it
'does not produce import data on an empty URI'
do
project2
=
build
(
:project
,
import_url:
''
)
project2
=
build
(
:
empty_
project
,
import_url:
''
)
expect
(
project2
.
import_data
).
to
be_nil
end
it
'does not produce import data on an invalid URI'
do
...
...
@@ -212,9 +212,9 @@
expect
(
project2
.
import_data
).
to
be_nil
end
it
'does not produce import data on an invalid URI'
do
project2
=
build
(
:project
,
import_url:
'test://'
)
project2
=
build
(
:
empty_
project
,
import_url:
'test://'
)
expect
(
project2
.
import_data
).
to
be_nil
end
...
...
@@ -218,6 +218,26 @@
expect
(
project2
.
import_data
).
to
be_nil
end
describe
'project pending deletion'
do
let!
(
:project_pending_deletion
)
do
create
(
:empty_project
,
pending_delete:
true
)
end
let
(
:new_project
)
do
build
(
:empty_project
,
name:
project_pending_deletion
.
name
,
namespace:
project_pending_deletion
.
namespace
)
end
before
do
new_project
.
validate
end
it
'contains errors related to the project being deleted'
do
expect
(
new_project
.
errors
.
full_messages
.
first
).
to
eq
(
'The project is still being deleted. Please try again later.'
)
end
end
end
describe
'default_scope'
do
...
...
Write
Preview
Supports
Markdown
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