Move the set up of the state described in context to a before block

This commit is contained in:
Douglas Barbosa Alexandre 2016-08-17 12:15:51 -03:00
parent 84afd6254a
commit 536bdf643e
3 changed files with 21 additions and 11 deletions

View file

@ -40,10 +40,12 @@ describe Projects::Boards::IssuesController do
end
context 'with unauthorized user' do
it 'returns a successful 403 response' do
before do
allow(Ability.abilities).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability.abilities).to receive(:allowed?).with(user, :read_issue, project).and_return(false)
end
it 'returns a successful 403 response' do
list_issues user: user, list_id: list2
expect(response).to have_http_status(403)

View file

@ -33,13 +33,17 @@ describe Projects::Boards::ListsController do
expect(parsed_response.length).to eq 3
end
it 'returns a successful 403 response with unauthorized user' do
allow(Ability.abilities).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability.abilities).to receive(:allowed?).with(user, :read_list, project).and_return(false)
context 'with unauthorized user' do
before do
allow(Ability.abilities).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability.abilities).to receive(:allowed?).with(user, :read_list, project).and_return(false)
end
read_board_list user: user
it 'returns a successful 403 response' do
read_board_list user: user
expect(response).to have_http_status(403)
expect(response).to have_http_status(403)
end
end
def read_board_list(user:)

View file

@ -21,13 +21,17 @@ describe Projects::BoardsController do
expect(response.content_type).to eq 'text/html'
end
it 'returns a successful 404 response with unauthorized user' do
allow(Ability.abilities).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability.abilities).to receive(:allowed?).with(user, :read_board, project).and_return(false)
context 'with unauthorized user' do
before do
allow(Ability.abilities).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability.abilities).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end
read_board
it 'returns a successful 404 response' do
read_board
expect(response).to have_http_status(404)
expect(response).to have_http_status(404)
end
end
def read_board(format: :html)