Skip to content

Commit

Permalink
List all available labels to the project on the labels API
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalexandre committed Oct 19, 2016
1 parent 68f30b2 commit 9b28823
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/api/labels.rb
Expand Up @@ -11,7 +11,7 @@ class Labels < Grape::API
# Example Request:
# GET /projects/:id/labels
get ':id/labels' do
present user_project.labels, with: Entities::Label, current_user: current_user
present available_labels, with: Entities::Label, current_user: current_user
end

# Creates a new label
Expand Down
12 changes: 9 additions & 3 deletions spec/requests/api/labels_spec.rb
Expand Up @@ -12,12 +12,18 @@
end

describe 'GET /projects/:id/labels' do
it 'returns project labels' do
it 'returns all available labels to the project' do
group = create(:group)
group_label = create(:group_label, group: group)
project.update(group: group)

get api("/projects/#{project.id}/labels", user)

expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first['name']).to eq(label1.name)
expect(json_response.size).to eq(2)
expect(json_response.first['name']).to eq(group_label.name)
expect(json_response.second['name']).to eq(label1.name)
end
end

Expand Down

0 comments on commit 9b28823

Please sign in to comment.