From 0cb5b9ecd6e07dc8334c51acfd02c59e180e654a Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 5 Jun 2025 16:07:19 +0200 Subject: [PATCH] Reactions reset entropy --- app/models/concerns/mentions.rb | 2 +- app/models/reaction.rb | 7 +++++++ test/models/reaction_test.rb | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/models/reaction_test.rb diff --git a/app/models/concerns/mentions.rb b/app/models/concerns/mentions.rb index e8efb550c..79ca110bd 100644 --- a/app/models/concerns/mentions.rb +++ b/app/models/concerns/mentions.rb @@ -37,7 +37,7 @@ module Mentions end def mentionable_content_changed? - rich_text_associations.any? { send(it.name).body_previously_changed? } + rich_text_associations.any? { send(it.name)&.body_previously_changed? } end def create_mentions_later diff --git a/app/models/reaction.rb b/app/models/reaction.rb index 45d9c1796..6ee88ca9a 100644 --- a/app/models/reaction.rb +++ b/app/models/reaction.rb @@ -4,7 +4,14 @@ class Reaction < ApplicationRecord scope :ordered, -> { order(:created_at) } + after_create :register_card_activity + def all_emoji? content.match? /\A(\p{Emoji_Presentation}|\p{Extended_Pictographic}|\uFE0F)+\z/u end + + private + def register_card_activity + comment.card.touch_last_active_at + end end diff --git a/test/models/reaction_test.rb b/test/models/reaction_test.rb new file mode 100644 index 000000000..7f1dd3985 --- /dev/null +++ b/test/models/reaction_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +class ReactionTest < ActiveSupport::TestCase + setup do + Current.session = sessions(:david) + end + + test "creating a reaction touches the card activity" do + assert_changes -> { cards(:logo).reload.last_active_at } do + comments(:logo_1).reactions.create!(content: "Nice!") + end + end +end