diff options
author | John Jarvis <jarv@gitlab.com> | 2019-01-02 12:33:23 +0300 |
---|---|---|
committer | John Jarvis <jarv@gitlab.com> | 2019-01-02 12:33:23 +0300 |
commit | a74700178db77aaba47f3773abe2b7e3c9cf6732 (patch) | |
tree | 74f31ec2394f5a72f3820d384aba621b49f2110e /spec/models/concerns | |
parent | e035e469e4b9f4bb716080be13c56d2ef17779ff (diff) | |
parent | 15526e023daa4c19dc1b619e02946a5dc775c49c (diff) |
Merge branch 'security-master-secret-ci-variables-exposed' into 'master'
[master] Secret CI variables can exposed by creating a tag with the same name as an existing protected branch
See merge request gitlab/gitlabhq!2596
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/has_ref_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/concerns/has_ref_spec.rb b/spec/models/concerns/has_ref_spec.rb new file mode 100644 index 00000000000..8aed72d77a4 --- /dev/null +++ b/spec/models/concerns/has_ref_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe HasRef do + describe '#branch?' do + let(:build) { create(:ci_build) } + + subject { build.branch? } + + context 'is not a tag' do + before do + build.tag = false + end + + it 'return true when tag is set to false' do + is_expected.to be_truthy + end + end + + context 'is not a tag' do + before do + build.tag = true + end + + it 'return false when tag is set to true' do + is_expected.to be_falsey + end + end + end + + describe '#git_ref' do + subject { build.git_ref } + + context 'when tag is true' do + let(:build) { create(:ci_build, tag: true) } + + it 'returns a tag ref' do + is_expected.to start_with(Gitlab::Git::TAG_REF_PREFIX) + end + end + + context 'when tag is false' do + let(:build) { create(:ci_build, tag: false) } + + it 'returns a branch ref' do + is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX) + end + end + + context 'when tag is nil' do + let(:build) { create(:ci_build, tag: nil) } + + it 'returns a branch ref' do + is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX) + end + end + end +end |