about summary refs log tree commit diff
path: root/spec/workers/scheduler/media_cleanup_scheduler_spec.rb
blob: 8a0da67e1b6f19576c1ad8041ebda580d203f467 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'rails_helper'

describe Scheduler::MediaCleanupScheduler do
  subject { described_class.new }

  let!(:old_media) { Fabricate(:media_attachment, account_id: nil, created_at: 10.days.ago) }
  let!(:new_media) { Fabricate(:media_attachment, account_id: nil, created_at: 1.hour.ago) }

  it 'removes old media records' do
    subject.perform

    expect { old_media.reload }.to raise_error(ActiveRecord::RecordNotFound)
    expect(new_media.reload).to be_persisted
  end
end