Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGal Schlezinger <galstar@spitfire.co.il>2016-01-31 12:05:47 +0300
committerRémy Coutable <remy@rymai.me>2016-02-11 11:34:07 +0300
commit78e36780be31257a59cb3076ba5402e380ca240f (patch)
treec51ae129173c76bd1e808731f8f63dc9e999ae40 /spec
parentbce482a59a235edf1607dab73dff88aba4300012 (diff)
Added '/api/v3/projects/:id/merge_requests/:merge_request_id/closes_issues' route in the API
Added some documentation for it Added to changelog Added curl example and an attribute table Moved the api route definition from "lib/api/issues.rb" to "lib/api/merge_requests.rb" Fixed the attributes and changed the documentation to be at "merge_requests.md" too Changed generic titles to more specific titles added an underscore added tests. it depends on a newer version of gitlab-test project I'm doing a since I need to add a branch to the `gitlab-test` repo removed the before using 'iid' instead of 'id' in the description to reference the issues. that makes the tests pass Removed the 'closes-issues' key from test_env. so it should pass the tests Moved the two initializations to the describe block Changed the changelog
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/merge_requests.rb6
-rw-r--r--spec/requests/api/merge_requests_spec.rb26
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index 0c6a881f868..777bdb95008 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -73,6 +73,12 @@ 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 d7bfa17b0b1..90faf82fc01 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -448,6 +448,32 @@ 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
+
+ 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)
+ 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
+ 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
+ expect(json_response.length).to eq(0)
+ end
+ end
+
def mr_with_later_created_and_updated_at_time
merge_request
merge_request.created_at += 1.hour