FIX: don't allow inviting more than max_allowed_message_recipients

* FIX: don't allow inviting more than `max_allowed_message_recipients` setting allows

* add specs for guardian

* user preferences for auto track shouldn't be applicable to PMs (it auto watches on visit)

Execlude PMs from "Automatically track topics I enter..." and "When I post in a topic, set that topic to..." user preferences

* groups take only 1 slot in PM

* just return if topic is a PM
This commit is contained in:
Osama Sayegh
2018-08-23 07:36:49 +03:00
committed by Sam
parent b2ce33be26
commit 2711f173dc
10 changed files with 133 additions and 2 deletions

View File

@ -568,6 +568,7 @@ describe Guardian do
let(:user) { Fabricate(:user, trust_level: TrustLevel[2]) }
let!(:pm) { Fabricate(:private_message_topic, user: user) }
let(:admin) { Fabricate(:admin) }
let(:moderator) { Fabricate(:moderator) }
context "when private messages are disabled" do
it "allows an admin to invite to the pm" do
@ -586,6 +587,22 @@ describe Guardian do
expect(Guardian.new(user).can_invite_to?(pm)).to be_falsey
end
end
context "when PM has receached the maximum number of recipients" do
before do
SiteSetting.max_allowed_message_recipients = 2
end
it "doesn't allow a regular user to invite" do
expect(Guardian.new(user).can_invite_to?(pm)).to be_falsey
end
it "allows staff to invite" do
expect(Guardian.new(admin).can_invite_to?(pm)).to be_truthy
pm.grant_permission_to_user(moderator.email)
expect(Guardian.new(moderator).can_invite_to?(pm)).to be_truthy
end
end
end
end