You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

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