push_conversation_worker_spec.rb 824 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PushConversationWorker do
  4. let(:worker) { described_class.new }
  5. describe 'perform' do
  6. context 'with missing values' do
  7. it 'runs without error' do
  8. expect { worker.perform(nil) }
  9. .to_not raise_error
  10. end
  11. end
  12. context 'with valid records' do
  13. let(:account_conversation) { Fabricate :account_conversation }
  14. before { allow(redis).to receive(:publish) }
  15. it 'pushes message to timeline' do
  16. expect { worker.perform(account_conversation.id) }
  17. .to_not raise_error
  18. expect(redis)
  19. .to have_received(:publish)
  20. .with(redis_key, anything)
  21. end
  22. def redis_key
  23. "timeline:direct:#{account_conversation.account_id}"
  24. end
  25. end
  26. end
  27. end