summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorjubianchi <julien.bianchi@pmsipilot.com>2014-08-14 16:17:19 +0200
committerjubianchi <contact@jubianchi.fr>2014-09-04 14:41:31 +0200
commit0ac4a933ffae00adc4b7ab58af9bef15ed8c412b (patch)
treeed2d378510d3c8f2af85dabc89ed10c7f1c6c91c /spec
parentd5c569118cf3a928b3f7e77a017a0df39c2cb1f1 (diff)
downloadgitlab-ce-0ac4a933ffae00adc4b7ab58af9bef15ed8c412b.tar.gz
Filters issues by labels via API
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/issues_spec.rb65
1 files changed, 64 insertions, 1 deletions
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index f70b56b194f..e8eebda95b4 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -9,6 +9,7 @@ describe API::API, api: true do
let!(:label) do
create(:label, title: 'label', color: '#FFAABB', project: project)
end
+ let!(:label_link) { create(:label_link, label: label, target: issue) }
before { project.team << [user, :reporter] }
@@ -58,6 +59,45 @@ describe API::API, api: true do
json_response.first['id'].should == issue.id
json_response.second['id'].should == closed_issue.id
end
+
+ it 'should return an array of labeled issues' do
+ get api("/issues?labels=#{label.title}", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['labels'].should == [label.title]
+ end
+
+ it 'should return an array of labeled issues when at least one label matches' do
+ get api("/issues?labels=#{label.title},foo,bar", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['labels'].should == [label.title]
+ end
+
+ it 'should return an empty array if no issue matches labels' do
+ get api('/issues?labels=foo,bar', user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 0
+ end
+
+ it 'should return an array of labeled issues matching given state' do
+ get api("/issues?labels=#{label.title}&state=opened", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['labels'].should == [label.title]
+ json_response.first['state'].should == 'opened'
+ end
+
+ it 'should return an empty array if no issue matches labels and state filters' do
+ get api("/issues?labels=#{label.title}&state=closed", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 0
+ end
end
end
@@ -68,6 +108,29 @@ describe API::API, api: true do
json_response.should be_an Array
json_response.first['title'].should == issue.title
end
+
+ it 'should return an array of labeled project issues' do
+ get api("/projects/#{project.id}/issues?labels=#{label.title}", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['labels'].should == [label.title]
+ end
+
+ it 'should return an array of labeled project issues when at least one label matches' do
+ get api("/projects/#{project.id}/issues?labels=#{label.title},foo,bar", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 1
+ json_response.first['labels'].should == [label.title]
+ end
+
+ it 'should return an empty array if no project issue matches labels' do
+ get api("/projects/#{project.id}/issues?labels=foo,bar", user)
+ response.status.should == 200
+ json_response.should be_an Array
+ json_response.length.should == 0
+ end
end
describe "GET /projects/:id/issues/:issue_id" do
@@ -182,7 +245,7 @@ describe API::API, api: true do
labels: 'label2', state_event: "close"
response.status.should == 200
- json_response['labels'].should == ['label2']
+ json_response['labels'].should include 'label2'
json_response['state'].should eq "closed"
end
end