From ce7c0ac3dbdc3f2f2f34b39bf5ef3755e79e9d42 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 31 Aug 2017 21:13:40 +0900 Subject: Add validation for protected attributes --- spec/factories/ci/builds.rb | 5 +++-- spec/factories/ci/pipelines.rb | 9 +++++++++ spec/models/ci/build_spec.rb | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index f8922275860..bdc3e8acc07 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -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 { @@ -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 diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index e83a0e599a8..5b51f5898a3 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -4,6 +4,7 @@ FactoryGirl.define do ref 'master' sha '97de212e80737a608d939f648d959671fb0a0142' status 'pending' + protected false project @@ -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 diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a94fdbf8434..cab59db3580 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -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 -- cgit v1.2.1