diff options
author | Rémy Coutable <remy@rymai.me> | 2016-02-10 17:11:23 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-02-11 09:34:07 +0100 |
commit | b91d1890a8f33566d52c653e9ae083a3a3329590 (patch) | |
tree | f9468f1f8f218ae525b9a5a8c7c1715e4007c089 /spec | |
parent | 78e36780be31257a59cb3076ba5402e380ca240f (diff) | |
download | gitlab-ce-b91d1890a8f33566d52c653e9ae083a3a3329590.tar.gz |
Pass current_user to merge_request.closes_issues in API ans streamline MR API specsSchniz/gitlab-ce-feature/merge-request-closes-issues-in-api
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/merge_requests.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 20 |
2 files changed, 8 insertions, 18 deletions
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 777bdb95008..0c6a881f868 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -73,12 +73,6 @@ FactoryGirl.define do merge_user author end - trait :with_closes_issues do - source_branch "markdown" - target_branch "master" - state :opened - end - factory :closed_merge_request, traits: [:closed] factory :reopened_merge_request, traits: [:reopened] factory :merge_request_with_diffs, traits: [:with_diffs] diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 90faf82fc01..7a722777d59 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -448,25 +448,21 @@ describe API::API, api: true do end end - describe "GET :id/merge_requests/:merge_request_id/closes_issues" do - let(:merge_request_with_closes_issues) { create(:merge_request, :with_closes_issues, author: user, assignee: user, source_project: project, target_project: project, title: "Closed ##{issue.id}", created_at: base_time + 3.seconds, description: "This should close ##{issue.iid}") } - let(:issue) do - create :issue, - author: user, - assignee: user, - project: project, - milestone: nil - end + describe 'GET :id/merge_requests/:merge_request_id/closes_issues' do + it 'returns the issue that will be closed on merge' do + issue = create(:issue, project: project) + mr = merge_request.tap do |mr| + mr.update_attribute(:description, "Closes #{issue.to_reference(mr.project)}") + end - it "should return the issues that will be closed on merge" do - get api("/projects/#{project.id}/merge_requests/#{merge_request_with_closes_issues.id}/closes_issues", user) + get api("/projects/#{project.id}/merge_requests/#{mr.id}/closes_issues", user) expect(response.status).to eq(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(issue.id) end - it "should return an empty array when there are no issues to be closed" do + it 'returns an empty array when there are no issues to be closed' do get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/closes_issues", user) expect(response.status).to eq(200) expect(json_response).to be_an Array |