From 1d85574d528c738a66aaddaee5b9006235136168 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 14 Apr 2021 12:34:13 -0500 Subject: [PATCH] FIX: Don't show the get a room composer message in private categories (#12702) --- lib/composer_messages_finder.rb | 1 + spec/components/composer_messages_finder_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb index 251091d0e04..27bddef4e13 100644 --- a/lib/composer_messages_finder.rb +++ b/lib/composer_messages_finder.rb @@ -151,6 +151,7 @@ class ComposerMessagesFinder def check_get_a_room(min_users_posted: 5) return unless educate_reply?(:notified_about_get_a_room) return unless @details[:post_id].present? + return if @topic.category&.read_restricted reply_to_user_id = Post.where(id: @details[:post_id]).pluck(:user_id)[0] diff --git a/spec/components/composer_messages_finder_spec.rb b/spec/components/composer_messages_finder_spec.rb index 50a8325576b..b114560ed8b 100644 --- a/spec/components/composer_messages_finder_spec.rb +++ b/spec/components/composer_messages_finder_spec.rb @@ -343,6 +343,13 @@ describe ComposerMessagesFinder do expect(ComposerMessagesFinder.new(user, composer_action: 'reply').check_get_a_room(min_users_posted: 2)).to be_blank end + it "does not give a message if the topic's category is read_restricted" do + topic.category.update(read_restricted: true) + finder = ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id, post_id: op.id) + finder.check_get_a_room(min_users_posted: 2) + expect(UserHistory.exists_for_user?(user, :notified_about_get_a_room)).to eq(false) + end + context "reply" do let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id, post_id: op.id) }