summaryrefslogtreecommitdiff
path: root/test/controllers/menu_items_controller_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-01 00:27:34 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-01 00:27:34 +0200
commit8bcacace28df52fd972c54e6850aa3b93f5c8bdf (patch)
tree05e90dd4e8f31ebb142f66239025da15e873901f /test/controllers/menu_items_controller_test.rb
parent529f81b28ed77c62acaa63fad957e751798f2440 (diff)
Declare role requirements per controller
RoleRequired supplies require_redaktion and require_admin for surfaces that are not nodes and so cannot be reached by Node#restricted?. Navigation is content rather than plumbing, so menu_items requires redaktion. User management is janitorial and requires admin: index, new, create, reset_otp, deactivate, reactivate. verify_status now also covers show, without which any logged-in user could read any account by walking a small id space. Editing your own account stays open. The dashboard hides the Users and Navigation buttons from those who cannot use them; everything else stays visible to everyone. Both denials share one message and land on the dashboard. Adds redella (redaktion) and alufa (redaktion + alumni) fixtures.
Diffstat (limited to 'test/controllers/menu_items_controller_test.rb')
-rw-r--r--test/controllers/menu_items_controller_test.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/controllers/menu_items_controller_test.rb b/test/controllers/menu_items_controller_test.rb
index 15a7b30b..d09198a3 100644
--- a/test/controllers/menu_items_controller_test.rb
+++ b/test/controllers/menu_items_controller_test.rb
@@ -9,7 +9,7 @@ class MenuItemsControllerTest < ActionController::TestCase
9 end 9 end
10 10
11 test "updating stores a title per locale" do 11 test "updating stores a title per locale" do
12 login_as :quentin 12 login_as :aaron
13 item = create_menu_item 13 item = create_menu_item
14 14
15 patch :update, params: { :id => item.id, 15 patch :update, params: { :id => item.id,
@@ -20,7 +20,7 @@ class MenuItemsControllerTest < ActionController::TestCase
20 end 20 end
21 21
22 test "blanking a non-default title falls back to the default locale" do 22 test "blanking a non-default title falls back to the default locale" do
23 login_as :quentin 23 login_as :aaron
24 item = create_menu_item 24 item = create_menu_item
25 patch :update, params: { :id => item.id, 25 patch :update, params: { :id => item.id,
26 :menu_item => { :titles => { "de" => "Transparenz", "en" => "Transparency" } } } 26 :menu_item => { :titles => { "de" => "Transparenz", "en" => "Transparency" } } }
@@ -33,7 +33,7 @@ class MenuItemsControllerTest < ActionController::TestCase
33 end 33 end
34 34
35 test "a blank default title is rejected" do 35 test "a blank default title is rejected" do
36 login_as :quentin 36 login_as :aaron
37 item = create_menu_item 37 item = create_menu_item
38 patch :update, params: { :id => item.id, 38 patch :update, params: { :id => item.id,
39 :menu_item => { :titles => { "de" => "" } } } 39 :menu_item => { :titles => { "de" => "" } } }
@@ -41,4 +41,11 @@ class MenuItemsControllerTest < ActionController::TestCase
41 assert_response :success # re-rendered :edit, not a redirect 41 assert_response :success # re-rendered :edit, not a redirect
42 assert_not_equal "", item.reload.translations.find_by(:locale => "de").title 42 assert_not_equal "", item.reload.translations.find_by(:locale => "de").title
43 end 43 end
44
45 test "an editor without redaktion cannot reach the menu" do
46 login_as :quentin
47 get :index
48 assert_redirected_to admin_path
49 assert_equal I18n.t("flash.common.redaktion_required"), flash[:error]
50 end
44end 51end