Commit ef3eb79a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Reject creating boards when the feature is not available

parent e5da0e50
......@@ -3,6 +3,7 @@ module EE
module BoardsController
extend ActiveSupport::Concern
prepended do
before_action :check_multiple_issue_boards_available!, only: [:create]
before_action :authorize_admin_board!, only: [:create, :update, :destroy]
before_action :find_board, only: [:update, :destroy]
end
......
......@@ -30,40 +30,54 @@ describe Projects::BoardsController do # rubocop:disable RSpec/FilePath
end
describe 'POST create' do
context 'with valid params' do
it 'returns a successful 200 response' do
create_board name: 'Backend'
context 'with the multiple issue boards available' do
before do
stub_licensed_features(multiple_issue_boards: true)
end
expect(response).to have_http_status(200)
context 'with valid params' do
it 'returns a successful 200 response' do
create_board name: 'Backend'
expect(response).to have_http_status(200)
end
it 'returns the created board' do
create_board name: 'Backend'
expect(response).to match_response_schema('board')
end
end
it 'returns the created board' do
create_board name: 'Backend'
context 'with invalid params' do
it 'returns an unprocessable entity 422 response' do
create_board name: nil
expect(response).to match_response_schema('board')
expect(response).to have_http_status(422)
end
end
end
context 'with invalid params' do
it 'returns an unprocessable entity 422 response' do
create_board name: nil
context 'with unauthorized user' do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :admin_board, project).and_return(false)
end
expect(response).to have_http_status(422)
it 'returns a not found 404 response' do
create_board name: 'Backend'
expect(response.content_type).to eq 'application/json'
expect(response).to have_http_status(404)
end
end
end
context 'with unauthorized user' do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :admin_board, project).and_return(false)
end
it 'renders a 404 when multiple issue boards are not available' do
stub_licensed_features(multiple_issue_boards: false)
it 'returns a not found 404 response' do
create_board name: 'Backend'
create_board name: 'Backend'
expect(response.content_type).to eq 'application/json'
expect(response).to have_http_status(404)
end
expect(response).to have_http_status(404)
end
def create_board(name:)
......
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