diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-03-28 17:04:14 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-05-08 11:29:10 -0300 |
commit | d9bebd89dfcf7e4b163b271eea3d7a5c3e99fb5d (patch) | |
tree | 94a54961d28098ea0675f2cb15ea19bbe27166e6 /spec | |
parent | 1bf2dacf2002fabf3b7bd364031d9020e5d0b624 (diff) | |
download | gitlab-ce-d9bebd89dfcf7e4b163b271eea3d7a5c3e99fb5d.tar.gz |
Fix specs 2
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/features/cycle_analytics_spec.rb | 13 | ||||
-rw-r--r-- | spec/features/merge_requests/widget_spec.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/cycle_analytics/events_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/merge_requests/update_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/pipeline_metrics_worker_spec.rb | 2 |
9 files changed, 24 insertions, 16 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index bc13a8123a5..d9dae999a87 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -1200,7 +1200,10 @@ describe Projects::MergeRequestsController do let(:status) { pipeline.detailed_status(double('user')) } - before { get_pipeline_status } + before do + merge_request.update(head_pipeline: pipeline) + get_pipeline_status + end it 'return a detailed head_pipeline status in json' do expect(response).to have_http_status(:ok) diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb index 57826fe872b..5553687707d 100644 --- a/spec/features/cycle_analytics_spec.rb +++ b/spec/features/cycle_analytics_spec.rb @@ -9,14 +9,17 @@ feature 'Cycle Analytics', feature: true, js: true do let(:mr) { create_merge_request_closing_issue(issue, commit_message: "References #{issue.to_reference}") } let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha) } - before { mr.update(head_pipeline: pipeline) } + before do + allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue]) + end context 'as an allowed user' do context 'when project is new' do before do project.add_master(user) - mr.update(head_pipeline_id: pipeline.id) + login_as(user) + visit namespace_project_cycle_analytics_path(project.namespace, project) wait_for_ajax end @@ -33,8 +36,8 @@ feature 'Cycle Analytics', feature: true, js: true do context "when there's cycle analytics data" do before do - project.team << [user, :master] - + mr.update(head_pipeline: pipeline) + project.add_master(user) create_cycle deploy_master @@ -87,7 +90,7 @@ feature 'Cycle Analytics', feature: true, js: true do context "as a guest" do before do - project.team << [guest, :guest] + project.add_guest(guest) allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue]) create_cycle diff --git a/spec/features/merge_requests/widget_spec.rb b/spec/features/merge_requests/widget_spec.rb index 02193dbfc8d..b1255ac0bd5 100644 --- a/spec/features/merge_requests/widget_spec.rb +++ b/spec/features/merge_requests/widget_spec.rb @@ -89,7 +89,7 @@ describe 'Merge request', :feature, :js do statuses: [commit_status]) create(:ci_build, :pending, pipeline: pipeline) - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) visit namespace_project_merge_request_path(project.namespace, project, merge_request) end @@ -111,7 +111,7 @@ describe 'Merge request', :feature, :js do status: :manual ) - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) visit namespace_project_merge_request_path(project.namespace, project, @@ -136,7 +136,7 @@ describe 'Merge request', :feature, :js do statuses: [commit_status]) create(:ci_build, :pending, pipeline: pipeline) - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) visit namespace_project_merge_request_path(project.namespace, project, merge_request) end diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb index 8753679e233..3610a0354e8 100644 --- a/spec/lib/gitlab/cycle_analytics/events_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb @@ -130,7 +130,7 @@ describe 'cycle analytics events' do end before do - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) create(:ci_build, pipeline: pipeline, status: :success, author: user) create(:ci_build, pipeline: pipeline, status: :success, author: user) @@ -228,7 +228,7 @@ describe 'cycle analytics events' do end before do - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) create(:ci_build, pipeline: pipeline, status: :success, author: user) create(:ci_build, pipeline: pipeline, status: :success, author: user) diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 86ed37b50aa..06e990a0574 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1045,7 +1045,7 @@ describe Ci::Pipeline, models: true do it "returns merge requests whose `diff_head_sha` matches the pipeline's SHA" do allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { 'a288a022a53a5a944fae87bcec6efc87b7061808' } - merge_request = create(:merge_request, source_project: project, head_pipeline: pipeline, , source_branch: pipeline.ref) + merge_request = create(:merge_request, source_project: project, head_pipeline: pipeline, source_branch: pipeline.ref) expect(pipeline.merge_requests).to eq([merge_request]) end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 45a5cd049a2..1db1640f5e5 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1507,6 +1507,8 @@ describe MergeRequest, models: true do status: status) merge_request.update(head_pipeline: pipeline) + + pipeline end let(:project) { create(:project, :public, :repository, only_allow_merge_if_pipeline_succeeds: true) } @@ -1592,7 +1594,7 @@ describe MergeRequest, models: true do context 'with running pipeline' do before do - merge_request.update(head_pipeline: create_pipeline(:running)) + create_pipeline(:running) end it 'is mergeable' do diff --git a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb index b0304b3b73f..3ef5135e6a3 100644 --- a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb +++ b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb @@ -128,7 +128,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do sha: mr_conflict.diff_head_sha, status: 'success') end - before { mr_conflict.update(head_pipeline_id: conflict_pipeline.id) } + before { mr_conflict.update(head_pipeline: conflict_pipeline) } it 'does not merge the merge request' do expect(MergeWorker).not_to receive(:perform_async) diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index e5071c2f447..07f5440cc36 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -179,7 +179,7 @@ describe MergeRequests::UpdateService, services: true do ref: merge_request.source_branch, sha: merge_request.diff_head_sha) - merge_request.update(head_pipeline_id: pipeline.id) + merge_request.update(head_pipeline: pipeline) expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user). and_return(service_mock) diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb index dbf2b7251c6..ef71125c0b6 100644 --- a/spec/workers/pipeline_metrics_worker_spec.rb +++ b/spec/workers/pipeline_metrics_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe PipelineMetricsWorker do let(:project) { create(:project, :repository) } - let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref, head_pipeline_id: pipeline.id) } + let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref, head_pipeline: pipeline) } let(:pipeline) do create(:ci_empty_pipeline, |