File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,25 @@ class CategoriesControllerTest < ActionController::TestCase
7575 end
7676
7777 test 'should prevent users under min_view_trust_level viewing category that requires higher' do
78- get :show , params : { id : categories ( :admin_only ) . id }
78+ staff_only = categories ( :admin_only )
7979
80- assert_response ( :not_found )
81- assert_not_nil assigns ( :category )
80+ users . reject { |u | u . can_see_category? ( staff_only ) && !u . staff? } . each do |user |
81+ sign_in user
82+ try_show_category ( staff_only )
83+
84+ if user . staff?
85+ assert_response ( :success )
86+ else
87+ assert_response ( :not_found )
88+ end
89+
90+ assert_not_nil assigns ( :category )
91+ end
92+ end
93+
94+ private
95+
96+ def try_show_category ( category )
97+ get :show , params : { id : category . id }
8298 end
8399end
You can’t perform that action at this time.
0 commit comments