2017-05-10 14:32:05 -04:00
|
|
|
# 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
|
2017-11-17 18:16:48 -05:00
|
|
|
instance = double(push_to_home: nil)
|
2017-05-10 14:32:05 -04:00
|
|
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
|
|
|
result = subject.perform(nil, follower.id)
|
|
|
|
|
|
|
|
expect(result).to eq true
|
2017-11-17 18:16:48 -05:00
|
|
|
expect(instance).not_to have_received(:push_to_home)
|
2017-05-10 14:32:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'skips push with missing account' do
|
2017-11-17 18:16:48 -05:00
|
|
|
instance = double(push_to_home: nil)
|
2017-05-10 14:32:05 -04:00
|
|
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
|
|
|
result = subject.perform(status.id, nil)
|
|
|
|
|
|
|
|
expect(result).to eq true
|
2017-11-17 18:16:48 -05:00
|
|
|
expect(instance).not_to have_received(:push_to_home)
|
2017-05-10 14:32:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are real records' do
|
|
|
|
it 'skips the push when there is a filter' do
|
2017-11-17 18:16:48 -05:00
|
|
|
instance = double(push_to_home: nil, filter?: true)
|
2017-05-10 14:32:05 -04:00
|
|
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
|
|
|
result = subject.perform(status.id, follower.id)
|
|
|
|
|
|
|
|
expect(result).to be_nil
|
2017-11-17 18:16:48 -05:00
|
|
|
expect(instance).not_to have_received(:push_to_home)
|
2017-05-10 14:32:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'pushes the status onto the home timeline without filter' do
|
2017-11-17 18:16:48 -05:00
|
|
|
instance = double(push_to_home: nil, filter?: false)
|
2017-05-10 14:32:05 -04:00
|
|
|
allow(FeedManager).to receive(:instance).and_return(instance)
|
|
|
|
result = subject.perform(status.id, follower.id)
|
|
|
|
|
|
|
|
expect(result).to be_nil
|
2022-01-19 16:37:27 -05:00
|
|
|
expect(instance).to have_received(:push_to_home).with(follower, status, update: nil)
|
2017-05-10 14:32:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|