mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:50:23 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe WebHookEvent do
|
|
let(:event) { WebHookEvent.new(status: 200, web_hook: Fabricate(:web_hook)) }
|
|
let(:failed_event) { WebHookEvent.new(status: 400, web_hook: Fabricate(:web_hook)) }
|
|
|
|
describe '.purge_old' do
|
|
before do
|
|
SiteSetting.retain_web_hook_events_period_days = 1
|
|
end
|
|
|
|
it "should be able to purge old web hook events" do
|
|
web_hook = Fabricate(:web_hook)
|
|
web_hook_event = WebHookEvent.create!(status: 200, web_hook: web_hook)
|
|
WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 2.days.ago)
|
|
|
|
expect { described_class.purge_old }
|
|
.to change { WebHookEvent.count }.by(-1)
|
|
|
|
expect(WebHookEvent.find(web_hook_event.id)).to eq(web_hook_event)
|
|
end
|
|
end
|
|
|
|
describe '#update_web_hook_delivery_status' do
|
|
it 'update last delivery status for associated WebHook record' do
|
|
event.update_web_hook_delivery_status
|
|
|
|
expect(event.web_hook.last_delivery_status)
|
|
.to eq(WebHook.last_delivery_statuses[:successful])
|
|
end
|
|
|
|
it 'sets last delivery status to failed' do
|
|
failed_event.update_web_hook_delivery_status
|
|
|
|
expect(failed_event.web_hook.last_delivery_status)
|
|
.to eq(WebHook.last_delivery_statuses[:failed])
|
|
end
|
|
end
|
|
end
|