Use JSON.generate call in push update worker (#38208)

This commit is contained in:
Matt Jankowski
2026-03-16 09:55:53 -04:00
committed by GitHub
parent 21c27eb3af
commit f9b2dffaa8
2 changed files with 14 additions and 5 deletions

View File

@@ -23,10 +23,10 @@ class PushUpdateWorker
end end
def message def message
Oj.dump( JSON.generate({
event: update? ? :'status.update' : :update, event: update? ? :'status.update' : :update,
payload: @payload payload: @payload,
) }.as_json)
end end
def publish! def publish!

View File

@@ -15,7 +15,7 @@ RSpec.describe PushUpdateWorker do
context 'with valid records' do context 'with valid records' do
let(:account) { Fabricate :account } let(:account) { Fabricate :account }
let(:status) { Fabricate :status } let(:status) { Fabricate :status, text: 'Test Post' }
before { allow(redis).to receive(:publish) } before { allow(redis).to receive(:publish) }
@@ -25,7 +25,16 @@ RSpec.describe PushUpdateWorker do
expect(redis) expect(redis)
.to have_received(:publish) .to have_received(:publish)
.with(redis_key, anything) .with(
redis_key,
match_json_values(
event: 'update',
payload: include(
created_at: status.created_at.iso8601(3),
content: eq('<p>Test Post</p>')
)
)
)
end end
def redis_key def redis_key