mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 16:41:08 +08:00
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:

committed by
GitHub

parent
18467d4067
commit
9f927cf999
@ -88,23 +88,23 @@ RSpec.describe Chat::GuardianExtensions do
|
||||
end
|
||||
|
||||
context "for category channel" do
|
||||
fab!(:category) { Fabricate(:category, read_restricted: true) }
|
||||
|
||||
before { channel.update(chatable: category) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group_user) { Fabricate(:group_user, group: group, user: user) }
|
||||
|
||||
it "returns true if the user can join the category" do
|
||||
category = Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:readonly])
|
||||
channel.update(chatable: category)
|
||||
guardian = Guardian.new(user)
|
||||
|
||||
readonly_group = Fabricate(:group)
|
||||
CategoryGroup.create(group: readonly_group, category: category, permission_type: CategoryGroup.permission_types[:readonly])
|
||||
GroupUser.create(group: readonly_group, user: user)
|
||||
|
||||
create_post_group = Fabricate(:group)
|
||||
CategoryGroup.create(group: create_post_group, category: category, permission_type: CategoryGroup.permission_types[:create_post])
|
||||
|
||||
expect(guardian.can_join_chat_channel?(channel)).to eq(false)
|
||||
|
||||
GroupUser.create(group: create_post_group, user: user)
|
||||
category = Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:create_post])
|
||||
channel.update(chatable: category)
|
||||
guardian = Guardian.new(user)
|
||||
expect(guardian.can_join_chat_channel?(channel)).to eq(true)
|
||||
|
||||
category = Fabricate(:private_category, group: group, permission_type: CategoryGroup.permission_types[:full])
|
||||
channel.update(chatable: category)
|
||||
guardian = Guardian.new(user)
|
||||
expect(guardian.can_join_chat_channel?(channel)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user