2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-08 12:06:51 +08:00

correct plugin specs

This commit is contained in:
Sam 2018-01-12 14:42:05 +11:00
parent 49ed382c2a
commit 7e3543d96f
3 changed files with 17 additions and 16 deletions

View file

@ -28,8 +28,8 @@ describe "Discobot Certificate" do
} }
params.each do |key, _| params.each do |key, _|
expect { get '/discobot/certificate.svg', params: params.except(key) } get '/discobot/certificate.svg', params: params.except(key)
.to raise_error(Discourse::InvalidParameters) expect(response.status).to eq(400)
end end
end end
end end

View file

@ -23,7 +23,8 @@ describe ::Presence::PresencesController do
context 'when not logged in' do context 'when not logged in' do
it 'should raise the right error' do it 'should raise the right error' do
expect { post '/presence/publish.json' }.to raise_error(Discourse::NotLoggedIn) post '/presence/publish.json'
expect(response.status).to eq(403)
end end
end end

View file

@ -57,34 +57,34 @@ describe "DiscoursePoll endpoints" do
describe 'when post_id is blank' do describe 'when post_id is blank' do
it 'should raise the right error' do it 'should raise the right error' do
expect { get "/polls/voters.json", params: { poll_name: DiscoursePoll::DEFAULT_POLL_NAME } } get "/polls/voters.json", params: { poll_name: DiscoursePoll::DEFAULT_POLL_NAME }
.to raise_error(ActionController::ParameterMissing) expect(response.status).to eq(400)
end end
end end
describe 'when post_id is not valid' do describe 'when post_id is not valid' do
it 'should raise the right error' do it 'should raise the right error' do
expect do
get "/polls/voters.json", params: { get "/polls/voters.json", params: {
post_id: -1, post_id: -1,
poll_name: DiscoursePoll::DEFAULT_POLL_NAME poll_name: DiscoursePoll::DEFAULT_POLL_NAME
} }
end.to raise_error(Discourse::InvalidParameters, 'post_id is invalid') expect(response.status).to eq(400)
expect(response.body).to include('post_id is invalid')
end end
end end
describe 'when poll_name is blank' do describe 'when poll_name is blank' do
it 'should raise the right error' do it 'should raise the right error' do
expect { get "/polls/voters.json", params: { post_id: post.id } } get "/polls/voters.json", params: { post_id: post.id }
.to raise_error(ActionController::ParameterMissing) expect(response.status).to eq(400)
end end
end end
describe 'when poll_name is not valid' do describe 'when poll_name is not valid' do
it 'should raise the right error' do it 'should raise the right error' do
expect do
get "/polls/voters.json", params: { post_id: post.id, poll_name: 'wrongpoll' } get "/polls/voters.json", params: { post_id: post.id, poll_name: 'wrongpoll' }
end.to raise_error(Discourse::InvalidParameters, 'poll_name is invalid') expect(response.status).to eq(400)
expect(response.body).to include('poll_name is invalid')
end end
end end