From 0051d6a0b89dee20fbf2b68cc605632c54a2c128 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem <svbergerem@omgsrsly.net> Date: Sat, 19 Nov 2016 01:36:36 +0100 Subject: [PATCH] Move comment, like and reshare creation error translations closes #7202 --- Changelog.md | 1 + app/controllers/comments_controller.rb | 4 ++-- app/controllers/likes_controller.rb | 2 +- app/controllers/reshares_controller.rb | 2 +- config/locales/diaspora/en.yml | 8 ++++++++ config/locales/javascript/javascript.en.yml | 3 --- spec/controllers/comments_controller_spec.rb | 2 +- spec/controllers/reshares_controller_spec.rb | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 52b4a7de9c..5e6979712b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ * Use typeahead.js from rails-assets.org [#7192](https://github.com/diaspora/diaspora/pull/7192) * Refactor ShareVisibilitesController to use PostService [#7196](https://github.com/diaspora/diaspora/pull/7196) * Unify desktop and mobile head elements [#7194](https://github.com/diaspora/diaspora/pull/7194) +* Refactor flash messages on ajax errors for comments, likes, reshares and aspect memberships [#7202](https://github.com/diaspora/diaspora/pull/7202) ## Bug fixes * Fix fetching comments after fetching likes [#7167](https://github.com/diaspora/diaspora/pull/7167) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 848e842dbb..bde3e2fbbf 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -15,14 +15,14 @@ class CommentsController < ApplicationController begin comment = comment_service.create(params[:post_id], params[:text]) rescue ActiveRecord::RecordNotFound - render text: I18n.t("javascripts.failed_to_comment"), status: 404 + render text: I18n.t("comments.create.error"), status: 404 return end if comment respond_create_success(comment) else - render text: I18n.t("javascripts.failed_to_comment"), status: 422 + render text: I18n.t("comments.create.error"), status: 422 end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index afc0be1136..5c2c65789d 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -26,7 +26,7 @@ class LikesController < ApplicationController format.json { render :json => @like.as_api_response(:backbone), :status => 201 } end else - render text: I18n.t("javascripts.failed_to_like"), status: 422 + render text: I18n.t("likes.create.error"), status: 422 end end diff --git a/app/controllers/reshares_controller.rb b/app/controllers/reshares_controller.rb index 4c9f70ca2e..7345e6343a 100644 --- a/app/controllers/reshares_controller.rb +++ b/app/controllers/reshares_controller.rb @@ -14,7 +14,7 @@ class ResharesController < ApplicationController current_user.dispatch_post(@reshare) render :json => ExtremePostPresenter.new(@reshare, current_user), :status => 201 else - render text: I18n.t("javascripts.failed_to_reshare"), status: 422 + render text: I18n.t("reshares.create.error"), status: 422 end end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index cdff0411ba..f6b53ca633 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -240,6 +240,8 @@ en: explanation: "Post to diaspora* from anywhere by bookmarking this link => %{link}." comments: + create: + error: "Failed to comment." new_comment: comment: "Comment" commenting: "Commenting..." @@ -591,6 +593,10 @@ en: source_package: "Download the source code package" be_excellent: "Be excellent to each other! ♥" + likes: + create: + error: "Failed to like." + notifications: started_sharing: zero: "%{actors} started sharing with you." @@ -991,6 +997,8 @@ en: invalid_invite: "The invite link you provided is no longer valid!" reshares: + create: + error: "Failed to reshare." reshare: reshared_via: "Reshared via" reshare_confirmation: "Reshare %{author}’s post?" diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index 94b9b49e09..a4583ee4f7 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -189,9 +189,6 @@ en: one: "In <%= count %> aspect" other: "In <%= count %> aspects" show_more: "Show more" - failed_to_like: "Failed to like. Maybe the author is ignoring you?" - failed_to_reshare: "Failed to reshare!" - failed_to_comment: "Failed to comment. Maybe the author is ignoring you?" failed_to_post_message: "Failed to post message!" failed_to_remove: "Failed to remove the entry!" comments: diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index e951b87a69..704df125e7 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -67,7 +67,7 @@ describe CommentsController, :type => :controller do expect(alice).not_to receive(:comment) post :create, comment_hash expect(response.code).to eq("404") - expect(response.body).to eq(I18n.t("javascripts.failed_to_comment")) + expect(response.body).to eq(I18n.t("comments.create.error")) end end diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb index 92d9072a81..c6f50f2d50 100644 --- a/spec/controllers/reshares_controller_spec.rb +++ b/spec/controllers/reshares_controller_spec.rb @@ -46,7 +46,7 @@ describe ResharesController, :type => :controller do it 'doesn\'t allow the user to reshare the post again' do post_request! expect(response.code).to eq('422') - expect(response.body).to eq(I18n.t("javascripts.failed_to_reshare")) + expect(response.body).to eq(I18n.t("reshares.create.error")) end end -- GitLab