From 7e3543d96fccfc9ca4e99b72d3fba825922bce8b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 12 Jan 2018 14:42:05 +1100 Subject: [PATCH] correct plugin specs --- .../integration/discobot_certificate_spec.rb | 4 +-- .../spec/requests/presence_controller_spec.rb | 3 ++- .../spec/integration/poll_endpoints_spec.rb | 26 +++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/plugins/discourse-narrative-bot/spec/integration/discobot_certificate_spec.rb b/plugins/discourse-narrative-bot/spec/integration/discobot_certificate_spec.rb index 5e2f58d84ee..c635a357cac 100644 --- a/plugins/discourse-narrative-bot/spec/integration/discobot_certificate_spec.rb +++ b/plugins/discourse-narrative-bot/spec/integration/discobot_certificate_spec.rb @@ -28,8 +28,8 @@ describe "Discobot Certificate" do } params.each do |key, _| - expect { get '/discobot/certificate.svg', params: params.except(key) } - .to raise_error(Discourse::InvalidParameters) + get '/discobot/certificate.svg', params: params.except(key) + expect(response.status).to eq(400) end end end diff --git a/plugins/discourse-presence/spec/requests/presence_controller_spec.rb b/plugins/discourse-presence/spec/requests/presence_controller_spec.rb index 0184718bc6b..8a003a9e4e1 100644 --- a/plugins/discourse-presence/spec/requests/presence_controller_spec.rb +++ b/plugins/discourse-presence/spec/requests/presence_controller_spec.rb @@ -23,7 +23,8 @@ describe ::Presence::PresencesController do context 'when not logged in' 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 diff --git a/plugins/poll/spec/integration/poll_endpoints_spec.rb b/plugins/poll/spec/integration/poll_endpoints_spec.rb index e4c8005a442..8e5e136534d 100644 --- a/plugins/poll/spec/integration/poll_endpoints_spec.rb +++ b/plugins/poll/spec/integration/poll_endpoints_spec.rb @@ -57,34 +57,34 @@ describe "DiscoursePoll endpoints" do describe 'when post_id is blank' do it 'should raise the right error' do - expect { get "/polls/voters.json", params: { poll_name: DiscoursePoll::DEFAULT_POLL_NAME } } - .to raise_error(ActionController::ParameterMissing) + get "/polls/voters.json", params: { poll_name: DiscoursePoll::DEFAULT_POLL_NAME } + expect(response.status).to eq(400) end end describe 'when post_id is not valid' do it 'should raise the right error' do - expect do - get "/polls/voters.json", params: { - post_id: -1, - poll_name: DiscoursePoll::DEFAULT_POLL_NAME - } - end.to raise_error(Discourse::InvalidParameters, 'post_id is invalid') + get "/polls/voters.json", params: { + post_id: -1, + poll_name: DiscoursePoll::DEFAULT_POLL_NAME + } + expect(response.status).to eq(400) + expect(response.body).to include('post_id is invalid') end end describe 'when poll_name is blank' do it 'should raise the right error' do - expect { get "/polls/voters.json", params: { post_id: post.id } } - .to raise_error(ActionController::ParameterMissing) + get "/polls/voters.json", params: { post_id: post.id } + expect(response.status).to eq(400) end end describe 'when poll_name is not valid' do it 'should raise the right error' do - expect do - get "/polls/voters.json", params: { post_id: post.id, poll_name: 'wrongpoll' } - end.to raise_error(Discourse::InvalidParameters, 'poll_name is invalid') + get "/polls/voters.json", params: { post_id: post.id, poll_name: 'wrongpoll' } + expect(response.status).to eq(400) + expect(response.body).to include('poll_name is invalid') end end