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
93ff65e1
Commit
93ff65e1
authored
Aug 30, 2021
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test project namespace is destroyed with project_namespace.rb
Changelog: added
parent
eb506c84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
app/models/namespace.rb
app/models/namespace.rb
+1
-1
spec/factories/namespaces/project_namespace.rb
spec/factories/namespaces/project_namespace.rb
+12
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+11
-0
No files found.
app/models/namespace.rb
View file @
93ff65e1
...
...
@@ -57,7 +57,7 @@ class Namespace < ApplicationRecord
has_one
:admin_note
,
inverse_of: :namespace
accepts_nested_attributes_for
:admin_note
,
update_only:
true
validates
:owner
,
presence:
true
,
unless:
->
(
n
)
{
n
.
type
==
"Group"
}
validates
:owner
,
presence:
true
,
unless:
->
(
n
)
{
n
.
type
==
"Group"
||
n
.
type
==
'Namespaces::ProjectNamespace'
}
validates
:name
,
presence:
true
,
length:
{
maximum:
255
}
...
...
spec/factories/namespaces/project_namespace.rb
0 → 100644
View file @
93ff65e1
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:project_namespace
,
class:
'Namespaces::ProjectNamespace'
do
project
sequence
(
:name
)
{
|
n
|
"project_namespace
#{
n
}
"
}
path
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
type
{
'Namespaces::ProjectNamespace'
}
owner
{
nil
}
project_creation_level
{
::
Gitlab
::
Access
::
MAINTAINER_PROJECT_ACCESS
}
end
end
spec/models/project_spec.rb
View file @
93ff65e1
...
...
@@ -185,6 +185,17 @@ RSpec.describe Project, factory_default: :keep do
end
end
context
'when destroying project'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project_namespace
)
{
create
(
:project_namespace
,
project:
project
)
}
it
'also destroys the associated ProjectNamespace'
do
project
.
destroy!
expect
{
project_namespace
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
context
'when creating a new project'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
...
...
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