FIX: Limit new and existent staged users for email topics (#17970)

The maximum_staged_users_per_email site setting controls how many
staged users will be invited to the topic created from an incoming
email. Previously, it counted only the new staged users.
This commit is contained in:
Bianca Nenciu
2022-08-18 18:19:20 +03:00
committed by GitHub
parent b082f459c9
commit 707034bc75
2 changed files with 32 additions and 15 deletions

View File

@ -879,7 +879,17 @@ RSpec.describe Email::Receiver do
it "cap the number of staged users created per email" do
SiteSetting.maximum_staged_users_per_email = 1
expect { process(:cc) }.to change(Topic, :count)
expect { process(:cc) }.to change(Topic, :count).by(1)
.and change(User, :count).by(1)
expect(Topic.last.ordered_posts[-1].post_type).to eq(Post.types[:moderator_action])
end
it "cap the number of staged users existing per email" do
Fabricate(:user, email: "discourse@bar.com", staged: true) # from
Fabricate(:user, email: "someone@else.com", staged: true) # to
SiteSetting.maximum_staged_users_per_email = 1
expect { process(:cc) }.to change(Topic, :count).and not_change(User, :count)
expect(Topic.last.ordered_posts[-1].post_type).to eq(Post.types[:moderator_action])
end