DEV: permission type for private category fabricator (#19601)

Allow to specify permission type for category fabricator to test `:readonly`, `:create_post` and `:full` rights.
This commit is contained in:
Krzysztof Kotlarek
2022-12-23 14:18:29 +11:00
committed by GitHub
parent 18467d4067
commit 9f927cf999
4 changed files with 23 additions and 33 deletions

View File

@ -139,30 +139,20 @@ describe Chat::ChatChannelFetcher do
context "when restricted category" do
fab!(:group) { Fabricate(:group) }
fab!(:category_group) do
Fabricate(
:category_group,
category: private_category,
group: group,
permission_type: CategoryGroup.permission_types[:readonly],
)
end
fab!(:group_user) do
Fabricate(:group_user, group: private_category.groups.last, user: user1)
end
before { category_channel.update!(chatable: private_category) }
fab!(:group_user) { Fabricate(:group_user, group: group, user: user1) }
it "does not include the category channel for member of group with readonly access" do
category_channel.update!(chatable: Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:readonly]))
expect(subject.all_secured_channel_ids(guardian)).to be_empty
end
it "includes the category channel for member of group with create_post access" do
category_group.update!(permission_type: CategoryGroup.permission_types[:create_post])
category_channel.update!(chatable: Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:create_post]))
expect(subject.all_secured_channel_ids(guardian)).to match_array([category_channel.id])
end
it "includes the category channel for member of group with full access" do
category_group.update!(permission_type: CategoryGroup.permission_types[:full])
category_channel.update!(chatable: Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:full]))
expect(subject.all_secured_channel_ids(guardian)).to match_array([category_channel.id])
end
end