diff options
author | Peter Marko <peter.marko@siemens.com> | 2019-05-14 09:45:08 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-05-25 02:00:00 +0300 |
commit | 0f322ff6e3c9685b7a254c62ea31afe46bcc5759 (patch) | |
tree | c40b226d4aaba3b5d05f68ac684b3750873439dc /app | |
parent | cf8df783661c841c07481f0f28628b5a71eb2bbf (diff) |
Fix project visibility level validation
Diffstat (limited to 'app')
-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 c9f3cb7062f..bd5ec87bc19 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -334,8 +334,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, @@ -878,6 +878,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? |