Commit 44aa6b90ddde3a7babc6ed9f50d73040d6184789
1 parent
fb919a63
Exists in
spb-stable
and in
3 other branches
added api method to return labels of a given project
Showing
3 changed files
with
39 additions
and
0 deletions
Show diff stats
lib/api/entities.rb
lib/api/projects.rb
... | ... | @@ -215,6 +215,15 @@ module API |
215 | 215 | @users = paginate @users |
216 | 216 | present @users, with: Entities::User |
217 | 217 | end |
218 | + | |
219 | + # Get a labels list | |
220 | + # | |
221 | + # Example Request: | |
222 | + # GET /users | |
223 | + get ':id/labels' do | |
224 | + @labels = user_project.issues_labels | |
225 | + present @labels, with: Entities::Label | |
226 | + end | |
218 | 227 | end |
219 | 228 | end |
220 | 229 | end | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe API::API do | |
4 | + include ApiHelpers | |
5 | + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } | |
6 | + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } | |
7 | + | |
8 | + let(:user) { create(:user) } | |
9 | + let!(:project) { create(:project, namespace: user.namespace ) } | |
10 | + let!(:issue) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } | |
11 | + before { project.team << [user, :reporter] } | |
12 | + | |
13 | + | |
14 | + describe "GET /projects/:id/labels" do | |
15 | + it "should return project labels" do | |
16 | + get api("/projects/#{project.id}/labels", user) | |
17 | + response.status.should == 200 | |
18 | + json_response.should be_an Array | |
19 | + json_response.first['name'].should == 'label1' | |
20 | + json_response.last['name'].should == 'label2' | |
21 | + end | |
22 | + end | |
23 | + | |
24 | + | |
25 | +end | |
26 | + | ... | ... |