@@ -7,6 +7,7 @@ class CustomMessageSettingsControllerTest < Redmine::ControllerTest
7
7
def setup
8
8
@request . session [ :user_id ] = 1 # admin
9
9
CustomMessageSetting . reload_translations! ( 'en' )
10
+ I18n . load_path = ( I18n . load_path + Dir . glob ( Rails . root . join ( 'plugins' , 'redmine_message_customize' , 'config' , 'locales' , 'custom_messages' , '*.rb' ) ) ) . uniq
10
11
end
11
12
12
13
# custom_message_settings/edit
@@ -23,8 +24,7 @@ def test_edit
23
24
def test_edit_except_admin_user
24
25
@request . session [ :user_id ] = 2
25
26
get :edit
26
- assert_response 403
27
- assert_select 'p#errorExplanation' , text : 'You are not authorized to access this page.'
27
+ assert_redirected_to ( /#{ signin_path } / )
28
28
end
29
29
30
30
def test_update_with_custom_messages
@@ -52,11 +52,25 @@ def test_update_with_invalid_params
52
52
assert_select 'h2' , :text => l ( :label_custom_messages )
53
53
assert_select 'div#errorExplanation'
54
54
end
55
- def test_edit_except_admin_user
55
+ def test_update_except_admin_user
56
56
@request . session [ :user_id ] = 2
57
57
get :update , params : { settings : { 'custom_messages' => { 'label_home' => 'Home3' } } , lang : 'en' , tab : 'normal' }
58
58
59
- assert_response 403
60
- assert_select 'p#errorExplanation' , text : 'You are not authorized to access this page.'
59
+ assert_redirected_to ( /#{ signin_path } / )
60
+ end
61
+
62
+ def test_toggle_enabled
63
+ patch :toggle_enabled
64
+ assert_redirected_to edit_custom_message_settings_path
65
+ assert_equal l ( :notice_disabled_customize ) , flash [ :notice ]
66
+
67
+ patch :toggle_enabled
68
+ assert_equal l ( :notice_enabled_customize ) , flash [ :notice ]
69
+ end
70
+ def test_toggle_enabled_except_admin_user
71
+ @request . session [ :user_id ] = 2
72
+ patch :toggle_enabled
73
+
74
+ assert_redirected_to ( /#{ signin_path } / )
61
75
end
62
76
end
0 commit comments