File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,11 +50,19 @@ class Category < ActiveRecord::Base
5050 }
5151
5252 scope :topic_create_allowed , -> ( guardian ) {
53- scoped_to_permissions ( guardian , [ :full ] )
53+ if guardian . anonymous?
54+ where ( "1=0" )
55+ else
56+ scoped_to_permissions ( guardian , [ :full ] )
57+ end
5458 }
5559
5660 scope :post_create_allowed , -> ( guardian ) {
57- scoped_to_permissions ( guardian , [ :create_post , :full ] )
61+ if guardian . anonymous?
62+ where ( "1=0" )
63+ else
64+ scoped_to_permissions ( guardian , [ :create_post , :full ] )
65+ end
5866 }
5967 delegate :post_template , to : 'self.class'
6068
Original file line number Diff line number Diff line change 6767 can_post_category . save
6868
6969 Category . post_create_allowed ( guardian ) . count . should == 3
70- end
7170
72- end
71+ # anonymous has permission to create no topics
72+ guardian = Guardian . new ( nil )
73+ Category . post_create_allowed ( guardian ) . count . should == 0
7374
74- describe "post_create_allowed" do
75+ end
7576
7677 end
7778
You can’t perform that action at this time.
0 commit comments