summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-09-06 18:26:22 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-09-06 18:26:22 +0000
commit0a8083c4f1605a17e52137c6da6d8748be1d98df (patch)
treee07dce12cd1ca89b9e404c4d3aee553362f97878
parentcc6f7b0b34d5d2be8445068a0620d0872003d85e (diff)
parent6c012c3b4c9a8b9a89c14403fc7f415c81b90722 (diff)
downloadgitlab-ce-0a8083c4f1605a17e52137c6da6d8748be1d98df.tar.gz
Merge branch 'fix/sm/33281-activerecord-recordinvalid-when-build-has-nil-protected' into 'master'
Fix 422 error when retry job Closes #33281 See merge request !14082
-rw-r--r--app/models/ci/build.rb1
-rw-r--r--app/models/ci/pipeline.rb1
-rw-r--r--spec/services/ci/retry_build_service_spec.rb11
3 files changed, 11 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 28c16d4037f..64c93966dff 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -27,7 +27,6 @@ module Ci
validates :coverage, numericality: true, allow_blank: true
validates :ref, presence: true
- validates :protected, inclusion: { in: [true, false], unless: :importing? }, on: :create
scope :unstarted, ->() { where(runner_id: nil) }
scope :ignore_failures, ->() { where(allow_failure: false) }
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 35d14b6e297..46e5c344fdc 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -36,7 +36,6 @@ module Ci
validates :sha, presence: { unless: :importing? }
validates :ref, presence: { unless: :importing? }
validates :status, presence: { unless: :importing? }
- validates :protected, inclusion: { in: [true, false], unless: :importing? }, on: :create
validate :valid_commit_sha, unless: :importing?
after_create :keep_around_commits, unless: :importing?
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb
index f5ed9ff608f..bbc3a8c79f5 100644
--- a/spec/services/ci/retry_build_service_spec.rb
+++ b/spec/services/ci/retry_build_service_spec.rb
@@ -52,6 +52,17 @@ describe Ci::RetryBuildService do
expect(new_build.send(attribute)).to eq build.send(attribute)
end
end
+
+ context 'when job has nullified protected' do
+ before do
+ build.update_attribute(:protected, nil)
+ end
+
+ it "clones protected build attribute" do
+ expect(new_build.protected).to be_nil
+ expect(new_build.protected).to eq build.protected
+ end
+ end
end
describe 'reject acessors' do