prune_web_hook_logs_worker_spec.rb 867 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4 5 6 7 8 9
require 'spec_helper'

describe PruneWebHookLogsWorker do
  describe '#perform' do
    before do
      hook = create(:project_hook)

10 11 12 13 14 15
      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)
16 17 18
      create(:web_hook_log, web_hook: hook, response_status: '404')
    end

19
    it 'removes all web hook logs older than 90 days' do
20 21
      described_class.new.perform

22 23
      expect(WebHookLog.count).to eq(4)
      expect(WebHookLog.last.response_status).to eq('404')
24 25 26
    end
  end
end