diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-01 16:23:16 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 12:58:58 -0300 |
commit | ed9943d0130f4a581156afcf038f2b51fd9cea9f (patch) | |
tree | 752a531108dcc88595a0870382772d5f972348a7 /spec/controllers | |
parent | e1998844781b92d118f25cb8f8c0cbd293a25708 (diff) | |
download | gitlab-ce-ed9943d0130f4a581156afcf038f2b51fd9cea9f.tar.gz |
Add endpoint to allow users to create a new board list
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/board_lists_controller_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/controllers/projects/board_lists_controller_spec.rb b/spec/controllers/projects/board_lists_controller_spec.rb new file mode 100644 index 00000000000..906edeb1c17 --- /dev/null +++ b/spec/controllers/projects/board_lists_controller_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe Projects::BoardListsController do + let(:project) { create(:project_with_board) } + let(:user) { create(:user) } + + before do + project.team << [user, :master] + sign_in(user) + end + + describe 'POST #create' do + context 'with valid params' do + let(:label) { create(:label, project: project, name: 'Development') } + + it 'returns a successful 200 response' do + post :create, namespace_id: project.namespace.to_param, + project_id: project.to_param, + list: { label_id: label.id }, + format: :json + + expect(response).to have_http_status(200) + end + + it 'returns the created list' do + post :create, namespace_id: project.namespace.to_param, + project_id: project.to_param, + list: { label_id: label.id }, + format: :json + + expect(response).to match_response_schema('list') + end + end + + context 'with invalid params' do + it 'returns an error' do + post :create, namespace_id: project.namespace.to_param, + project_id: project.to_param, + list: { label_id: nil }, + format: :json + + parsed_response = JSON.parse(response.body) + + expect(parsed_response['label']).to contain_exactly "can't be blank" + expect(response).to have_http_status(422) + end + end + end +end |