SPEC: Update webhook event attributes even when an error raised
1e3cb7575d
This commit is contained in:
parent
fc026e12a5
commit
9f0574dcfd
|
@ -263,5 +263,26 @@ describe Jobs::EmitWebHookEvent do
|
||||||
expect(MultiJson.load(event.response_headers)['Test']).to eq('string')
|
expect(MultiJson.load(event.response_headers)['Test']).to eq('string')
|
||||||
expect(event.response_body).to eq('OK')
|
expect(event.response_body).to eq('OK')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'sets up proper request headers when an error raised' do
|
||||||
|
Excon::Connection.any_instance.expects(:post).raises("error")
|
||||||
|
|
||||||
|
subject.execute(
|
||||||
|
web_hook_id: post_hook.id,
|
||||||
|
event_type: described_class::PING_EVENT,
|
||||||
|
event_name: described_class::PING_EVENT,
|
||||||
|
payload: { test: "this payload shouldn't appear" }.to_json
|
||||||
|
)
|
||||||
|
|
||||||
|
event = WebHookEvent.last
|
||||||
|
headers = MultiJson.load(event.headers)
|
||||||
|
expect(headers['Content-Length']).to eq(13)
|
||||||
|
expect(headers['Host']).to eq("meta.discourse.org")
|
||||||
|
expect(headers['X-Discourse-Event-Id']).to eq(event.id)
|
||||||
|
expect(headers['X-Discourse-Event-Type']).to eq(described_class::PING_EVENT)
|
||||||
|
expect(headers['X-Discourse-Event']).to eq(described_class::PING_EVENT)
|
||||||
|
expect(headers['X-Discourse-Event-Signature']).to eq('sha256=162f107f6b5022353274eb1a7197885cfd35744d8d08e5bcea025d309386b7d6')
|
||||||
|
expect(event.payload).to eq(MultiJson.dump(ping: 'OK'))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue