push_update_worker_spec.rb 808 B

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PushUpdateWorker 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, nil) }
  9. .to_not raise_error
  10. end
  11. end
  12. context 'with valid records' do
  13. let(:account) { Fabricate :account }
  14. let(:status) { Fabricate :status }
  15. before { allow(redis).to receive(:publish) }
  16. it 'pushes message to timeline' do
  17. expect { worker.perform(account.id, status.id) }
  18. .to_not raise_error
  19. expect(redis)
  20. .to have_received(:publish)
  21. .with(redis_key, anything)
  22. end
  23. def redis_key
  24. "timeline:#{account.id}"
  25. end
  26. end
  27. end
  28. end