FIX: Defer topic/post created events until emails have been added (#15252)

This commit is contained in:
Daniel Waterworth
2021-12-09 14:45:07 -06:00
committed by GitHub
parent f24027b453
commit ec36cddd2f
2 changed files with 14 additions and 0 deletions

View File

@ -1364,6 +1364,14 @@ describe Email::Receiver do
end
it "works" do
handler_calls = 0
handler = proc { |topic|
expect(topic.incoming_email_addresses).to contain_exactly("discourse@bar.com", "category@foo.com")
handler_calls += 1
}
DiscourseEvent.on(:topic_created, &handler)
user = Fabricate(:user, email: "existing@bar.com", trust_level: SiteSetting.email_in_min_trust)
group = Fabricate(:group)
@ -1380,6 +1388,9 @@ describe Email::Receiver do
# allows new user to create a topic
expect { process(:new_user) }.to change(Topic, :count)
DiscourseEvent.off(:topic_created, &handler)
expect(handler_calls).to eq(1)
end
it "creates visible topic for ham" do