2019-05-18 00:54:41 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PruneWebHookLogsWorker do
|
|
|
|
describe '#perform' do
|
|
|
|
before do
|
|
|
|
hook = create(:project_hook)
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 5.months.ago)
|
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 4.months.ago)
|
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 91.days.ago)
|
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 89.days.ago)
|
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 2.months.ago)
|
|
|
|
create(:web_hook_log, web_hook: hook, created_at: 1.month.ago)
|
2018-11-08 19:23:39 +05:30
|
|
|
create(:web_hook_log, web_hook: hook, response_status: '404')
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
it 'removes all web hook logs older than 90 days' do
|
2018-11-08 19:23:39 +05:30
|
|
|
described_class.new.perform
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(WebHookLog.count).to eq(4)
|
|
|
|
expect(WebHookLog.last.response_status).to eq('404')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|