mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 01:15:47 +08:00
c531f4ded5
Rails yanked out observers many many years ago, instead the functionality was yanked out to a gem that is very lightly maintained. For example: if we want to upgrade to rails 5 there is no published gem Internally the usage of observers had quite a few problem. The series of refactors renamed a bunch of classes to give us more clarity and removed some magic.
32 lines
881 B
Ruby
32 lines
881 B
Ruby
require 'rails_helper'
|
|
require_dependency 'site'
|
|
|
|
describe Site do
|
|
it "omits categories users can not write to from the category list" do
|
|
category = Fabricate(:category)
|
|
user = Fabricate(:user)
|
|
|
|
expect(Site.new(Guardian.new(user)).categories.count).to eq(2)
|
|
|
|
category.set_permissions(:everyone => :create_post)
|
|
category.save
|
|
|
|
guardian = Guardian.new(user)
|
|
|
|
expect(Site.new(guardian)
|
|
.categories
|
|
.keep_if{|c| c.name == category.name}
|
|
.first
|
|
.permission)
|
|
.not_to eq(CategoryGroup.permission_types[:full])
|
|
|
|
# If a parent category is not visible, the child categories should not be returned
|
|
category.set_permissions(:staff => :full)
|
|
category.save
|
|
|
|
sub_category = Fabricate(:category, parent_category_id: category.id)
|
|
expect(Site.new(guardian).categories).not_to include(sub_category)
|
|
end
|
|
|
|
end
|