FIX: Incorrect notification state being published.
This commit is contained in:
parent
23b787e0a6
commit
e542884b00
|
@ -405,9 +405,11 @@ class User < ActiveRecord::Base
|
|||
) AS y
|
||||
"
|
||||
|
||||
recent = User.exec_sql(sql, user_id: id,
|
||||
type: Notification.types[:private_message]).values.map do |id, read|
|
||||
[id.to_i, read == 't'.freeze]
|
||||
recent = User.exec_sql(sql,
|
||||
user_id: id,
|
||||
type: Notification.types[:private_message]
|
||||
).values.map! do |id, read|
|
||||
[id.to_i, read]
|
||||
end
|
||||
|
||||
MessageBus.publish("/notification/#{id}",
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'rails_helper'
|
|||
require_dependency 'user'
|
||||
|
||||
describe User do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
context 'validations' do
|
||||
it { is_expected.to validate_presence_of :username }
|
||||
|
@ -1520,4 +1521,19 @@ describe User do
|
|||
expect(User.human_users).to eq([user])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#publish_notifications_state' do
|
||||
it 'should publish the right message' do
|
||||
notification = Fabricate(:notification, user: user)
|
||||
notification2 = Fabricate(:notification, user: user, read: true)
|
||||
|
||||
message = MessageBus.track_publish do
|
||||
user.publish_notifications_state
|
||||
end.find { |m| m.channel = "/notification/#{user.id}" }
|
||||
|
||||
expect(message.data[:recent]).to eq([
|
||||
[notification2.id, true], [notification.id, false]
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue