summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStuart Pook <s.pook@criteo.com>2014-04-04 18:32:53 +0200
committerStuart Pook <s.pook@criteo.com>2014-04-07 16:18:25 +0200
commit66209fbc7668b5b64b34c2997185223891211829 (patch)
tree1d9597aed58c1770bee973c92c90fe8aca56aa8a /spec
parent650d0bc695eb0f874561b8d4ed3fc86510573fba (diff)
downloadgitlab-ce-66209fbc7668b5b64b34c2997185223891211829.tar.gz
Add optional parameter to list merge requests
Add an optional parameter to list merge requests to restrict the returned merge requests to those that are "opened", "merged" or "closed". By default all merge requests are returned. Note that "all" can be given to explicitly request all merge requests.
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/merge_requests_spec.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 9530f7ceb04..0ab5b136820 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -7,6 +7,8 @@ describe API::API do
let(:user) { create(:user) }
let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, target_project: project, title: "Test") }
+ let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") }
+ let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") }
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
before {
project.team << [user, :reporters]
@@ -21,12 +23,42 @@ describe API::API do
end
context "when authenticated" do
- it "should return an array of merge_requests" do
+ it "should return an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests", user)
response.status.should == 200
json_response.should be_an Array
+ json_response.length.should == 3
json_response.first['title'].should == merge_request.title
end
+ it "should return an array of all merge_requests" do
+ get api("/projects/#{project.id}/merge_requests?state", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 3
+ json_response.first['title'].should == merge_request.title
+ end
+ it "should return an array of open merge_requests" do
+ get api("/projects/#{project.id}/merge_requests?state=opened", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['title'].should == merge_request.title
+ end
+ it "should return an array of closed merge_requests" do
+ get api("/projects/#{project.id}/merge_requests?state=closed", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 2
+ json_response.first['title'].should == merge_request_closed.title
+ json_response.second['title'].should == merge_request_merged.title
+ end
+ it "should return an array of merged merge_requests" do
+ get api("/projects/#{project.id}/merge_requests?state=merged", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['title'].should == merge_request_merged.title
+ end
end
end