A platform for community discussion. Free, open, simple.
FIX: `Topic#invite_group` failed to notify users on newly created topic (#12255)
Gerhard Schlager11ccea5c9a13
diff --git a/app/models/topic.rb b/app/models/topic.rbindex a141b144646..2ad0fccdc37 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -930,6 +930,7 @@ class Topic < ActiveRecord::Basegroup_user = topic_allowed_groups.find_by(group_id: group.id)if group_usergroup_user.destroy+ allowed_groups.reloadadd_small_action(removed_by, "removed_group", group.name)return trueend@@ -968,6 +969,7 @@ class Topic < ActiveRecord::Basedef invite_group(user, group)TopicAllowedGroup.create!(topic_id: id, group_id: group.id)+ allowed_groups.reloadlast_post = posts.order('post_number desc').where('not hidden AND posts.deleted_at IS NULL').firstif last_postdiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex c5d45472406..6f45a32708f 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -909,7 +909,15 @@ describe Topic docontext 'private message' dolet(:coding_horror) { Fabricate(:coding_horror) }fab!(:evil_trout) { Fabricate(:evil_trout) }- let(:topic) { Fabricate(:private_message_topic, recipient: coding_horror) }+ let(:topic) do+ PostCreator.new(+ Fabricate(:user),+ title: "This is a private message",+ raw: "This is my message to you-ou-ou",+ archetype: Archetype.private_message,+ target_usernames: coding_horror.username+ ).create!.topic+ endit "should integrate correctly" doexpect(Guardian.new(topic.user).can_see?(topic)).to eq(true)