diff options
| author | Matija Čupić <matteeyah@gmail.com> | 2019-07-29 07:43:10 +0000 |
|---|---|---|
| committer | Phil Hughes <me@iamphill.com> | 2019-07-29 07:43:10 +0000 |
| commit | a5aa40c5fe93dc3daba8a578f4c09c4e443fcbec (patch) | |
| tree | 34eb74d209b1919f78ce70d89ee0900cd2602780 /spec/models/ci | |
| parent | 946f7c0687760ec49aca582a329d0ec3c7ac3037 (diff) | |
| download | gitlab-ce-a5aa40c5fe93dc3daba8a578f4c09c4e443fcbec.tar.gz | |
Add Job specific variables
Adds Job specific variables to facilitate specifying variables when
running manual jobs.
Diffstat (limited to 'spec/models/ci')
| -rw-r--r-- | spec/models/ci/build_spec.rb | 13 | ||||
| -rw-r--r-- | spec/models/ci/job_variable_spec.rb | 12 |
2 files changed, 24 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index c30cb70e1c1..17c7c05324a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -21,7 +21,8 @@ describe Ci::Build do it { is_expected.to belong_to(:erased_by) } it { is_expected.to have_many(:trace_sections)} it { is_expected.to have_one(:deployment) } - it { is_expected.to have_one(:runner_session)} + it { is_expected.to have_one(:runner_session) } + it { is_expected.to have_many(:job_variables) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to respond_to(:has_trace?) } it { is_expected.to respond_to(:trace) } @@ -2258,6 +2259,16 @@ describe Ci::Build do it { is_expected.to include(manual_variable) } end + context 'when job variable is defined' do + let(:job_variable) { { key: 'first', value: 'first', public: false, masked: false } } + + before do + create(:ci_job_variable, job_variable.slice(:key, :value).merge(job: build)) + end + + it { is_expected.to include(job_variable) } + end + context 'when build is for tag' do let(:tag_variable) do { key: 'CI_COMMIT_TAG', value: 'master', public: true, masked: false } diff --git a/spec/models/ci/job_variable_spec.rb b/spec/models/ci/job_variable_spec.rb new file mode 100644 index 00000000000..b94a914c784 --- /dev/null +++ b/spec/models/ci/job_variable_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Ci::JobVariable do + subject { build(:ci_job_variable) } + + it_behaves_like "CI variable" + + it { is_expected.to belong_to(:job) } + it { is_expected.to validate_uniqueness_of(:key).scoped_to(:job_id) } +end |
