diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
| commit | baace1fa5df46694ddd515dc3bbca59b22df8692 (patch) | |
| tree | 6a8b587ca5d6d38377fe132b02c857f1c4149231 /test/controllers | |
| parent | ed32bc6902ab634451539770bcd910662212e01a (diff) | |
Extract flashes to i18n and stop dispatching on submit labels
Diffstat (limited to 'test/controllers')
| -rw-r--r-- | test/controllers/assets_controller_test.rb | 2 | ||||
| -rw-r--r-- | test/controllers/events_controller_test.rb | 2 | ||||
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 10 | ||||
| -rw-r--r-- | test/controllers/page_translations_controller_test.rb | 4 | ||||
| -rw-r--r-- | test/controllers/users_controller_test.rb | 18 |
5 files changed, 18 insertions, 18 deletions
diff --git a/test/controllers/assets_controller_test.rb b/test/controllers/assets_controller_test.rb index 4be2e8a1..467e1a68 100644 --- a/test/controllers/assets_controller_test.rb +++ b/test/controllers/assets_controller_test.rb | |||
| @@ -102,7 +102,7 @@ class AssetsControllerTest < ActionController::TestCase | |||
| 102 | assert_response :redirect | 102 | assert_response :redirect |
| 103 | asset = Asset.last | 103 | asset = Asset.last |
| 104 | assert_includes node.draft.assets.reload, asset | 104 | assert_includes node.draft.assets.reload, asset |
| 105 | assert_match /attached/, flash[:notice] | 105 | assert_equal I18n.t("flash.assets.attached", :title => node.title), flash[:notice] |
| 106 | end | 106 | end |
| 107 | 107 | ||
| 108 | test "create against a foreign-locked node keeps the asset but refuses the attach" do | 108 | test "create against a foreign-locked node keeps the asset but refuses the attach" do |
diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb index 46f3f4f1..d4fd66d6 100644 --- a/test/controllers/events_controller_test.rb +++ b/test/controllers/events_controller_test.rb | |||
| @@ -83,7 +83,7 @@ class EventsControllerTest < ActionController::TestCase | |||
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | assert_redirected_to edit_node_path(node) | 85 | assert_redirected_to edit_node_path(node) |
| 86 | assert_equal 'Event was successfully created.', flash[:notice] | 86 | assert_equal I18n.t("flash.events.created"), flash[:notice] |
| 87 | end | 87 | end |
| 88 | 88 | ||
| 89 | test "should not create an event without a title or a node_id" do | 89 | test "should not create an event without a title or a node_id" do |
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 8b59fc37..d7a3abbd 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -91,7 +91,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 91 | node = Node.last | 91 | node = Node.last |
| 92 | assert_includes node.draft.assets, asset | 92 | assert_includes node.draft.assets, asset |
| 93 | assert_equal asset, node.draft.headline_asset | 93 | assert_equal asset, node.draft.headline_asset |
| 94 | assert_match /attached/, flash[:notice] | 94 | assert_equal I18n.t("flash.nodes.created_with_attachment", :name => "Birth attachment") + " " + I18n.t("flash.common.now_headline"), flash[:notice] |
| 95 | end | 95 | end |
| 96 | 96 | ||
| 97 | test "the attach notice survives the redirect into the editor" do | 97 | test "the attach notice survives the redirect into the editor" do |
| @@ -104,8 +104,8 @@ class NodesControllerTest < ActionController::TestCase | |||
| 104 | 104 | ||
| 105 | get :edit, params: { :id => Node.last.id } | 105 | get :edit, params: { :id => Node.last.id } |
| 106 | assert_response :success | 106 | assert_response :success |
| 107 | assert_match /attached/, flash[:notice] | 107 | assert_equal I18n.t("flash.nodes.created_with_attachment", :name => "Flash survivor"), flash[:notice] |
| 108 | assert_no_match /ready to edit/, flash[:notice] | 108 | assert_not_equal I18n.t("flash.nodes.locked_ready"), flash[:notice] |
| 109 | end | 109 | end |
| 110 | 110 | ||
| 111 | test "editing a node" do | 111 | test "editing a node" do |
| @@ -146,7 +146,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 146 | 146 | ||
| 147 | get :edit, params: { :id => node.id } | 147 | get :edit, params: { :id => node.id } |
| 148 | assert_response :redirect | 148 | assert_response :redirect |
| 149 | assert flash[:error] =~ /Page is locked by another user/ | 149 | assert_equal I18n.t("flash.common.locked_by_other"), flash[:error] |
| 150 | end | 150 | end |
| 151 | 151 | ||
| 152 | def test_update_a_draft | 152 | def test_update_a_draft |
| @@ -282,7 +282,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 282 | 282 | ||
| 283 | put :unlock, params: { :id => node.id } | 283 | put :unlock, params: { :id => node.id } |
| 284 | assert_response :redirect | 284 | assert_response :redirect |
| 285 | assert_equal "Already unlocked", flash[:notice] | 285 | assert_equal I18n.t("flash.nodes.already_unlocked"), flash[:notice] |
| 286 | end | 286 | end |
| 287 | 287 | ||
| 288 | test "updating a node by changing its parent" do | 288 | test "updating a node by changing its parent" do |
diff --git a/test/controllers/page_translations_controller_test.rb b/test/controllers/page_translations_controller_test.rb index feaacd0e..7484a203 100644 --- a/test/controllers/page_translations_controller_test.rb +++ b/test/controllers/page_translations_controller_test.rb | |||
| @@ -55,7 +55,7 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 55 | 55 | ||
| 56 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } | 56 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } |
| 57 | 57 | ||
| 58 | assert_equal "Can't remove the only remaining translation.", flash[:error] | 58 | assert_equal I18n.t("flash.page_translations.last_translation"), flash[:error] |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | test "destroy is a safe no-op, not a false success, when the translation doesn't exist" do | 61 | test "destroy is a safe no-op, not a false success, when the translation doesn't exist" do |
| @@ -64,7 +64,7 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 64 | 64 | ||
| 65 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } | 65 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } |
| 66 | 66 | ||
| 67 | assert_match(/No EN translation exists/, flash[:error]) | 67 | assert_equal I18n.t("flash.page_translations.none_to_remove", :lang => "EN"), flash[:error] |
| 68 | end | 68 | end |
| 69 | 69 | ||
| 70 | test "autosave writes the translation without creating a new revision or touching the draft" do | 70 | test "autosave writes the translation without creating a new revision or touching the draft" do |
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index dcd8f259..67f7c053 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class UsersControllerTest < ActionController::TestCase | 3 | class UsersControllerTest < ActionController::TestCase |
| 4 | 4 | ||
| 5 | test "get index as regular user renders stripped partial" do | 5 | test "get index as regular user renders stripped partial" do |
| 6 | login_as :quentin | 6 | login_as :quentin |
| 7 | get :index | 7 | get :index |
| @@ -16,20 +16,20 @@ class UsersControllerTest < ActionController::TestCase | |||
| 16 | assert_select "button[type=submit]", I18n.t("admin.common.destroy") | 16 | assert_select "button[type=submit]", I18n.t("admin.common.destroy") |
| 17 | assert_select "a", "show" | 17 | assert_select "a", "show" |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | test "get new when logged in as admin" do | 20 | test "get new when logged in as admin" do |
| 21 | login_as :aaron | 21 | login_as :aaron |
| 22 | get :new | 22 | get :new |
| 23 | assert_response :success | 23 | assert_response :success |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | test "get new without being logged in as admin redirects back to index" do | 26 | test "get new without being logged in as admin redirects back to index" do |
| 27 | login_as :quentin | 27 | login_as :quentin |
| 28 | get :new | 28 | get :new |
| 29 | assert_response :redirect | 29 | assert_response :redirect |
| 30 | assert_redirected_to users_path | 30 | assert_redirected_to users_path |
| 31 | assert_equal( | 31 | assert_equal( |
| 32 | "Sorry, you need to be an admin for this action", | 32 | I18n.t("flash.common.admin_required"), |
| 33 | flash[:notice] | 33 | flash[:notice] |
| 34 | ) | 34 | ) |
| 35 | end | 35 | end |
| @@ -84,7 +84,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 84 | 84 | ||
| 85 | assert_redirected_to users_path | 85 | assert_redirected_to users_path |
| 86 | assert_equal( | 86 | assert_equal( |
| 87 | "Sorry, you need to be an admin for this action", | 87 | I18n.t("flash.common.admin_required"), |
| 88 | flash[:notice] | 88 | flash[:notice] |
| 89 | ) | 89 | ) |
| 90 | end | 90 | end |
| @@ -94,7 +94,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 94 | get :edit, params: { :id => User.find_by_login("aaron").id } | 94 | get :edit, params: { :id => User.find_by_login("aaron").id } |
| 95 | assert_redirected_to users_path | 95 | assert_redirected_to users_path |
| 96 | assert_equal( | 96 | assert_equal( |
| 97 | "Sorry, you need to be an admin for this action", | 97 | I18n.t("flash.common.admin_required"), |
| 98 | flash[:notice] | 98 | flash[:notice] |
| 99 | ) | 99 | ) |
| 100 | end | 100 | end |
| @@ -117,7 +117,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 117 | put :update, params: { :id => user.id, :user => {:login => "random"} } | 117 | put :update, params: { :id => user.id, :user => {:login => "random"} } |
| 118 | assert_redirected_to users_path | 118 | assert_redirected_to users_path |
| 119 | assert_equal( | 119 | assert_equal( |
| 120 | "Sorry, you need to be an admin for this action", | 120 | I18n.t("flash.common.admin_required"), |
| 121 | flash[:notice] | 121 | flash[:notice] |
| 122 | ) | 122 | ) |
| 123 | end | 123 | end |
| @@ -137,7 +137,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 137 | assert_redirected_to user_path(user) | 137 | assert_redirected_to user_path(user) |
| 138 | assert_equal "random", user.reload.login | 138 | assert_equal "random", user.reload.login |
| 139 | end | 139 | end |
| 140 | 140 | ||
| 141 | test "showing a user" do | 141 | test "showing a user" do |
| 142 | login_as :quentin | 142 | login_as :quentin |
| 143 | get :show, params: { :id => User.find_by_login("aaron").id } | 143 | get :show, params: { :id => User.find_by_login("aaron").id } |
| @@ -151,7 +151,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 151 | end | 151 | end |
| 152 | assert_redirected_to users_path | 152 | assert_redirected_to users_path |
| 153 | assert_equal( | 153 | assert_equal( |
| 154 | "Sorry, you need to be an admin for this action", | 154 | I18n.t("flash.common.admin_required"), |
| 155 | flash[:notice] | 155 | flash[:notice] |
| 156 | ) | 156 | ) |
| 157 | end | 157 | end |
