mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:07:17 +08:00
FIX: prevents duplicate reactions (#20527)
This was possible due to specific events which are hard to represent in a test. The provided test is as close as possible to what was happening in production: a message bus event was played on a channel which has just loaded its state with the existing reaction.
This commit is contained in:
@ -140,5 +140,26 @@ RSpec.describe "React to message", type: :system, js: true do
|
||||
context "when mobile", mobile: true do
|
||||
include_examples "inline reactions"
|
||||
end
|
||||
|
||||
context "when receiving a duplicate reaction event" do
|
||||
fab!(:user_1) { Fabricate(:user) }
|
||||
|
||||
fab!(:reaction_2) do
|
||||
Chat::ChatMessageReactor.new(user_1, category_channel_1).react!(
|
||||
message_id: message_1.id,
|
||||
react_action: :add,
|
||||
emoji: "heart",
|
||||
)
|
||||
end
|
||||
|
||||
it "doesn’t create duplicate reactions" do
|
||||
chat.visit_channel(category_channel_1)
|
||||
|
||||
ChatPublisher.publish_reaction!(category_channel_1, message_1, "add", user_1, "heart")
|
||||
channel.send_message("test") # cheap trick to ensure reaction has been processed
|
||||
|
||||
expect(channel).to have_reaction(message_1, reaction_2, "1")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user