blob: 16f7d73e02548d4fd795f0363234730f811a1272 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# frozen_string_literal: true
require 'rails_helper'
describe FeedInsertWorker do
subject { described_class.new }
describe 'perform' do
let(:follower) { Fabricate(:account) }
let(:status) { Fabricate(:status) }
context 'when there are no records' do
it 'skips push with missing status' do
instance = double(push_to_home: nil)
allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(nil, follower.id)
expect(result).to be true
expect(instance).to_not have_received(:push_to_home)
end
it 'skips push with missing account' do
instance = double(push_to_home: nil)
allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(status.id, nil)
expect(result).to be true
expect(instance).to_not have_received(:push_to_home)
end
end
context 'when there are real records' do
it 'skips the push when there is a filter' do
instance = double(push_to_home: nil, filter?: true)
allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(status.id, follower.id)
expect(result).to be_nil
expect(instance).to_not have_received(:push_to_home)
end
it 'pushes the status onto the home timeline without filter' do
instance = double(push_to_home: nil, filter?: false)
allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(status.id, follower.id)
expect(result).to be_nil
expect(instance).to have_received(:push_to_home).with(follower, status, update: nil)
end
end
end
end
|