diff options
author | Stan Hu <stanhu@gmail.com> | 2019-05-14 08:43:08 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-05-14 08:43:08 +0000 |
commit | 99637084b22abdf7b1f6d46daad80faf8181f3cd (patch) | |
tree | 9df6f37282dd64e948e69a08fd3264546df2104c /app/models | |
parent | ddb90d88a08de7748245400ca70b2700fb054017 (diff) | |
parent | b554011271b3acdc58bc2ef5bff1a3d40b69c5dd (diff) | |
download | gitlab-ce-99637084b22abdf7b1f6d46daad80faf8181f3cd.tar.gz |
Merge branch 'fix-project-visibility-level-validation' into 'master'
Fix project visibility level validation
Closes #59379
See merge request gitlab-org/gitlab-ce!28305
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 6351fe24838..ab4da61dcf8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -336,8 +336,8 @@ class Project < ApplicationRecord validates :star_count, numericality: { greater_than_or_equal_to: 0 } validate :check_personal_projects_limit, on: :create validate :check_repository_path_availability, on: :update, if: ->(project) { project.renamed? } - validate :visibility_level_allowed_by_group, if: -> { changes.has_key?(:visibility_level) } - validate :visibility_level_allowed_as_fork, if: -> { changes.has_key?(:visibility_level) } + validate :visibility_level_allowed_by_group, if: :should_validate_visibility_level? + validate :visibility_level_allowed_as_fork, if: :should_validate_visibility_level? validate :check_wiki_path_conflict validate :validate_pages_https_only, if: -> { changes.has_key?(:pages_https_only) } validates :repository_storage, @@ -891,6 +891,10 @@ class Project < ApplicationRecord self.errors.add(:limit_reached, error % { limit: limit }) end + def should_validate_visibility_level? + new_record? || changes.has_key?(:visibility_level) + end + def visibility_level_allowed_by_group return if visibility_level_allowed_by_group? |