diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-10-04 16:52:48 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-10-04 16:52:48 +0000 |
commit | 84c4e920cdf45a182064461a681d4660d9a19073 (patch) | |
tree | f4f7ceec321da7cd16cbbd85405d5ba906f87b80 /spec/models/ci/pipeline_spec.rb | |
parent | bfdac6324c717d014b7271a83c2bf883814f93d7 (diff) | |
parent | 707148ebae4cdda42b2b0cc5f87a6aa49615728f (diff) | |
download | gitlab-ce-84c4e920cdf45a182064461a681d4660d9a19073.tar.gz |
Merge branch 'master' into 'feature/gb/pipeline-only-except-with-modified-paths'feature/gb/pipeline-only-except-with-modified-paths
# Conflicts:
# app/models/ci/pipeline.rb
Diffstat (limited to 'spec/models/ci/pipeline_spec.rb')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 1060417b03b..b56c7f26864 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -2019,4 +2019,34 @@ describe Ci::Pipeline, :mailer do end end end + + describe '#default_branch?' do + let(:default_branch) { 'master'} + + subject { pipeline.default_branch? } + + before do + allow(project).to receive(:default_branch).and_return(default_branch) + end + + context 'when pipeline ref is the default branch of the project' do + let(:pipeline) do + build(:ci_empty_pipeline, status: :created, project: project, ref: default_branch) + end + + it "returns true" do + expect(subject).to be_truthy + end + end + + context 'when pipeline ref is not the default branch of the project' do + let(:pipeline) do + build(:ci_empty_pipeline, status: :created, project: project, ref: 'another_branch') + end + + it "returns false" do + expect(subject).to be_falsey + end + end + end end |