diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-12-05 14:39:15 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-12-05 14:39:15 +0000 |
commit | a6778fc647d83c8fbdca69e1bb2d38b490853ba8 (patch) | |
tree | 93d1d2bc4c5bd85e5255b9cfdf29a88ca9af127f /spec/models | |
parent | 107ff10eb68aa8715b8bfc5a8ae13bf2f4453355 (diff) | |
download | gitlab-ce-a6778fc647d83c8fbdca69e1bb2d38b490853ba8.tar.gz |
Rename project's pipelines relation
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 29 |
2 files changed, 30 insertions, 6 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index dcaea9d3f83..ba9540c84d4 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -33,8 +33,9 @@ describe Ci::Pipeline, :mailer do describe 'associations' do it 'has a bidirectional relationship with projects' do - expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:pipelines) - expect(Project.reflect_on_association(:pipelines).has_inverse?).to eq(:project) + expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:all_pipelines) + expect(Project.reflect_on_association(:all_pipelines).has_inverse?).to eq(:project) + expect(Project.reflect_on_association(:ci_pipelines).has_inverse?).to eq(:project) end end @@ -1186,7 +1187,7 @@ describe Ci::Pipeline, :mailer do create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop') create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline2, name: 'rubocop') - pipelines = project.pipelines.to_a + pipelines = project.ci_pipelines.to_a pipelines.each(&:number_of_warnings) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 54ad3c858d5..c0bc9eb2ef0 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -63,7 +63,7 @@ describe Project do it { is_expected.to have_one(:forked_from_project).through(:fork_network_member) } it { is_expected.to have_one(:auto_devops).class_name('ProjectAutoDevops') } it { is_expected.to have_many(:commit_statuses) } - it { is_expected.to have_many(:pipelines) } + it { is_expected.to have_many(:ci_pipelines) } it { is_expected.to have_many(:builds) } it { is_expected.to have_many(:build_trace_section_names)} it { is_expected.to have_many(:runner_projects) } @@ -142,6 +142,29 @@ describe Project do expect(subject.boards.size).to eq 1 end end + + describe 'ci_pipelines association' do + context 'when feature flag pipeline_ci_sources_only is enabled' do + it 'returns only pipelines from ci_sources' do + stub_feature_flags(pipeline_ci_sources_only: true) + + expect(Ci::Pipeline).to receive(:ci_sources).and_call_original + + subject.ci_pipelines + end + end + + context 'when feature flag pipeline_ci_sources_only is disabled' do + it 'returns all pipelines' do + stub_feature_flags(pipeline_ci_sources_only: false) + + expect(Ci::Pipeline).not_to receive(:ci_sources).and_call_original + expect(Ci::Pipeline).to receive(:all).and_call_original.at_least(:once) + + subject.ci_pipelines + end + end + end end describe 'modules' do @@ -3373,7 +3396,7 @@ describe Project do context 'with a ref that is not the default branch' do it 'returns the latest successful pipeline for the given ref' do - expect(project.pipelines).to receive(:latest_successful_for).with('foo') + expect(project.ci_pipelines).to receive(:latest_successful_for).with('foo') project.latest_successful_pipeline_for('foo') end @@ -3401,7 +3424,7 @@ describe Project do it 'memoizes and returns the latest successful pipeline for the default branch' do pipeline = double(:pipeline) - expect(project.pipelines).to receive(:latest_successful_for) + expect(project.ci_pipelines).to receive(:latest_successful_for) .with(project.default_branch) .and_return(pipeline) .once |