2013-07-14 09:24:16 +08:00
|
|
|
require 'spec_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)
|
|
|
|
|
2013-10-24 07:05:51 +08:00
|
|
|
Site.new(Guardian.new(user)).categories.count.should == 2
|
2013-07-14 09:24:16 +08:00
|
|
|
|
|
|
|
category.set_permissions(:everyone => :create_post)
|
|
|
|
category.save
|
|
|
|
|
2013-10-24 07:05:51 +08:00
|
|
|
Site.new(Guardian.new(user))
|
|
|
|
.categories
|
|
|
|
.keep_if{|c| c.name == category.name}
|
|
|
|
.first
|
|
|
|
.permission
|
|
|
|
.should_not == CategoryGroup.permission_types[:full]
|
2013-07-14 09:24:16 +08:00
|
|
|
end
|
|
|
|
end
|