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
Léo-Paul Géneau
gitlab-ce
Commits
d3cfa39e
Commit
d3cfa39e
authored
Jul 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New error message recreating projects on pending delete
parent
4404ea86
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
5 deletions
+59
-5
app/models/concerns/valid_attribute.rb
app/models/concerns/valid_attribute.rb
+10
-0
app/models/project.rb
app/models/project.rb
+20
-0
changelogs/unreleased/fix-project-delete-tooltip.yml
changelogs/unreleased/fix-project-delete-tooltip.yml
+4
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+25
-5
No files found.
app/models/concerns/valid_attribute.rb
0 → 100644
View file @
d3cfa39e
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 @
d3cfa39e
...
...
@@ -12,6 +12,7 @@ class Project < ActiveRecord::Base
include
AfterCommitQueue
include
CaseSensitivity
include
TokenAuthenticatable
include
ValidAttribute
include
ProjectFeaturesCompatibility
include
SelectForProjectAuthorization
include
Routable
...
...
@@ -65,6 +66,8 @@ class Project < ActiveRecord::Base
end
end
after_validation
:check_pending_delete
ActsAsTaggableOn
.
strict_case_match
=
true
acts_as_taggable_on
:tags
...
...
@@ -1320,4 +1323,21 @@ class Project < ActiveRecord::Base
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 @
d3cfa39e
---
title
:
Fix project queued for deletion re-creation tooltip
merge_request
:
author
:
spec/models/project_spec.rb
View file @
d3cfa39e
...
...
@@ -190,34 +190,54 @@ describe Project, models: true do
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
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
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
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
project2
=
build
(
:project
,
import_url:
'test://'
)
project2
=
build
(
:
empty_
project
,
import_url:
'test://'
)
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
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