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

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

  let!(:active_user) { Fabricate(:user, current_sign_in_at: 2.days.ago) }
  let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }

  it 'clears feeds of inactives' do
    expect_any_instance_of(Redis).to receive(:del).with(feed_key_for(inactive_user))
    expect_any_instance_of(Redis).not_to receive(:del).with(feed_key_for(active_user))

    subject.perform
  end

  def feed_key_for(user)
    FeedManager.instance.key(:home, user.account_id)
  end
end