List all available labels to the project on the labels API

This commit is contained in:
Douglas Barbosa Alexandre 2016-10-13 18:53:06 -03:00
parent 68f30b2fff
commit 9b28823854
2 changed files with 10 additions and 4 deletions

View File

@ -11,7 +11,7 @@ module 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

View File

@ -12,12 +12,18 @@ describe API::API, api: true do
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