diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-09-11 12:06:33 +0300 |
---|---|---|
committer | Kushal Pandya <kushalspandya@gmail.com> | 2019-09-11 12:06:33 +0300 |
commit | 48b98b5898e15ab4bb1db47e201fef8db68dc34d (patch) | |
tree | 70edcf4953d88d542243fe1d288ff249c02c9d9f /spec/requests/api | |
parent | bfaa96d586668678893e295062495f2c35b73c2a (diff) |
Enables Run Pipeline button to be rendered
In the Merge Request view, under pipelines tab
the user can see a run pipeline button
Adds axios post request to button click
Adds the logic to handle the user click,
refresh the table and disable the button while thee
request is being made
Updates UI for desktop and mobile
Adds specs
Regenerates potfile
Follow-up after review
Uses .finally to avoid code repetition
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 15d6db42760..8179da2f97c 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1033,6 +1033,70 @@ describe API::MergeRequests do end end + describe 'POST /projects/:id/merge_requests/:merge_request_iid/pipelines' do + before do + allow_any_instance_of(Ci::Pipeline) + .to receive(:ci_yaml_file) + .and_return(YAML.dump({ + rspec: { + script: 'ls', + only: ['merge_requests'] + } + })) + end + + let(:project) do + create(:project, :private, :repository, + creator: user, + namespace: user.namespace, + only_allow_merge_if_pipeline_succeeds: false) + end + + let(:merge_request) do + create(:merge_request, :with_detached_merge_request_pipeline, + milestone: milestone1, + author: user, + assignees: [user], + source_project: project, + target_project: project, + title: 'Test', + created_at: base_time) + end + + let(:merge_request_iid) { merge_request.iid } + let(:authenticated_user) { user } + + let(:request) do + post api("/projects/#{project.id}/merge_requests/#{merge_request_iid}/pipelines", authenticated_user) + end + + context 'when authorized' do + it 'creates and returns the new Pipeline' do + expect { request }.to change(Ci::Pipeline, :count).by(1) + expect(response).to have_gitlab_http_status(200) + expect(json_response).to be_a Hash + end + end + + context 'when unauthorized' do + let(:authenticated_user) { create(:user) } + + it 'responds with a blank 404' do + expect { request }.not_to change(Ci::Pipeline, :count) + expect(response).to have_gitlab_http_status(404) + end + end + + context 'when the merge request does not exist' do + let(:merge_request_iid) { 777 } + + it 'responds with a blank 404' do + expect { request }.not_to change(Ci::Pipeline, :count) + expect(response).to have_gitlab_http_status(404) + end + end + end + describe 'POST /projects/:id/merge_requests' do context 'support for deprecated assignee_id' do let(:params) do |