@@ -25,4 +25,52 @@ class TermControllerTest < ActionDispatch::IntegrationTest
2525
2626 assert_response :success
2727 end
28+
29+ test 'basic users see only one confirmation option' do
30+ sign_in users ( :basic )
31+ get terms_unconfirmed_path
32+
33+ assert_select 'p.wrap-filters' , text : "View:\n Categorized terms\n All terms" , count : 0
34+ end
35+
36+ test 'admin users see two confirmation options' do
37+ sign_in users ( :admin )
38+ get terms_unconfirmed_path
39+
40+ assert_select 'p.wrap-filters' , text : "View:\n Categorized terms\n All terms" , count : 1
41+ end
42+
43+ test 'basic users cannot access the confirmation option for uncategorized terms' do
44+ sign_in users ( :basic )
45+ get terms_unconfirmed_path ( show : 'all' )
46+
47+ assert_redirected_to '/'
48+ follow_redirect!
49+
50+ assert_select 'div.alert' , text : 'Not authorized.' , count : 1
51+ end
52+
53+ test 'admin users can access the confirmation option for uncategorized terms' do
54+ sign_in users ( :admin )
55+ get terms_unconfirmed_path ( show : 'all' )
56+
57+ assert_response :success
58+ end
59+
60+ test 'confirmation index can show two different sets of terms for admin users' do
61+ sign_in users ( :admin )
62+ get terms_unconfirmed_path
63+
64+ # default_pagy will be something like "Displaying 10 items"
65+ default_pagy = response . parsed_body . xpath ( '//main//span' ) . first . text
66+ default_pagy_count = default_pagy . split . second . to_i
67+
68+ get terms_unconfirmed_path ( show : 'all' )
69+
70+ # The '?type=all' route asks for more records, so the count should be higher
71+ all_pagy = response . parsed_body . xpath ( '//main//span' ) . first . text
72+ all_pagy_count = all_pagy . split . second . to_i
73+
74+ assert_operator all_pagy_count , :> , default_pagy_count
75+ end
2876end
0 commit comments