summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-15 13:59:11 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-22 23:09:24 +0100
commit4319b15a78be70ccabb31a25ffba37f77de27b28 (patch)
treef147f78dfb81994c1b063bf9b38beb182a58cac9
parent44fed816ee510c0aa56406c9221a0ffb2601d8f5 (diff)
downloadgitlab-ce-4319b15a78be70ccabb31a25ffba37f77de27b28.tar.gz
Condition associated variable validation in Project and Group
-rw-r--r--app/models/group.rb3
-rw-r--r--app/models/project.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 45160875dfb..e7640d1c8ec 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -26,7 +26,7 @@ class Group < Namespace
has_many :shared_projects, through: :project_group_links, source: :project
has_many :notification_settings, dependent: :destroy, as: :source # rubocop:disable Cop/ActiveRecordDependent
has_many :labels, class_name: 'GroupLabel'
- has_many :variables, class_name: 'Ci::GroupVariable', validate: false
+ has_many :variables, class_name: 'Ci::GroupVariable'
has_many :custom_attributes, class_name: 'GroupCustomAttribute'
has_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -37,6 +37,7 @@ class Group < Namespace
validate :visibility_level_allowed_by_sub_groups
validate :visibility_level_allowed_by_parent
validates :variables, variable_duplicates: true
+ validates_associated :variables, if: proc { |group| group.errors[:variables].nil? }
validates :two_factor_grace_period, presence: true, numericality: { greater_than_or_equal_to: 0 }
diff --git a/app/models/project.rb b/app/models/project.rb
index fd09bb6a4d3..4ad6f025e5c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -210,7 +210,7 @@ class Project < ActiveRecord::Base
has_many :build_trace_section_names, class_name: 'Ci::BuildTraceSectionName'
has_many :runner_projects, class_name: 'Ci::RunnerProject'
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
- has_many :variables, class_name: 'Ci::Variable', validate: false
+ has_many :variables, class_name: 'Ci::Variable'
has_many :triggers, class_name: 'Ci::Trigger'
has_many :environments
has_many :deployments