correct specs

This commit is contained in:
Sam 2018-01-12 14:48:00 +11:00
parent 805cd762df
commit 3069124273
2 changed files with 9 additions and 8 deletions

View File

@ -48,8 +48,8 @@ describe 'Mattermost Command Controller', type: :request do
describe 'when the token is invalid' do
it 'should raise the right error' do
expect { post '/chat-integration/mattermost/command.json', params: { text: 'help' } }
.to raise_error(ActionController::ParameterMissing)
post '/chat-integration/mattermost/command.json', params: { text: 'help' }
expect(response.status).to eq(400)
end
end

View File

@ -20,14 +20,16 @@ describe 'Chat Controller', type: :request do
shared_examples 'admin constraints' do |action, route|
context 'when user is not signed in' do
it 'should raise the right error' do
expect { public_send(action, route) }.to raise_error(ActionController::RoutingError)
public_send(action, route)
expect(response.status).to eq(404)
end
end
context 'when user is not an admin' do
it 'should raise the right error' do
sign_in(Fabricate(:user))
expect { public_send(action, route) }.to raise_error(ActionController::RoutingError)
public_send(action, route)
expect(response.status).to eq(404)
end
end
end
@ -73,7 +75,7 @@ describe 'Chat Controller', type: :request do
expect(response).to be_success
json = JSON.parse(response.body)
JSON.parse(response.body)
end
it 'should fail for invalid channel' do
@ -120,9 +122,8 @@ describe 'Chat Controller', type: :request do
end
it 'should fail for invalid provider' do
expect do
get '/admin/plugins/chat/channels.json', params: { provider: 'someprovider' }
end.to raise_error(Discourse::InvalidParameters)
get '/admin/plugins/chat/channels.json', params: { provider: 'someprovider' }
expect(response.status).to eq(400)
end
end