mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 12:57:17 +08:00
FIX: Topic#invite_group
failed to notify users on newly created topic (#12255)
When `PostCreator` creates a new topic it loads the `allowed_groups` of the topic. `Fabricate` doesn't do that and that's why the existing spec worked even though it should have failed, because `PostAlerter#notify_group_summary` didn't create a notification for a non-fabricated topic. `Topic#invite_group` added a new `TopicAllowedGroup` record without reloading `Topic.allowed_groups`. A subsequent call to `PostAlerter#notify_group_summary` didn't work because it didn't find the invited group in the topic's `allowed_groups` association.
This commit is contained in:
@ -909,7 +909,15 @@ describe Topic do
|
||||
context 'private message' do
|
||||
let(: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
|
||||
end
|
||||
|
||||
it "should integrate correctly" do
|
||||
expect(Guardian.new(topic.user).can_see?(topic)).to eq(true)
|
||||
|
Reference in New Issue
Block a user