2023-03-04 15:56:09 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 05:12:25 +00:00
|
|
|
RSpec.describe PushUpdateWorker do
|
2023-03-04 15:56:09 +00:00
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
|
|
|
describe 'perform' do
|
2024-10-23 07:50:20 +00:00
|
|
|
context 'with missing values' do
|
|
|
|
it 'runs without error' do
|
|
|
|
expect { worker.perform(nil, nil) }
|
|
|
|
.to_not raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with valid records' do
|
|
|
|
let(:account) { Fabricate :account }
|
|
|
|
let(:status) { Fabricate :status }
|
|
|
|
|
|
|
|
before { allow(redis).to receive(:publish) }
|
|
|
|
|
|
|
|
it 'pushes message to timeline' do
|
|
|
|
expect { worker.perform(account.id, status.id) }
|
|
|
|
.to_not raise_error
|
|
|
|
|
|
|
|
expect(redis)
|
|
|
|
.to have_received(:publish)
|
|
|
|
.with(redis_key, anything)
|
|
|
|
end
|
2023-03-04 15:56:09 +00:00
|
|
|
|
2024-10-23 07:50:20 +00:00
|
|
|
def redis_key
|
|
|
|
"timeline:#{account.id}"
|
|
|
|
end
|
2023-03-04 15:56:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|