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
59b5eef590c0
Commit
59b5eef5
authored
Sep 12, 2017
by
Felipe Artur
Browse files
Fix project feature being deleted when updating project with invalid visibility level
parent
3622148f9376
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
59b5eef5
...
...
@@ -161,7 +161,7 @@
has_many
:notification_settings
,
as: :source
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_one
:import_data
,
class_name:
'ProjectImportData'
,
inverse_of: :project
,
autosave:
true
has_one
:project_feature
has_one
:project_feature
,
inverse_of: :project
has_one
:statistics
,
class_name:
'ProjectStatistics'
# Container repositories need to remove data from the container registry,
...
...
@@ -190,7 +190,7 @@
has_one
:auto_devops
,
class_name:
'ProjectAutoDevops'
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
accepts_nested_attributes_for
:project_feature
accepts_nested_attributes_for
:project_feature
,
update_only:
true
accepts_nested_attributes_for
:import_data
accepts_nested_attributes_for
:auto_devops
...
...
app/models/project_feature.rb
View file @
59b5eef5
...
...
@@ -41,6 +41,8 @@
# http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to
belongs_to
:project
,
->
{
unscope
(
where: :pending_delete
)
}
validates
:project
,
presence:
true
validate
:repository_children_level
default_value_for
:builds_access_level
,
value:
ENABLED
,
allows_nil:
false
...
...
app/services/projects/update_service.rb
View file @
59b5eef5
...
...
@@ -24,7 +24,10 @@
success
else
error
(
'Project could not be updated!'
)
model_errors
=
project
.
errors
.
full_messages
.
to_sentence
error_message
=
model_errors
.
presence
||
'Project could not be updated!'
error
(
error_message
)
end
end
...
...
changelogs/unreleased/issue_37640.yml
0 → 100644
View file @
59b5eef5
---
title
:
Fix project feature being deleted when updating project with invalid visibility
level
merge_request
:
author
:
type
:
fixed
spec/services/projects/update_service_spec.rb
View file @
59b5eef5
...
...
@@ -57,6 +57,21 @@
end
end
end
context
'When project visibility is higher than parent group'
do
let
(
:group
)
{
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
before
do
project
.
update
(
namespace:
group
,
visibility_level:
group
.
visibility_level
)
end
it
'does not update project visibility level'
do
result
=
update_project
(
project
,
admin
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
expect
(
result
).
to
eq
({
status: :error
,
message:
'Visibility level public is not allowed in a internal group.'
})
expect
(
project
.
reload
).
to
be_internal
end
end
end
describe
'when updating project that has forks'
do
...
...
@@ -159,8 +174,10 @@
it
'returns an error result when record cannot be updated'
do
result
=
update_project
(
project
,
admin
,
{
name:
'foo&bar'
})
expect
(
result
).
to
eq
({
status: :error
,
message:
'Project could not be updated!'
})
expect
(
result
).
to
eq
({
status: :error
,
message:
"Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
})
end
end
...
...
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