Skip to content
Snippets Groups Projects
Commit ce7c0ac3 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Add validation for protected attributes

parent f3d3cecf
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -26,6 +26,7 @@ module Ci
 
validates :coverage, numericality: true, allow_blank: true
validates :ref, presence: true
validates :protected, inclusion: { in: [ true, false ] }, on: :create
 
scope :unstarted, ->() { where(runner_id: nil) }
scope :ignore_failures, ->() { where(allow_failure: false) }
Loading
Loading
Loading
Loading
@@ -36,6 +36,7 @@ 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?
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ module Ci
CLONE_ACCESSORS = %i[pipeline project ref tag options commands name
allow_failure stage_id stage stage_idx trigger_request
yaml_variables when environment coverage_regex
description tag_list].freeze
description tag_list protected].freeze
 
def execute(build)
reprocess!(build).tap do |new_build|
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ FactoryGirl.define do
started_at 'Di 29. Okt 09:51:28 CET 2013'
finished_at 'Di 29. Okt 09:53:28 CET 2013'
commands 'ls -a'
protected false
 
options do
{
Loading
Loading
@@ -227,11 +228,11 @@ FactoryGirl.define do
self.when 'manual'
end
 
trait(:protected) do
trait :protected do
protected true
end
 
trait(:unprotected) do
trait :unprotected do
protected false
end
end
Loading
Loading
Loading
Loading
@@ -4,6 +4,7 @@ FactoryGirl.define do
ref 'master'
sha '97de212e80737a608d939f648d959671fb0a0142'
status 'pending'
protected false
 
project
 
Loading
Loading
@@ -59,6 +60,14 @@ FactoryGirl.define do
trait :failed do
status :failed
end
trait :protected do
protected true
end
trait :unprotected do
protected false
end
end
end
end
Loading
Loading
@@ -59,7 +59,11 @@ describe Ci::Build do
end
 
context 'when protected is false' do
let!(:job) { create(:ci_build, protected: nil) }
let!(:job) { create(:ci_build) }
before do
job.update_attribute(:protected, nil)
end
 
it { is_expected.not_to include(job) }
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment