diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-18 01:52:17 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-19 02:04:31 +0300 |
commit | b44a2c801a64fb282cea794871fcfcf81e4ec539 (patch) | |
tree | 32e699b6efa548048abe11f29f84e85e3d2a034f /spec/requests/api/labels_spec.rb | |
parent | 5d68c23792e87e710877e4baf57605bcf11a6cb5 (diff) |
Update specs to rails5 format
Updates specs to use new rails5 format.
The old format:
`get :show, { some: params }, { some: headers }`
The new format:
`get :show, params: { some: params }, headers: { some: headers }`
Diffstat (limited to 'spec/requests/api/labels_spec.rb')
-rw-r--r-- | spec/requests/api/labels_spec.rb | 152 |
1 files changed, 97 insertions, 55 deletions
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index b8a4a04a7e4..49eea2e362b 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -70,10 +70,12 @@ describe API::Labels do describe 'POST /projects/:id/labels' do it 'returns created label when all params' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAABB', - description: 'test', - priority: 2 + params: { + name: 'Foo', + color: '#FFAABB', + description: 'test', + priority: 2 + } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('Foo') @@ -84,8 +86,10 @@ describe API::Labels do it 'returns created label when only required params' do post api("/projects/#{project.id}/labels", user), - name: 'Foo & Bar', - color: '#FFAABB' + params: { + name: 'Foo & Bar', + color: '#FFAABB' + } expect(response.status).to eq(201) expect(json_response['name']).to eq('Foo & Bar') @@ -96,9 +100,11 @@ describe API::Labels do it 'creates a prioritized label' do post api("/projects/#{project.id}/labels", user), - name: 'Foo & Bar', - color: '#FFAABB', - priority: 3 + params: { + name: 'Foo & Bar', + color: '#FFAABB', + priority: 3 + } expect(response.status).to eq(201) expect(json_response['name']).to eq('Foo & Bar') @@ -108,35 +114,41 @@ describe API::Labels do end it 'returns a 400 bad request if name not given' do - post api("/projects/#{project.id}/labels", user), color: '#FFAABB' + post api("/projects/#{project.id}/labels", user), params: { color: '#FFAABB' } expect(response).to have_gitlab_http_status(400) end it 'returns a 400 bad request if color not given' do - post api("/projects/#{project.id}/labels", user), name: 'Foobar' + post api("/projects/#{project.id}/labels", user), params: { name: 'Foobar' } expect(response).to have_gitlab_http_status(400) end it 'returns 400 for invalid color' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAA' + params: { + name: 'Foo', + color: '#FFAA' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for too long color code' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAAFFFF' + params: { + name: 'Foo', + color: '#FFAAFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for invalid name' do post api("/projects/#{project.id}/labels", user), - name: ',', - color: '#FFAABB' + params: { + name: ',', + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -147,8 +159,10 @@ describe API::Labels do project.update(group: group) post api("/projects/#{project.id}/labels", user), - name: group_label.name, - color: '#FFAABB' + params: { + name: group_label.name, + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') @@ -156,17 +170,21 @@ describe API::Labels do it 'returns 400 for invalid priority' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAAFFFF', - priority: 'foo' + params: { + name: 'Foo', + color: '#FFAAFFFF', + priority: 'foo' + } expect(response).to have_gitlab_http_status(400) end it 'returns 409 if label already exists in project' do post api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFAABB' + params: { + name: 'label1', + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end @@ -174,13 +192,13 @@ describe API::Labels do describe 'DELETE /projects/:id/labels' do it 'returns 204 for existing label' do - delete api("/projects/#{project.id}/labels", user), name: 'label1' + delete api("/projects/#{project.id}/labels", user), params: { name: 'label1' } expect(response).to have_gitlab_http_status(204) end it 'returns 404 for non existing label' do - delete api("/projects/#{project.id}/labels", user), name: 'label2' + delete api("/projects/#{project.id}/labels", user), params: { name: 'label2' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end @@ -199,10 +217,12 @@ describe API::Labels do describe 'PUT /projects/:id/labels' do it 'returns 200 if name and colors and description are changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: 'New Label', - color: '#FFFFFF', - description: 'test' + params: { + name: 'label1', + new_name: 'New Label', + color: '#FFFFFF', + description: 'test' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq('#FFFFFF') @@ -211,8 +231,10 @@ describe API::Labels do it 'returns 200 if name is changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: 'New Label' + params: { + name: 'label1', + new_name: 'New Label' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq(label1.color) @@ -220,8 +242,10 @@ describe API::Labels do it 'returns 200 if colors is changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFFFFF' + params: { + name: 'label1', + color: '#FFFFFF' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(label1.name) expect(json_response['color']).to eq('#FFFFFF') @@ -229,8 +253,10 @@ describe API::Labels do it 'returns 200 if description is changed' do put api("/projects/#{project.id}/labels", user), - name: 'bug', - description: 'test' + params: { + name: 'bug', + description: 'test' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(priority_label.name) @@ -240,8 +266,10 @@ describe API::Labels do it 'returns 200 if priority is changed' do put api("/projects/#{project.id}/labels", user), - name: 'bug', - priority: 10 + params: { + name: 'bug', + priority: 10 + } expect(response.status).to eq(200) expect(json_response['name']).to eq(priority_label.name) @@ -250,8 +278,10 @@ describe API::Labels do it 'returns 200 if a priority is added' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - priority: 3 + params: { + name: 'label1', + priority: 3 + } expect(response.status).to eq(200) expect(json_response['name']).to eq(label1.name) @@ -260,8 +290,10 @@ describe API::Labels do it 'returns 200 if the priority is removed' do put api("/projects/#{project.id}/labels", user), - name: priority_label.name, - priority: nil + params: { + name: priority_label.name, + priority: nil + } expect(response.status).to eq(200) expect(json_response['name']).to eq(priority_label.name) @@ -270,19 +302,21 @@ describe API::Labels do it 'returns 404 if label does not exist' do put api("/projects/#{project.id}/labels", user), - name: 'label2', - new_name: 'label3' + params: { + name: 'label2', + new_name: 'label3' + } expect(response).to have_gitlab_http_status(404) end it 'returns 400 if no label name given' do - put api("/projects/#{project.id}/labels", user), new_name: 'label2' + put api("/projects/#{project.id}/labels", user), params: { new_name: 'label2' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end it 'returns 400 if no new parameters given' do - put api("/projects/#{project.id}/labels", user), name: 'label1' + put api("/projects/#{project.id}/labels", user), params: { name: 'label1' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\ 'at least one parameter must be provided') @@ -290,33 +324,41 @@ describe API::Labels do it 'returns 400 for invalid name' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: ',', - color: '#FFFFFF' + params: { + name: 'label1', + new_name: ',', + color: '#FFFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end it 'returns 400 when color code is too short' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FF' + params: { + name: 'label1', + color: '#FF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for too long color code' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFAAFFFF' + params: { + name: 'label1', + color: '#FFAAFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for invalid priority' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - priority: 'foo' + params: { + name: 'label1', + priority: 'foo' + } expect(response).to have_gitlab_http_status(400) end |