List all available labels to the project on the labels API

parent 68f30b2f
...@@ -11,7 +11,7 @@ module API ...@@ -11,7 +11,7 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/labels # GET /projects/:id/labels
get ':id/labels' do 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 end
# Creates a new label # Creates a new label
......
...@@ -12,12 +12,18 @@ describe API::API, api: true do ...@@ -12,12 +12,18 @@ describe API::API, api: true do
end end
describe 'GET /projects/:id/labels' do 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) get api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(2)
expect(json_response.first['name']).to eq(label1.name) expect(json_response.first['name']).to eq(group_label.name)
expect(json_response.second['name']).to eq(label1.name)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment