Commit 2023ac4c authored by Rémy Coutable's avatar Rémy Coutable

Reduce CE/EE diff in spec/controllers/projects/boards_controller_spec.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 34862867
...@@ -27,6 +27,20 @@ describe Projects::BoardsController do ...@@ -27,6 +27,20 @@ describe Projects::BoardsController do
expect(response).to render_template :index expect(response).to render_template :index
expect(response.content_type).to eq 'text/html' expect(response.content_type).to eq 'text/html'
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, :read_board, project).and_return(false)
end
it 'returns a not found 404 response' do
list_boards
expect(response).to have_gitlab_http_status(404)
expect(response.content_type).to eq 'text/html'
end
end
end end
context 'when format is JSON' do context 'when format is JSON' do
...@@ -40,18 +54,19 @@ describe Projects::BoardsController do ...@@ -40,18 +54,19 @@ describe Projects::BoardsController do
expect(response).to match_response_schema('boards') expect(response).to match_response_schema('boards')
expect(parsed_response.length).to eq 2 expect(parsed_response.length).to eq 2
end end
end
context 'with unauthorized user' do context 'with unauthorized user' do
before do before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true) allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false) allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end end
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_boards list_boards format: :json
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
expect(response.content_type).to eq 'application/json'
end
end end
end end
...@@ -88,6 +103,20 @@ describe Projects::BoardsController do ...@@ -88,6 +103,20 @@ describe Projects::BoardsController do
expect(response).to render_template :show expect(response).to render_template :show
expect(response.content_type).to eq 'text/html' expect(response.content_type).to eq 'text/html'
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, :read_board, project).and_return(false)
end
it 'returns a not found 404 response' do
read_board board: board
expect(response).to have_gitlab_http_status(404)
expect(response.content_type).to eq 'text/html'
end
end
end end
context 'when format is JSON' do context 'when format is JSON' do
...@@ -96,18 +125,19 @@ describe Projects::BoardsController do ...@@ -96,18 +125,19 @@ describe Projects::BoardsController do
expect(response).to match_response_schema('board') expect(response).to match_response_schema('board')
end end
end
context 'with unauthorized user' do context 'with unauthorized user' do
before do before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true) allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false) allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end end
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
read_board board: board read_board board: board, format: :json
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
expect(response.content_type).to eq 'application/json'
end
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