Skip to content
Permalink
Browse files

FIX: any subcategory permissions are valid if everyone has access to …

…parent category (#7097)
  • Loading branch information...
majakomel authored and SamSaffron committed Mar 4, 2019
1 parent bb39a6f commit fea5d4f3eceba37c43559a7c61a962de7d41d3b3
Showing with 7 additions and 4 deletions.
  1. +3 −0 app/models/category.rb
  2. +4 −4 spec/models/category_spec.rb
@@ -658,6 +658,9 @@ def permissions_compatibility_validator

def check_permissions_compatibility(parent_permissions, child_permissions)
parent_groups = parent_permissions.map(&:first)

return if parent_groups.include?(Group[:everyone].id)

child_groups = child_permissions.map(&:first)
only_in_subcategory = child_groups - parent_groups

@@ -779,8 +779,8 @@
expect(subcategory.valid?).to eq(true)
end

it "is valid if no permissions are set on parent" do
parent_category.set_permissions(everyone: :full)
it "is valid if everyone has access to parent category" do
parent_category.set_permissions(everyone: :readonly)
parent_category.save!

subcategory.set_permissions(group => :create_post, group2 => :create_post)
@@ -814,10 +814,10 @@

end

it "is valid if no permissions set on parent" do
it "is valid if everyone has access to parent category" do
subcategory.set_permissions(group => :create_post)
subcategory.save
parent_category.set_permissions(everyone: :full)
parent_category.set_permissions(everyone: :readonly)

expect(parent_category.valid?).to eq(true)
end

2 comments on commit fea5d4f

@discoursebot

This comment has been minimized.

Copy link

replied Mar 4, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/parent-category-with-more-restrictions-than-subcategory/20913/12

@discoursebot

This comment has been minimized.

Copy link

replied Apr 1, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/unable-to-set-up-permissions-on-parent-subcategory/112562/3

Please sign in to comment.
You can’t perform that action at this time.