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
0c66f683
Commit
0c66f683
authored
Feb 18, 2021
by
Jonas Wälter
Committed by
James Lopez
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix project import error occurring due to default visibility
parent
91817c59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+2
-0
changelogs/unreleased/fix-project-import-visibility-error.yml
...gelogs/unreleased/fix-project-import-visibility-error.yml
+5
-0
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+27
-16
No files found.
app/services/projects/create_service.rb
View file @
0c66f683
...
@@ -19,6 +19,8 @@ module Projects
...
@@ -19,6 +19,8 @@ module Projects
@project
=
Project
.
new
(
params
)
@project
=
Project
.
new
(
params
)
@project
.
visibility_level
=
@project
.
group
.
visibility_level
unless
@project
.
visibility_level_allowed_by_group?
# If a project is newly created it should have shared runners settings
# If a project is newly created it should have shared runners settings
# based on its group having it enabled. This is like the "default value"
# based on its group having it enabled. This is like the "default value"
@project
.
shared_runners_enabled
=
false
if
!
params
.
key?
(
:shared_runners_enabled
)
&&
@project
.
group
&&
@project
.
group
.
shared_runners_setting
!=
'enabled'
@project
.
shared_runners_enabled
=
false
if
!
params
.
key?
(
:shared_runners_enabled
)
&&
@project
.
group
&&
@project
.
group
.
shared_runners_setting
!=
'enabled'
...
...
changelogs/unreleased/fix-project-import-visibility-error.yml
0 → 100644
View file @
0c66f683
---
title
:
Fix project import error occurring due to default visibility
merge_request
:
53827
author
:
Jonas Wälter @wwwjon
type
:
fixed
spec/services/projects/create_service_spec.rb
View file @
0c66f683
...
@@ -349,27 +349,38 @@ RSpec.describe Projects::CreateService, '#execute' do
...
@@ -349,27 +349,38 @@ RSpec.describe Projects::CreateService, '#execute' do
context
'default visibility level'
do
context
'default visibility level'
do
let
(
:group
)
{
create
(
:group
,
:private
)
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:case_name
,
:group_level
,
:project_level
)
do
[
[
'in public group'
,
Gitlab
::
VisibilityLevel
::
PUBLIC
,
Gitlab
::
VisibilityLevel
::
INTERNAL
],
[
'in internal group'
,
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
INTERNAL
],
[
'in private group'
,
Gitlab
::
VisibilityLevel
::
PRIVATE
,
Gitlab
::
VisibilityLevel
::
PRIVATE
]
]
end
with_them
do
before
do
before
do
stub_application_setting
(
default_project_visibility:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
stub_application_setting
(
default_project_visibility:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
group
.
update!
(
visibility_level:
group_level
)
opts
.
merge!
(
opts
.
merge!
(
visibility:
'private'
,
name:
'test'
,
name:
'test'
,
namespace:
group
,
namespace:
group
,
path:
'foo'
path:
'foo'
)
)
end
end
it
'creates a private project'
do
it
'creates project with correct visibility level'
,
:aggregate_failures
do
project
=
create_project
(
user
,
opts
)
project
=
create_project
(
user
,
opts
)
expect
(
project
).
to
respond_to
(
:errors
)
expect
(
project
).
to
respond_to
(
:errors
)
expect
(
project
.
errors
).
to
be_blank
expect
(
project
.
errors
.
any?
).
to
be
(
false
)
expect
(
project
.
visibility_level
).
to
eq
(
project_level
)
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
project
).
to
be_saved
expect
(
project
.
saved?
).
to
be
(
true
)
expect
(
project
).
to
be_valid
e
xpect
(
project
.
valid?
).
to
be
(
true
)
e
nd
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