diff options
20 files changed, 205 insertions, 81 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6d46d522..0a7ba109 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb | |||
| @@ -40,7 +40,7 @@ class ApplicationController < ActionController::Base | |||
| 40 | return unless logged_in? | 40 | return unless logged_in? |
| 41 | return unless current_user.otp_required? && !current_user.otp_enrolled? | 41 | return unless current_user.otp_required? && !current_user.otp_enrolled? |
| 42 | return if %w[otp_enrollments otp_challenges sessions users].include?(controller_name) | 42 | return if %w[otp_enrollments otp_challenges sessions users].include?(controller_name) |
| 43 | flash[:error] = "Your account requires a second factor -- set it up to continue." | 43 | flash[:error] = t("flash.common.otp_required") |
| 44 | redirect_to edit_user_path(current_user) | 44 | redirect_to edit_user_path(current_user) |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 7edd9c05..f1c259e3 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb | |||
| @@ -49,7 +49,7 @@ class AssetsController < ApplicationController | |||
| 49 | 49 | ||
| 50 | respond_to do |format| | 50 | respond_to do |format| |
| 51 | if @asset.save | 51 | if @asset.save |
| 52 | flash[:notice] = 'Asset was successfully created.' | 52 | flash[:notice] = t("flash.assets.created") |
| 53 | NodeAction.record!(:participants => [@asset], :user => current_user, | 53 | NodeAction.record!(:participants => [@asset], :user => current_user, |
| 54 | :action => "asset_create", | 54 | :action => "asset_create", |
| 55 | :asset_name => @asset.name, | 55 | :asset_name => @asset.name, |
| @@ -72,7 +72,7 @@ class AssetsController < ApplicationController | |||
| 72 | 72 | ||
| 73 | respond_to do |format| | 73 | respond_to do |format| |
| 74 | if @asset.update(asset_params) | 74 | if @asset.update(asset_params) |
| 75 | flash[:notice] = 'Asset was successfully updated.' | 75 | flash[:notice] = t("flash.assets.updated") |
| 76 | format.html { redirect_to(@asset) } | 76 | format.html { redirect_to(@asset) } |
| 77 | format.xml { head :ok } | 77 | format.xml { head :ok } |
| 78 | else | 78 | else |
| @@ -105,14 +105,14 @@ class AssetsController < ApplicationController | |||
| 105 | :headline => params[:headline].present?) | 105 | :headline => params[:headline].present?) |
| 106 | flash[:notice] = | 106 | flash[:notice] = |
| 107 | if result[:attached].zero? | 107 | if result[:attached].zero? |
| 108 | "Asset saved — it was already attached to “#{node.title}”." | 108 | t("flash.assets.already_attached", :title => node.title) |
| 109 | else | 109 | else |
| 110 | "Asset was successfully created and attached to “#{node.title}”." | 110 | t("flash.assets.attached", :title => node.title) |
| 111 | end | 111 | end |
| 112 | case result[:headline] | 112 | case result[:headline] |
| 113 | when :set then flash[:notice] += " It is now the page's headline." | 113 | when :set then flash[:notice] += " " + t("flash.common.now_headline") |
| 114 | when :kept_existing then flash[:headline_kept_path] = node_path(node) | 114 | when :kept_existing then flash[:headline_kept_path] = node_path(node) |
| 115 | when :not_eligible then flash[:error] = "This asset type cannot be a headline." | 115 | when :not_eligible then flash[:error] = t("flash.common.headline_ineligible") |
| 116 | end | 116 | end |
| 117 | rescue LockedByAnotherUser | 117 | rescue LockedByAnotherUser |
| 118 | flash[:locked_by] = node.lock_owner&.login | 118 | flash[:locked_by] = node.lock_owner&.login |
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index be3f5476..f2c710bd 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb | |||
| @@ -43,7 +43,7 @@ class EventsController < ApplicationController | |||
| 43 | ) | 43 | ) |
| 44 | 44 | ||
| 45 | if params[:tag_list].present? && params[:auto_tag_source].present? | 45 | if params[:tag_list].present? && params[:auto_tag_source].present? |
| 46 | flash.now[:notice] = "Tag '#{params[:tag_list]}' was pre-filled because this page is tagged '#{params[:auto_tag_source]}'. You can remove it below." | 46 | flash.now[:notice] = t("flash.events.tag_prefilled", :tag => params[:tag_list], :source => params[:auto_tag_source]) |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | respond_to do |format| | 49 | respond_to do |format| |
| @@ -65,7 +65,7 @@ class EventsController < ApplicationController | |||
| 65 | 65 | ||
| 66 | respond_to do |format| | 66 | respond_to do |format| |
| 67 | if @event.save | 67 | if @event.save |
| 68 | flash[:notice] = 'Event was successfully created.' | 68 | flash[:notice] = t("flash.events.created") |
| 69 | format.html { redirect_to(safe_return_to(params[:return_to] || (@event.node ? edit_node_path(@event.node) : edit_event_path(@event)))) } | 69 | format.html { redirect_to(safe_return_to(params[:return_to] || (@event.node ? edit_node_path(@event.node) : edit_event_path(@event)))) } |
| 70 | format.xml { render :xml => @event, :status => :created, :location => @event } | 70 | format.xml { render :xml => @event, :status => :created, :location => @event } |
| 71 | else | 71 | else |
| @@ -82,7 +82,7 @@ class EventsController < ApplicationController | |||
| 82 | 82 | ||
| 83 | respond_to do |format| | 83 | respond_to do |format| |
| 84 | if @event.update(event_params) | 84 | if @event.update(event_params) |
| 85 | flash[:notice] = 'Event was successfully updated.' | 85 | flash[:notice] = t("flash.events.updated") |
| 86 | format.html { redirect_to(safe_return_to(params[:return_to] || events_path)) } | 86 | format.html { redirect_to(safe_return_to(params[:return_to] || events_path)) } |
| 87 | format.xml { head :ok } | 87 | format.xml { head :ok } |
| 88 | else | 88 | else |
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index ce8f0538..50b30881 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -55,9 +55,9 @@ class NodesController < ApplicationController | |||
| 55 | if params[:asset_id].present? && (asset = Asset.find(params[:asset_id])) | 55 | if params[:asset_id].present? && (asset = Asset.find(params[:asset_id])) |
| 56 | result = @node.attach_asset!(asset, :user => current_user, | 56 | result = @node.attach_asset!(asset, :user => current_user, |
| 57 | :headline => params[:asset_headline].present?) | 57 | :headline => params[:asset_headline].present?) |
| 58 | flash[:notice] = "Page created with “#{asset.name}” attached." | 58 | flash[:notice] = t("flash.nodes.created_with_attachment", :name => asset.name) |
| 59 | flash[:notice] += " It is the page's headline." if result[:headline] == :set | 59 | flash[:notice] += " " + t("flash.common.now_headline") if result[:headline] == :set |
| 60 | flash[:error] = "This asset type cannot be a headline." if result[:headline] == :not_eligible | 60 | flash[:error] = t("flash.common.headline_ineligible") if result[:headline] == :not_eligible |
| 61 | end | 61 | end |
| 62 | 62 | ||
| 63 | redirect_to(edit_node_path(@node)) | 63 | redirect_to(edit_node_path(@node)) |
| @@ -83,14 +83,12 @@ class NodesController < ApplicationController | |||
| 83 | @page = @node.autosave || @node.draft || @node.head | 83 | @page = @node.autosave || @node.draft || @node.head |
| 84 | 84 | ||
| 85 | if @node.autosave | 85 | if @node.autosave |
| 86 | flash.now[:notice] = | 86 | flash.now[:notice] = t("flash.nodes.autosave_banner") |
| 87 | "This page has unsaved changes from a previous session, shown below. " \ | ||
| 88 | "Save to keep them, or use \"Discard Autosave\" below to go back to the last saved version." | ||
| 89 | elsif freshly_locked | 87 | elsif freshly_locked |
| 90 | flash.now[:notice] ||= "Node locked and ready to edit" | 88 | flash.now[:notice] ||= t("flash.nodes.locked_ready") |
| 91 | end | 89 | end |
| 92 | rescue LockedByAnotherUser => e | 90 | rescue LockedByAnotherUser => e |
| 93 | flash[:error] = e.message | 91 | flash[:error] = t("flash.common.locked_by_other") |
| 94 | redirect_to(request.referer || node_path(@node)) | 92 | redirect_to(request.referer || node_path(@node)) |
| 95 | end | 93 | end |
| 96 | 94 | ||
| @@ -99,7 +97,7 @@ class NodesController < ApplicationController | |||
| 99 | @node.autosave!( page_params.merge(:tag_list => params[:tag_list]), current_user ) | 97 | @node.autosave!( page_params.merge(:tag_list => params[:tag_list]), current_user ) |
| 100 | @node.save_draft!(current_user) | 98 | @node.save_draft!(current_user) |
| 101 | 99 | ||
| 102 | flash[:notice] = "Draft saved. Publish your changes in the Status section once you're done." | 100 | flash[:notice] = t("flash.nodes.draft_saved") |
| 103 | flash[:status_path] = node_path(@node) | 101 | flash[:status_path] = node_path(@node) |
| 104 | 102 | ||
| 105 | if @node.draft.translated_locales.size > 1 | 103 | if @node.draft.translated_locales.size > 1 |
| @@ -112,7 +110,7 @@ class NodesController < ApplicationController | |||
| 112 | end | 110 | end |
| 113 | end | 111 | end |
| 114 | 112 | ||
| 115 | if params[:commit] == "Save + Unlock + Exit" | 113 | if params[:unlock_exit].present? |
| 116 | @node.unlock! | 114 | @node.unlock! |
| 117 | redirect_to node_path(@node) | 115 | redirect_to node_path(@node) |
| 118 | else | 116 | else |
| @@ -156,13 +154,16 @@ class NodesController < ApplicationController | |||
| 156 | 154 | ||
| 157 | def trash | 155 | def trash |
| 158 | if @node.trash!(current_user) | 156 | if @node.trash!(current_user) |
| 159 | flash[:notice] = "Page has been moved to the Trash" | 157 | flash[:notice] = t("flash.nodes.trashed") |
| 160 | redirect_to trashed_nodes_path | 158 | redirect_to trashed_nodes_path |
| 161 | else | 159 | else |
| 162 | flash[:notice] = "Page is already in the Trash" | 160 | flash[:notice] = t("flash.nodes.already_trashed") |
| 163 | redirect_to node_path(@node) | 161 | redirect_to node_path(@node) |
| 164 | end | 162 | end |
| 165 | rescue ActiveRecord::RecordInvalid, LockedByAnotherUser => e | 163 | rescue LockedByAnotherUser |
| 164 | flash[:error] = t("flash.common.locked_by_other") | ||
| 165 | redirect_to node_path(@node) | ||
| 166 | rescue ActiveRecord::RecordInvalid => e | ||
| 166 | flash[:error] = e.message | 167 | flash[:error] = e.message |
| 167 | redirect_to node_path(@node) | 168 | redirect_to node_path(@node) |
| 168 | end | 169 | end |
| @@ -170,10 +171,10 @@ class NodesController < ApplicationController | |||
| 170 | def restore_from_trash | 171 | def restore_from_trash |
| 171 | parent = Node.find(params[:parent_id]) | 172 | parent = Node.find(params[:parent_id]) |
| 172 | @node.restore_from_trash!(parent, current_user) | 173 | @node.restore_from_trash!(parent, current_user) |
| 173 | flash[:notice] = "Page has been restored from the Trash" | 174 | flash[:notice] = t("flash.nodes.restored") |
| 174 | redirect_to node_path(@node) | 175 | redirect_to node_path(@node) |
| 175 | rescue ActiveRecord::RecordNotFound | 176 | rescue ActiveRecord::RecordNotFound |
| 176 | flash[:error] = "Restore target not found" | 177 | flash[:error] = t("flash.nodes.restore_target_missing") |
| 177 | redirect_to node_path(@node) | 178 | redirect_to node_path(@node) |
| 178 | rescue ActiveRecord::RecordInvalid => e | 179 | rescue ActiveRecord::RecordInvalid => e |
| 179 | flash[:error] = e.message | 180 | flash[:error] = e.message |
| @@ -182,7 +183,7 @@ class NodesController < ApplicationController | |||
| 182 | 183 | ||
| 183 | def destroy | 184 | def destroy |
| 184 | @node.destroy_from_trash!(current_user) | 185 | @node.destroy_from_trash!(current_user) |
| 185 | flash[:notice] = "Page has been permanently deleted" | 186 | flash[:notice] = t("flash.nodes.deleted") |
| 186 | redirect_to trashed_nodes_path | 187 | redirect_to trashed_nodes_path |
| 187 | 188 | ||
| 188 | rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e | 189 | rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e |
| @@ -192,15 +193,15 @@ class NodesController < ApplicationController | |||
| 192 | 193 | ||
| 193 | def publish | 194 | def publish |
| 194 | @node.publish_draft!(current_user) | 195 | @node.publish_draft!(current_user) |
| 195 | flash[:notice] = "Draft has been published" | 196 | flash[:notice] = t("flash.nodes.published") |
| 196 | redirect_to node_path(@node) | 197 | redirect_to node_path(@node) |
| 197 | end | 198 | end |
| 198 | 199 | ||
| 199 | def unlock | 200 | def unlock |
| 200 | if @node.unlock! | 201 | if @node.unlock! |
| 201 | flash[:notice] = "Node unlocked" | 202 | flash[:notice] = t("flash.nodes.unlocked") |
| 202 | else | 203 | else |
| 203 | flash[:notice] = "Already unlocked" | 204 | flash[:notice] = t("flash.nodes.already_unlocked") |
| 204 | end | 205 | end |
| 205 | 206 | ||
| 206 | redirect_to node_path(@node) | 207 | redirect_to node_path(@node) |
| @@ -210,9 +211,9 @@ class NodesController < ApplicationController | |||
| 210 | @node = Node.find(params[:id]) | 211 | @node = Node.find(params[:id]) |
| 211 | if @node.draft | 212 | if @node.draft |
| 212 | @node.draft.ensure_preview_token! | 213 | @node.draft.ensure_preview_token! |
| 213 | flash[:notice] = "Shareable preview link created - see below." | 214 | flash[:notice] = t("flash.nodes.preview_created") |
| 214 | else | 215 | else |
| 215 | flash[:notice] = "Create or edit a draft first - shared preview links are only available for pages with an active draft." | 216 | flash[:notice] = t("flash.nodes.preview_needs_draft") |
| 216 | end | 217 | end |
| 217 | redirect_to node_path(@node) | 218 | redirect_to node_path(@node) |
| 218 | end | 219 | end |
| @@ -220,7 +221,7 @@ class NodesController < ApplicationController | |||
| 220 | def revoke_shared_preview | 221 | def revoke_shared_preview |
| 221 | @node = Node.find(params[:id]) | 222 | @node = Node.find(params[:id]) |
| 222 | @node.draft.revoke_preview_token! if @node.draft | 223 | @node.draft.revoke_preview_token! if @node.draft |
| 223 | flash[:notice] = "Shareable preview link revoked." | 224 | flash[:notice] = t("flash.nodes.preview_revoked") |
| 224 | redirect_to node_path(@node) | 225 | redirect_to node_path(@node) |
| 225 | end | 226 | end |
| 226 | 227 | ||
diff --git a/app/controllers/occurrences_controller.rb b/app/controllers/occurrences_controller.rb index 0f30ce38..2e3c2ec1 100644 --- a/app/controllers/occurrences_controller.rb +++ b/app/controllers/occurrences_controller.rb | |||
| @@ -49,7 +49,7 @@ class OccurrencesController < ApplicationController | |||
| 49 | 49 | ||
| 50 | respond_to do |format| | 50 | respond_to do |format| |
| 51 | if @occurrence.save | 51 | if @occurrence.save |
| 52 | flash[:notice] = 'Occurrence was successfully created.' | 52 | flash[:notice] = t("flash.occurrences.created") |
| 53 | format.html { redirect_to(@occurrence) } | 53 | format.html { redirect_to(@occurrence) } |
| 54 | format.xml { render :xml => @occurrence, :status => :created, :location => @occurrence } | 54 | format.xml { render :xml => @occurrence, :status => :created, :location => @occurrence } |
| 55 | else | 55 | else |
| @@ -66,7 +66,7 @@ class OccurrencesController < ApplicationController | |||
| 66 | 66 | ||
| 67 | respond_to do |format| | 67 | respond_to do |format| |
| 68 | if @occurrence.update(occurrence_params) | 68 | if @occurrence.update(occurrence_params) |
| 69 | flash[:notice] = 'Occurrence was successfully updated.' | 69 | flash[:notice] = t("flash.occurrences.updated") |
| 70 | format.html { redirect_to(@occurrence) } | 70 | format.html { redirect_to(@occurrence) } |
| 71 | format.xml { head :ok } | 71 | format.xml { head :ok } |
| 72 | else | 72 | else |
diff --git a/app/controllers/otp_challenges_controller.rb b/app/controllers/otp_challenges_controller.rb index e31c36ca..eeaeac20 100644 --- a/app/controllers/otp_challenges_controller.rb +++ b/app/controllers/otp_challenges_controller.rb | |||
| @@ -19,7 +19,7 @@ class OtpChallengesController < ApplicationController | |||
| 19 | session[:otp_attempts] = session[:otp_attempts].to_i + 1 | 19 | session[:otp_attempts] = session[:otp_attempts].to_i + 1 |
| 20 | if session[:otp_attempts] > MAX_ATTEMPTS | 20 | if session[:otp_attempts] > MAX_ATTEMPTS |
| 21 | clear_pending | 21 | clear_pending |
| 22 | flash[:error] = "Too many attempts -- log in again." | 22 | flash[:error] = t("flash.otp.too_many_attempts") |
| 23 | return redirect_to login_path | 23 | return redirect_to login_path |
| 24 | end | 24 | end |
| 25 | 25 | ||
| @@ -28,10 +28,10 @@ class OtpChallengesController < ApplicationController | |||
| 28 | reset_session | 28 | reset_session |
| 29 | self.current_user = user | 29 | self.current_user = user |
| 30 | session[:logged_in_at] = Time.now.to_i | 30 | session[:logged_in_at] = Time.now.to_i |
| 31 | flash[:notice] = "Logged in successfully" | 31 | flash[:notice] = t("flash.common.logged_in") |
| 32 | redirect_to safe_return_to(return_to, :default => admin_path) | 32 | redirect_to safe_return_to(return_to, :default => admin_path) |
| 33 | else | 33 | else |
| 34 | flash.now[:error] = "That code did not match." | 34 | flash.now[:error] = t("flash.otp.code_mismatch") |
| 35 | render :new | 35 | render :new |
| 36 | end | 36 | end |
| 37 | end | 37 | end |
diff --git a/app/controllers/otp_enrollments_controller.rb b/app/controllers/otp_enrollments_controller.rb index 7a31d1e1..54b82214 100644 --- a/app/controllers/otp_enrollments_controller.rb +++ b/app/controllers/otp_enrollments_controller.rb | |||
| @@ -15,7 +15,7 @@ class OtpEnrollmentsController < ApplicationController | |||
| 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. | 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. |
| 16 | def create | 16 | def create |
| 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) | 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) |
| 18 | flash[:error] = "Wrong password." | 18 | flash[:error] = t("flash.otp.wrong_password") |
| 19 | return redirect_to edit_user_path(current_user) | 19 | return redirect_to edit_user_path(current_user) |
| 20 | end | 20 | end |
| 21 | current_user.begin_otp_enrollment! | 21 | current_user.begin_otp_enrollment! |
| @@ -25,11 +25,10 @@ class OtpEnrollmentsController < ApplicationController | |||
| 25 | # Confirms with the first generated code. | 25 | # Confirms with the first generated code. |
| 26 | def update | 26 | def update |
| 27 | if current_user.confirm_otp_enrollment!(params[:code]) | 27 | if current_user.confirm_otp_enrollment!(params[:code]) |
| 28 | flash[:notice] = "Second factor enabled. The code you just entered is " \ | 28 | flash[:notice] = t("flash.otp.enabled") |
| 29 | "spent -- wait for the next one before logging in with it." | ||
| 30 | redirect_to edit_user_path(current_user) | 29 | redirect_to edit_user_path(current_user) |
| 31 | else | 30 | else |
| 32 | flash.now[:error] = "That code did not match. Rescan or wait for the next code." | 31 | flash.now[:error] = t("flash.otp.code_mismatch_rescan") |
| 33 | render :show | 32 | render :show |
| 34 | end | 33 | end |
| 35 | end | 34 | end |
| @@ -38,11 +37,11 @@ class OtpEnrollmentsController < ApplicationController | |||
| 38 | def destroy | 37 | def destroy |
| 39 | unless User.authenticate(current_user.login, params[:current_password].to_s) && | 38 | unless User.authenticate(current_user.login, params[:current_password].to_s) && |
| 40 | current_user.verify_otp!(params[:code]) | 39 | current_user.verify_otp!(params[:code]) |
| 41 | flash[:error] = "Password or code wrong -- second factor unchanged." | 40 | flash[:error] = t("flash.otp.wrong_credentials") |
| 42 | return redirect_to edit_user_path(current_user) | 41 | return redirect_to edit_user_path(current_user) |
| 43 | end | 42 | end |
| 44 | current_user.disable_otp!(:actor => current_user) | 43 | current_user.disable_otp!(:actor => current_user) |
| 45 | flash[:notice] = "Second factor disabled." | 44 | flash[:notice] = t("flash.otp.disabled") |
| 46 | redirect_to edit_user_path(current_user) | 45 | redirect_to edit_user_path(current_user) |
| 47 | end | 46 | end |
| 48 | end | 47 | end |
diff --git a/app/controllers/page_translations_controller.rb b/app/controllers/page_translations_controller.rb index 38a7c4f9..e5ca57e0 100644 --- a/app/controllers/page_translations_controller.rb +++ b/app/controllers/page_translations_controller.rb | |||
| @@ -16,14 +16,14 @@ class PageTranslationsController < ApplicationController | |||
| 16 | @page = @node.draft || @node.head | 16 | @page = @node.draft || @node.head |
| 17 | @translation = @page.translations.find_by(:locale => @locale) | 17 | @translation = @page.translations.find_by(:locale => @locale) |
| 18 | rescue LockedByAnotherUser => e | 18 | rescue LockedByAnotherUser => e |
| 19 | flash[:error] = e.message | 19 | flash[:error] = t("flash.common.locked_by_other") |
| 20 | redirect_to node_path(@node) | 20 | redirect_to node_path(@node) |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def update | 23 | def update |
| 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 25 | @node.save_draft!(current_user) | 25 | @node.save_draft!(current_user) |
| 26 | flash[:notice] = "#{@locale.upcase} translation saved. Publish the draft to make it live." | 26 | flash[:notice] = t("flash.page_translations.saved", :lang => @locale.upcase) |
| 27 | 27 | ||
| 28 | if params[:commit] == "Save + Unlock + Exit" | 28 | if params[:commit] == "Save + Unlock + Exit" |
| 29 | @node.unlock! | 29 | @node.unlock! |
| @@ -32,7 +32,7 @@ class PageTranslationsController < ApplicationController | |||
| 32 | redirect_to edit_node_translation_path(@node, @locale) | 32 | redirect_to edit_node_translation_path(@node, @locale) |
| 33 | end | 33 | end |
| 34 | rescue LockedByAnotherUser => e | 34 | rescue LockedByAnotherUser => e |
| 35 | flash[:error] = e.message | 35 | flash[:error] = t("flash.common.locked_by_other") |
| 36 | redirect_to node_path(@node) | 36 | redirect_to node_path(@node) |
| 37 | end | 37 | end |
| 38 | 38 | ||
| @@ -40,7 +40,7 @@ class PageTranslationsController < ApplicationController | |||
| 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 41 | head :ok | 41 | head :ok |
| 42 | rescue LockedByAnotherUser => e | 42 | rescue LockedByAnotherUser => e |
| 43 | render plain: e.message, status: :locked | 43 | render plain: t("flash.common.locked_by_other"), status: :locked |
| 44 | rescue ActiveRecord::RecordInvalid => e | 44 | rescue ActiveRecord::RecordInvalid => e |
| 45 | render plain: e.message, status: :unprocessable_entity | 45 | render plain: e.message, status: :unprocessable_entity |
| 46 | rescue StandardError => e | 46 | rescue StandardError => e |
| @@ -50,12 +50,12 @@ class PageTranslationsController < ApplicationController | |||
| 50 | def destroy | 50 | def destroy |
| 51 | base = @node.draft || @node.head | 51 | base = @node.draft || @node.head |
| 52 | unless base && base.translated_locales.include?(@locale) | 52 | unless base && base.translated_locales.include?(@locale) |
| 53 | flash[:error] = "No #{@locale.to_s.upcase} translation exists to remove." | 53 | flash[:error] = t("flash.page_translations.none_to_remove", :lang => @locale.to_s.upcase) |
| 54 | return redirect_to node_path(@node) | 54 | return redirect_to node_path(@node) |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | if (base.translated_locales - [@locale]).empty? | 57 | if (base.translated_locales - [@locale]).empty? |
| 58 | flash[:error] = "Can't remove the only remaining translation." | 58 | flash[:error] = t("flash.page_translations.last_translation") |
| 59 | return redirect_to node_path(@node) | 59 | return redirect_to node_path(@node) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| @@ -63,7 +63,7 @@ class PageTranslationsController < ApplicationController | |||
| 63 | draft.translations.where(:locale => @locale).delete_all | 63 | draft.translations.where(:locale => @locale).delete_all |
| 64 | draft.reload | 64 | draft.reload |
| 65 | 65 | ||
| 66 | flash[:notice] = "#{@locale.upcase} translation removed from the draft. Publish to make this permanent." | 66 | flash[:notice] = t("flash.page_translations.removed", :lang => @locale.upcase) |
| 67 | redirect_to node_path(@node) | 67 | redirect_to node_path(@node) |
| 68 | rescue LockedByAnotherUser => e | 68 | rescue LockedByAnotherUser => e |
| 69 | flash[:error] = e.message | 69 | flash[:error] = e.message |
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb index c1237a95..9f920b03 100644 --- a/app/controllers/revisions_controller.rb +++ b/app/controllers/revisions_controller.rb | |||
| @@ -26,7 +26,7 @@ class RevisionsController < ApplicationController | |||
| 26 | @end = @node.resolve_page_reference(params[:end_revision]) | 26 | @end = @node.resolve_page_reference(params[:end_revision]) |
| 27 | 27 | ||
| 28 | if @start.nil? || @end.nil? | 28 | if @start.nil? || @end.nil? |
| 29 | flash[:error] = "That comparison is no longer available." | 29 | flash[:error] = t("flash.revisions.unavailable") |
| 30 | redirect_to(node_path(@node)) and return | 30 | redirect_to(node_path(@node)) and return |
| 31 | end | 31 | end |
| 32 | 32 | ||
| @@ -50,7 +50,7 @@ class RevisionsController < ApplicationController | |||
| 50 | def restore | 50 | def restore |
| 51 | page = Page.find(params[:id]) | 51 | page = Page.find(params[:id]) |
| 52 | page.node.restore_revision! page.revision, current_user | 52 | page.node.restore_revision! page.revision, current_user |
| 53 | flash[:notice] = "Revision #{page.revision} restored" | 53 | flash[:notice] = t("flash.revisions.restored", :rev => page.revision) |
| 54 | redirect_to node_path(page.node) | 54 | redirect_to node_path(page.node) |
| 55 | end | 55 | end |
| 56 | 56 | ||
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 49d33810..bb63c51e 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb | |||
| @@ -32,10 +32,10 @@ class SessionsController < ApplicationController | |||
| 32 | session[:logged_in_at] = Time.now.to_i | 32 | session[:logged_in_at] = Time.now.to_i |
| 33 | 33 | ||
| 34 | if user.otp_required? | 34 | if user.otp_required? |
| 35 | flash[:error] = "Your account requires a second factor -- set it up now." | 35 | flash[:error] = t("flash.sessions.otp_setup_now") |
| 36 | redirect_to edit_user_path(user) | 36 | redirect_to edit_user_path(user) |
| 37 | else | 37 | else |
| 38 | flash[:notice] = "Logged in successfully" | 38 | flash[:notice] = t("flash.common.logged_in") |
| 39 | redirect_to safe_return_to(return_to, :default => admin_path) | 39 | redirect_to safe_return_to(return_to, :default => admin_path) |
| 40 | end | 40 | end |
| 41 | end | 41 | end |
| @@ -48,14 +48,14 @@ class SessionsController < ApplicationController | |||
| 48 | 48 | ||
| 49 | def destroy | 49 | def destroy |
| 50 | logout_killing_session! | 50 | logout_killing_session! |
| 51 | flash[:notice] = "You have been logged out." | 51 | flash[:notice] = t("flash.sessions.logged_out") |
| 52 | redirect_back_or_default('/login') | 52 | redirect_back_or_default('/login') |
| 53 | end | 53 | end |
| 54 | 54 | ||
| 55 | protected | 55 | protected |
| 56 | # Track failed login attempts | 56 | # Track failed login attempts |
| 57 | def note_failed_signin | 57 | def note_failed_signin |
| 58 | flash[:error] = "login not successful" | 58 | flash[:error] = t("flash.sessions.failed") |
| 59 | logger.warn "Failed login for '#{params[:login]}'" \ | 59 | logger.warn "Failed login for '#{params[:login]}'" \ |
| 60 | "from #{request.remote_ip} at #{Time.now.utc}" | 60 | "from #{request.remote_ip} at #{Time.now.utc}" |
| 61 | end | 61 | end |
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 08541b0c..12531d86 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb | |||
| @@ -22,7 +22,7 @@ class UsersController < ApplicationController | |||
| 22 | @user = User.new user_params | 22 | @user = User.new user_params |
| 23 | 23 | ||
| 24 | if @user.save | 24 | if @user.save |
| 25 | flash[:notice] = "User created #{@user.login}" | 25 | flash[:notice] = t("flash.users.created", :login => @user.login) |
| 26 | redirect_to user_path(@user) | 26 | redirect_to user_path(@user) |
| 27 | else | 27 | else |
| 28 | render :new | 28 | render :new |
| @@ -37,7 +37,7 @@ class UsersController < ApplicationController | |||
| 37 | permitted.delete(:admin) unless current_user.is_admin? | 37 | permitted.delete(:admin) unless current_user.is_admin? |
| 38 | 38 | ||
| 39 | if @user.update(permitted) | 39 | if @user.update(permitted) |
| 40 | flash[:notice] = "Updated user #{@user.login}" | 40 | flash[:notice] = t("flash.users.updated", :login => @user.login) |
| 41 | redirect_to user_path(@user) | 41 | redirect_to user_path(@user) |
| 42 | else | 42 | else |
| 43 | render :edit | 43 | render :edit |
| @@ -55,7 +55,7 @@ class UsersController < ApplicationController | |||
| 55 | def reset_otp | 55 | def reset_otp |
| 56 | return deny_user_access unless current_user.admin? | 56 | return deny_user_access unless current_user.admin? |
| 57 | @user.disable_otp!(:actor => current_user) | 57 | @user.disable_otp!(:actor => current_user) |
| 58 | flash[:notice] = "Second factor reset for #{@user.login}" | 58 | flash[:notice] = t("flash.users.otp_reset", :login => @user.login) |
| 59 | redirect_to edit_user_path(@user) | 59 | redirect_to edit_user_path(@user) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| @@ -79,7 +79,7 @@ class UsersController < ApplicationController | |||
| 79 | end | 79 | end |
| 80 | 80 | ||
| 81 | def deny_user_access | 81 | def deny_user_access |
| 82 | flash[:notice] = "Sorry, you need to be an admin for this action" | 82 | flash[:notice] = t("flash.common.admin_required") |
| 83 | redirect_to users_path | 83 | redirect_to users_path |
| 84 | end | 84 | end |
| 85 | end | 85 | end |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 1d07a21e..b65416e1 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | <% end %> | 21 | <% end %> |
| 22 | 22 | ||
| 23 | <%= submit_tag t(".save_draft"), form: dom_id(@node, :edit) %> | 23 | <%= submit_tag t(".save_draft"), form: dom_id(@node, :edit) %> |
| 24 | <%= submit_tag t(".save_unlock_exit"), form: dom_id(@node, :edit) %> | 24 | <%= submit_tag t(".save_unlock_exit"), name: "unlock_exit", form: dom_id(@node, :edit) %> |
| 25 | <%= link_to t(".preview"), preview_page_path(@page), target: "_blank", rel: "noopener", class: "preview_link" %> | 25 | <%= link_to t(".preview"), preview_page_path(@page), target: "_blank", rel: "noopener", class: "preview_link" %> |
| 26 | </div> | 26 | </div> |
| 27 | 27 | ||
| @@ -163,7 +163,7 @@ | |||
| 163 | 163 | ||
| 164 | <div class="node_action_bar"> | 164 | <div class="node_action_bar"> |
| 165 | <%= f.submit t(".save_draft") %> | 165 | <%= f.submit t(".save_draft") %> |
| 166 | <%= f.submit t(".save_unlock_exit") %> | 166 | <%= f.submit t(".save_unlock_exit"), name: "unlock_exit"%> |
| 167 | </div> | 167 | </div> |
| 168 | <% end %> | 168 | <% end %> |
| 169 | </div> | 169 | </div> |
diff --git a/app/views/page_translations/edit.html.erb b/app/views/page_translations/edit.html.erb index 2b2ce137..ac91d22c 100644 --- a/app/views/page_translations/edit.html.erb +++ b/app/views/page_translations/edit.html.erb | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | form: { class: 'button_to state_changing' }, | 15 | form: { class: 'button_to state_changing' }, |
| 16 | disabled: @node.autosave.present? %> | 16 | disabled: @node.autosave.present? %> |
| 17 | <%= submit_tag "Save #{@locale.to_s.upcase} translation", form: "translation_edit_form" %> | 17 | <%= submit_tag "Save #{@locale.to_s.upcase} translation", form: "translation_edit_form" %> |
| 18 | <%= submit_tag "Save + Unlock + Exit", form: "translation_edit_form" %> | 18 | <%= submit_tag "Save + Unlock + Exit", name: "unlock_exit", form: "translation_edit_form" %> |
| 19 | <%= link_to "Preview ↗", preview_page_path(@page, :locale => @locale), target: "_blank", rel: "noopener", class: "preview_link" %> | 19 | <%= link_to "Preview ↗", preview_page_path(@page, :locale => @locale), target: "_blank", rel: "noopener", class: "preview_link" %> |
| 20 | </div> | 20 | </div> |
| 21 | 21 | ||
diff --git a/config/locales/de.yml b/config/locales/de.yml index ab7852ce..3e0dfdd7 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml | |||
| @@ -374,3 +374,65 @@ de: | |||
| 374 | other: "\"%{title}\" und die %{count} Seiten darunter endgültig löschen? Das kann nicht rückgängig gemacht werden." | 374 | other: "\"%{title}\" und die %{count} Seiten darunter endgültig löschen? Das kann nicht rückgängig gemacht werden." |
| 375 | delete_permanently: "Endgültig löschen" | 375 | delete_permanently: "Endgültig löschen" |
| 376 | restore_hint: "Zum Wiederherstellen eine Seite öffnen und in ihrem Papierkorb-Abschnitt einen neuen Eltern-Node wählen." | 376 | restore_hint: "Zum Wiederherstellen eine Seite öffnen und in ihrem Papierkorb-Abschnitt einen neuen Eltern-Node wählen." |
| 377 | |||
| 378 | flash: | ||
| 379 | common: | ||
| 380 | logged_in: "Erfolgreich angemeldet" | ||
| 381 | otp_required: "Dein Konto erfordert einen zweiten Faktor — richte ihn ein, um fortzufahren." | ||
| 382 | admin_required: "Dafür sind Admin-Rechte erforderlich" | ||
| 383 | now_headline: "Es ist jetzt der Aufmacher der Seite." | ||
| 384 | headline_ineligible: "Dieser Asset-Typ kann kein Aufmacher sein." | ||
| 385 | locked_by_other: "Die Seite ist gerade von jemand anderem gesperrt." | ||
| 386 | autosave_failed: "Autosave fehlgeschlagen" | ||
| 387 | sessions: | ||
| 388 | otp_setup_now: "Dein Konto erfordert einen zweiten Faktor — richte ihn jetzt ein." | ||
| 389 | logged_out: "Du wurdest abgemeldet." | ||
| 390 | failed: "Anmeldung fehlgeschlagen" | ||
| 391 | otp: | ||
| 392 | too_many_attempts: "Zu viele Versuche — bitte neu anmelden." | ||
| 393 | code_mismatch: "Der Code hat nicht gepasst." | ||
| 394 | code_mismatch_rescan: "Der Code hat nicht gepasst. Neu scannen oder auf den nächsten Code warten." | ||
| 395 | wrong_password: "Falsches Passwort." | ||
| 396 | wrong_credentials: "Passwort oder Code falsch — zweiter Faktor unverändert." | ||
| 397 | enabled: "Zweiter Faktor aktiviert. Der eben eingegebene Code ist verbraucht — für die Anmeldung auf den nächsten warten." | ||
| 398 | disabled: "Zweiter Faktor entfernt." | ||
| 399 | users: | ||
| 400 | created: "Benutzer %{login} angelegt" | ||
| 401 | updated: "Benutzer %{login} aktualisiert" | ||
| 402 | otp_reset: "Zweiter Faktor von %{login} zurückgesetzt" | ||
| 403 | assets: | ||
| 404 | created: "Asset wurde angelegt." | ||
| 405 | updated: "Asset wurde aktualisiert." | ||
| 406 | attached: "Asset wurde angelegt und an „%{title}“ angehängt." | ||
| 407 | already_attached: "Asset gespeichert — es war bereits an „%{title}“ angehängt." | ||
| 408 | events: | ||
| 409 | created: "Termin wurde angelegt." | ||
| 410 | updated: "Termin wurde aktualisiert." | ||
| 411 | tag_prefilled: "Tag '%{tag}' wurde vorausgefüllt, weil diese Seite mit '%{source}' getaggt ist. Er lässt sich unten entfernen." | ||
| 412 | occurrences: | ||
| 413 | created: "Termin-Instanz wurde angelegt." | ||
| 414 | updated: "Termin-Instanz wurde aktualisiert." | ||
| 415 | revisions: | ||
| 416 | unavailable: "Dieser Vergleich ist nicht mehr verfügbar." | ||
| 417 | restored: "Revision %{rev} wiederhergestellt" | ||
| 418 | nodes: | ||
| 419 | created_with_attachment: "Seite mit angehängtem „%{name}“ angelegt." | ||
| 420 | autosave_banner: "Diese Seite hat ungespeicherte Änderungen aus einer früheren Sitzung, unten angezeigt. Speichern, um sie zu behalten — oder unten \"Autosave verwerfen\" nutzen, um zum letzten gespeicherten Stand zurückzukehren." | ||
| 421 | locked_ready: "Node gesperrt und bereit zum Bearbeiten" | ||
| 422 | draft_saved: "Entwurf gespeichert. Veröffentliche deine Änderungen im Status-Abschnitt, sobald du fertig bist." | ||
| 423 | trashed: "Seite wurde in den Papierkorb verschoben" | ||
| 424 | already_trashed: "Seite ist bereits im Papierkorb" | ||
| 425 | restored: "Seite wurde aus dem Papierkorb wiederhergestellt" | ||
| 426 | restore_target_missing: "Wiederherstellungsziel nicht gefunden" | ||
| 427 | deleted: "Seite wurde endgültig gelöscht" | ||
| 428 | published: "Entwurf wurde veröffentlicht" | ||
| 429 | unlocked: "Node entsperrt" | ||
| 430 | already_unlocked: "Bereits entsperrt" | ||
| 431 | preview_created: "Teilbarer Vorschau-Link erzeugt — siehe unten." | ||
| 432 | preview_needs_draft: "Erst einen Entwurf anlegen oder bearbeiten — teilbare Vorschau-Links gibt es nur für Seiten mit aktivem Entwurf." | ||
| 433 | preview_revoked: "Teilbarer Vorschau-Link zurückgezogen." | ||
| 434 | page_translations: | ||
| 435 | saved: "%{lang}-Übersetzung gespeichert. Den Entwurf veröffentlichen, um sie live zu schalten." | ||
| 436 | none_to_remove: "Es existiert keine %{lang}-Übersetzung zum Entfernen." | ||
| 437 | last_translation: "Die einzige verbliebene Übersetzung kann nicht entfernt werden." | ||
| 438 | removed: "%{lang}-Übersetzung aus dem Entwurf entfernt. Veröffentlichen, um das dauerhaft zu machen." | ||
diff --git a/config/locales/en.yml b/config/locales/en.yml index cb75693b..616a1d8f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml | |||
| @@ -326,3 +326,65 @@ en: | |||
| 326 | other: "Delete \"%{title}\" and the %{count} pages beneath it permanently? This cannot be undone." | 326 | other: "Delete \"%{title}\" and the %{count} pages beneath it permanently? This cannot be undone." |
| 327 | delete_permanently: "Delete permanently" | 327 | delete_permanently: "Delete permanently" |
| 328 | restore_hint: "To restore a page, open it and pick a new parent in its Trash section." | 328 | restore_hint: "To restore a page, open it and pick a new parent in its Trash section." |
| 329 | |||
| 330 | flash: | ||
| 331 | common: | ||
| 332 | logged_in: "Logged in successfully" | ||
| 333 | otp_required: "Your account requires a second factor -- set it up to continue." | ||
| 334 | admin_required: "Sorry, you need to be an admin for this action" | ||
| 335 | now_headline: "It is now the page's headline." | ||
| 336 | headline_ineligible: "This asset type cannot be a headline." | ||
| 337 | locked_by_other: "The page is locked by another editor." | ||
| 338 | autosave_failed: "Autosave failed" | ||
| 339 | sessions: | ||
| 340 | otp_setup_now: "Your account requires a second factor -- set it up now." | ||
| 341 | logged_out: "You have been logged out." | ||
| 342 | failed: "login not successful" | ||
| 343 | otp: | ||
| 344 | too_many_attempts: "Too many attempts -- log in again." | ||
| 345 | code_mismatch: "That code did not match." | ||
| 346 | code_mismatch_rescan: "That code did not match. Rescan or wait for the next code." | ||
| 347 | wrong_password: "Wrong password." | ||
| 348 | wrong_credentials: "Password or code wrong -- second factor unchanged." | ||
| 349 | enabled: "Second factor enabled. The code you just entered is spent -- wait for the next one before logging in with it." | ||
| 350 | disabled: "Second factor disabled." | ||
| 351 | users: | ||
| 352 | created: "User created %{login}" | ||
| 353 | updated: "Updated user %{login}" | ||
| 354 | otp_reset: "Second factor reset for %{login}" | ||
| 355 | assets: | ||
| 356 | created: "Asset was successfully created." | ||
| 357 | updated: "Asset was successfully updated." | ||
| 358 | attached: "Asset was successfully created and attached to “%{title}”." | ||
| 359 | already_attached: "Asset saved — it was already attached to “%{title}”." | ||
| 360 | events: | ||
| 361 | created: "Event was successfully created." | ||
| 362 | updated: "Event was successfully updated." | ||
| 363 | tag_prefilled: "Tag '%{tag}' was pre-filled because this page is tagged '%{source}'. You can remove it below." | ||
| 364 | occurrences: | ||
| 365 | created: "Occurrence was successfully created." | ||
| 366 | updated: "Occurrence was successfully updated." | ||
| 367 | revisions: | ||
| 368 | unavailable: "That comparison is no longer available." | ||
| 369 | restored: "Revision %{rev} restored" | ||
| 370 | nodes: | ||
| 371 | created_with_attachment: "Page created with “%{name}” attached." | ||
| 372 | autosave_banner: "This page has unsaved changes from a previous session, shown below. Save to keep them, or use \"Discard Autosave\" below to go back to the last saved version." | ||
| 373 | locked_ready: "Node locked and ready to edit" | ||
| 374 | draft_saved: "Draft saved. Publish your changes in the Status section once you're done." | ||
| 375 | trashed: "Page has been moved to the Trash" | ||
| 376 | already_trashed: "Page is already in the Trash" | ||
| 377 | restored: "Page has been restored from the Trash" | ||
| 378 | restore_target_missing: "Restore target not found" | ||
| 379 | deleted: "Page has been permanently deleted" | ||
| 380 | published: "Draft has been published" | ||
| 381 | unlocked: "Node unlocked" | ||
| 382 | already_unlocked: "Already unlocked" | ||
| 383 | preview_created: "Shareable preview link created - see below." | ||
| 384 | preview_needs_draft: "Create or edit a draft first - shared preview links are only available for pages with an active draft." | ||
| 385 | preview_revoked: "Shareable preview link revoked." | ||
| 386 | page_translations: | ||
| 387 | saved: "%{lang} translation saved. Publish the draft to make it live." | ||
| 388 | none_to_remove: "No %{lang} translation exists to remove." | ||
| 389 | last_translation: "Can't remove the only remaining translation." | ||
| 390 | removed: "%{lang} translation removed from the draft. Publish to make this permanent." | ||
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 |
