FEATURE: Warn if invited user cannot see topic (#13548)

Users can invite people to topics from secured category, but they will
not be redirected to the topic after signing up unless they have the
permissions to view the topic. This commit shows a warning when invite
is saved if the topic is in a secured category and none of the invite
groups are allowed to see it.
This commit is contained in:
Dan Ungureanu
2021-07-06 12:49:26 +03:00
committed by GitHub
parent f999ef2d52
commit 34387c5a38
7 changed files with 67 additions and 7 deletions

View File

@ -404,4 +404,27 @@ describe Invite do
expect(invite.invalidated_at).to be_nil
end
end
describe '#warnings' do
fab!(:admin) { Fabricate(:admin) }
fab!(:invite) { Fabricate(:invite) }
fab!(:group) { Fabricate(:group) }
fab!(:secured_category) do
secured_category = Fabricate(:category)
secured_category.permissions = { group.name => :full }
secured_category.save!
secured_category
end
it 'does not return any warnings for simple invites' do
expect(invite.warnings(admin.guardian)).to be_blank
end
it 'returns a warning if topic is private' do
topic = Fabricate(:topic, category: secured_category)
TopicInvite.create!(topic: topic, invite: invite)
expect(invite.warnings(admin.guardian)).to contain_exactly(I18n.t("invite.requires_groups", groups: group.name))
end
end
end