From 6bbcb7415bff1bb648ae2e826c6918af19d94d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Thu, 30 Jan 2020 00:55:22 +0100 Subject: [PATCH] API: don't make error messages translatable --- app/controllers/api/v1/aspects_controller.rb | 14 +++--- app/controllers/api/v1/comments_controller.rb | 14 +++--- app/controllers/api/v1/contacts_controller.rb | 10 ++--- .../api/v1/conversations_controller.rb | 4 +- app/controllers/api/v1/likes_controller.rb | 8 ++-- app/controllers/api/v1/messages_controller.rb | 4 +- .../api/v1/notifications_controller.rb | 10 ++--- app/controllers/api/v1/photos_controller.rb | 6 +-- .../api/v1/post_interactions_controller.rb | 12 ++--- app/controllers/api/v1/posts_controller.rb | 6 +-- app/controllers/api/v1/reshares_controller.rb | 8 ++-- app/controllers/api/v1/search_controller.rb | 2 +- .../api/v1/tag_followings_controller.rb | 6 +-- app/controllers/api/v1/users_controller.rb | 8 ++-- config/locales/diaspora/en.yml | 44 ------------------- .../api/aspects_controller_spec.rb | 12 ++--- .../api/comments_controller_spec.rb | 26 +++++------ .../api/contacts_controller_spec.rb | 20 ++++----- .../api/conversations_controller_spec.rb | 20 ++++----- spec/integration/api/likes_controller_spec.rb | 14 +++--- .../api/messages_controller_spec.rb | 6 +-- .../api/notifications_controller_spec.rb | 10 ++--- .../integration/api/photos_controller_spec.rb | 16 +++---- .../api/post_interactions_controller_spec.rb | 18 ++++---- spec/integration/api/posts_controller_spec.rb | 28 ++++++------ .../api/reshares_controller_spec.rb | 14 +++--- .../integration/api/search_controller_spec.rb | 6 +-- .../api/tag_followings_controller_spec.rb | 6 +-- spec/integration/api/users_controller_spec.rb | 10 ++--- 29 files changed, 159 insertions(+), 203 deletions(-) diff --git a/app/controllers/api/v1/aspects_controller.rb b/app/controllers/api/v1/aspects_controller.rb index a05f4cbae..8b1773f59 100644 --- a/app/controllers/api/v1/aspects_controller.rb +++ b/app/controllers/api/v1/aspects_controller.rb @@ -23,7 +23,7 @@ module Api if aspect render json: aspect_as_json(aspect, true) else - render_error 404, I18n.t("api.endpoint_errors.aspects.not_found") + render_error 404, "Aspect with provided ID could not be found" end end @@ -33,24 +33,24 @@ module Api if aspect&.save render json: aspect_as_json(aspect, true) else - render_error 422, I18n.t("api.endpoint_errors.aspects.cant_create") + render_error 422, "Failed to create the aspect" end rescue ActionController::ParameterMissing - render_error 422, I18n.t("api.endpoint_errors.aspects.cant_create") + render_error 422, "Failed to create the aspect" end def update aspect = current_user.aspects.where(id: params[:id]).first if !aspect - render_error 404, I18n.t("api.endpoint_errors.aspects.cant_update") + render_error 404, "Failed to update the aspect" elsif aspect.update!(aspect_params(true)) render json: aspect_as_json(aspect, true) else - render_error 422, I18n.t("api.endpoint_errors.aspects.cant_update") + render_error 422, "Failed to update the aspect" end rescue ActionController::ParameterMissing, ActiveRecord::RecordInvalid - render_error 422, I18n.t("api.endpoint_errors.aspects.cant_update") + render_error 422, "Failed to update the aspect" end def destroy @@ -58,7 +58,7 @@ module Api if aspect&.destroy head :no_content else - render_error 422, I18n.t("api.endpoint_errors.aspects.cant_delete") + render_error 422, "Failed to delete the aspect" end end diff --git a/app/controllers/api/v1/comments_controller.rb b/app/controllers/api/v1/comments_controller.rb index 405df9e8f..7e500b664 100644 --- a/app/controllers/api/v1/comments_controller.rb +++ b/app/controllers/api/v1/comments_controller.rb @@ -12,18 +12,18 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end rescue_from ActiveRecord::RecordInvalid do - render_error 422, I18n.t("api.endpoint_errors.comments.not_allowed") + render_error 422, "User is not allowed to comment" end def create find_post comment = comment_service.create(params.require(:post_id), params.require(:body)) rescue ActiveRecord::RecordNotFound - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" else render json: comment_as_json(comment), status: :created end @@ -45,7 +45,7 @@ module Api head :no_content end rescue ActiveRecord::RecordInvalid - render_error 403, I18n.t("api.endpoint_errors.comments.no_delete") + render_error 403, "User not allowed to delete the comment" end def report @@ -64,7 +64,7 @@ module Api if report.save head :no_content else - render_error 409, I18n.t("api.endpoint_errors.comments.duplicate_report") + render_error 409, "This item already has been reported by this user" end end @@ -72,10 +72,10 @@ module Api def comment_and_post_validate(post_guid, comment_guid) if !comment_exists(comment_guid) - render_error 404, I18n.t("api.endpoint_errors.comments.not_found") + render_error 404, "Comment not found for the given post" false elsif !comment_is_for_post(post_guid, comment_guid) - render_error 404, I18n.t("api.endpoint_errors.comments.not_found") + render_error 404, "Comment not found for the given post" false else true diff --git a/app/controllers/api/v1/contacts_controller.rb b/app/controllers/api/v1/contacts_controller.rb index 41028204f..c6c8b8f90 100644 --- a/app/controllers/api/v1/contacts_controller.rb +++ b/app/controllers/api/v1/contacts_controller.rb @@ -14,7 +14,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.aspects.not_found") + render_error 404, "Aspect with provided ID could not be found" end def index @@ -34,10 +34,10 @@ module Api if aspect_membership head :no_content else - render_error 422, I18n.t("api.endpoint_errors.contacts.cant_create") + render_error 422, "Failed to add user to aspect" end rescue ActiveRecord::RecordNotUnique - render_error 422, I18n.t("api.endpoint_errors.contacts.cant_create") + render_error 422, "Failed to add user to aspect" end def destroy @@ -48,10 +48,10 @@ module Api if result && result[:success] head :no_content else - render_error 422, I18n.t("api.endpoint_errors.contacts.cant_delete") + render_error 422, "Failed to remove user from aspect" end rescue ActiveRecord::RecordNotFound - render_error 404, I18n.t("api.endpoint_errors.contacts.not_found") + render_error 404, "Aspect or contact on aspect not found" end def aspects_membership_service diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index 61649013c..d87f4c0a4 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -10,7 +10,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.conversations.not_found") + render_error 404, "Conversation with provided guid could not be found" end def index @@ -40,7 +40,7 @@ module Api Diaspora::Federation::Dispatcher.defer_dispatch(current_user, conversation) render json: conversation_as_json(conversation), status: :created rescue ActiveRecord::RecordInvalid, ActionController::ParameterMissing, ActiveRecord::RecordNotFound - render_error 422, I18n.t("api.endpoint_errors.conversations.cant_process") + render_error 422, "Couldn’t accept or process the conversation" end def destroy diff --git a/app/controllers/api/v1/likes_controller.rb b/app/controllers/api/v1/likes_controller.rb index ec20ecf91..30ee81149 100644 --- a/app/controllers/api/v1/likes_controller.rb +++ b/app/controllers/api/v1/likes_controller.rb @@ -12,11 +12,11 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end rescue_from ActiveRecord::RecordInvalid do - render_error 422, I18n.t("api.endpoint_errors.likes.user_not_allowed_to_like") + render_error 422, "User is not allowed to like" end def show @@ -36,7 +36,7 @@ module Api like_service.create(params[:post_id]) rescue ActiveRecord::RecordInvalid => e if e.message == "Validation failed: Target has already been taken" - return render_error 409, I18n.t("api.endpoint_errors.likes.like_exists") + return render_error 409, "Like already exists" end raise @@ -52,7 +52,7 @@ module Api if success head :no_content else - render_error 410, I18n.t("api.endpoint_errors.likes.no_like") + render_error 410, "Like doesn’t exist" end end diff --git a/app/controllers/api/v1/messages_controller.rb b/app/controllers/api/v1/messages_controller.rb index f6db1ba2a..6b12d2082 100644 --- a/app/controllers/api/v1/messages_controller.rb +++ b/app/controllers/api/v1/messages_controller.rb @@ -8,7 +8,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.conversations.not_found") + render_error 404, "Conversation with provided guid could not be found" end def create @@ -19,7 +19,7 @@ module Api Diaspora::Federation::Dispatcher.defer_dispatch(current_user, message) render json: message_json(message), status: :created rescue ActionController::ParameterMissing - render_error 422, I18n.t("api.endpoint_errors.conversations.cant_process") + render_error 422, "Couldn’t accept or process the conversation" end def index diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index 94a5b41a2..d6662ccef 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -8,7 +8,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.notifications.not_found") + render_error 404, "Notification with provided guid could not be found" end def show @@ -17,7 +17,7 @@ module Api if notification render json: NotificationPresenter.new(notification).as_api_json(true) else - render_error 404, I18n.t("api.endpoint_errors.notifications.not_found") + render_error 404, "Notification with provided guid could not be found" end end @@ -31,7 +31,7 @@ module Api end render_paged_api_response notifications_page rescue ArgumentError - render_error 422, I18n.t("api.endpoint_errors.notifications.cant_process") + render_error 422, "Couldnt process the notifications requestt process the notifications request" end def update @@ -39,10 +39,10 @@ module Api if service.update_status_by_guid(params[:id], read) head :no_content else - render_error 422, I18n.t("api.endpoint_errors.notifications.cant_process") + render_error 422, "Couldnt process the notifications requestt process the notifications request" end rescue ActionController::ParameterMissing - render_error 422, I18n.t("api.endpoint_errors.notifications.cant_process") + render_error 422, "Couldnt process the notifications requestt process the notifications request" end private diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb index b97f12ed3..132dd3344 100644 --- a/app/controllers/api/v1/photos_controller.rb +++ b/app/controllers/api/v1/photos_controller.rb @@ -12,7 +12,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.photos.not_found") + render_error 404, "Photo with provided guid could not be found" end def index @@ -46,7 +46,7 @@ module Api render json: photo_json(photo) rescue CarrierWave::IntegrityError, ActionController::ParameterMissing, RuntimeError - render_error 422, I18n.t("api.endpoint_errors.photos.failed_create") + render_error 422, "Failed to create the photo" end def destroy @@ -58,7 +58,7 @@ module Api if current_user.retract(photo) head :no_content else - render_error 422, I18n.t("api.endpoint_errors.photos.failed_delete") + render_error 422, "Not allowed to delete the photo" end end diff --git a/app/controllers/api/v1/post_interactions_controller.rb b/app/controllers/api/v1/post_interactions_controller.rb index 945ea6314..173bd3292 100644 --- a/app/controllers/api/v1/post_interactions_controller.rb +++ b/app/controllers/api/v1/post_interactions_controller.rb @@ -10,7 +10,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end def subscribe @@ -20,7 +20,7 @@ module Api current_user.participate!(post) head :no_content rescue ActiveRecord::RecordInvalid - render_error 422, I18n.t("api.endpoint_errors.interactions.cant_subscribe") + render_error 422, "Cannot subscribe to this post" end def hide @@ -49,10 +49,10 @@ module Api if report.save head :no_content else - render_error 409, I18n.t("api.endpoint_errors.posts.cant_report") + render_error 409, "Failed to create report on this post" end rescue ActionController::ParameterMissing - render_error 422, I18n.t("api.endpoint_errors.posts.cant_report") + render_error 422, "Failed to create report on this post" end def vote @@ -66,10 +66,10 @@ module Api if poll_vote head :no_content else - render_error 422, I18n.t("api.endpoint_errors.interactions.cant_vote") + render_error 422, "Cant vote on this post" end rescue ActiveRecord::RecordInvalid - render_error 422, I18n.t("api.endpoint_errors.interactions.cant_vote") + render_error 422, "Cant vote on this post" end private diff --git a/app/controllers/api/v1/posts_controller.rb b/app/controllers/api/v1/posts_controller.rb index eb854368f..ae0bd663f 100644 --- a/app/controllers/api/v1/posts_controller.rb +++ b/app/controllers/api/v1/posts_controller.rb @@ -14,7 +14,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end def show @@ -31,14 +31,14 @@ module Api @status_message = creation_service.create(creation_params) render json: PostPresenter.new(@status_message, current_user).as_api_response rescue StandardError - render_error 422, I18n.t("api.endpoint_errors.posts.failed_create") + render_error 422, "Failed to create the post" end def destroy post_service.destroy(params[:id], private_modify?) head :no_content rescue Diaspora::NotMine, Diaspora::NonPublic - render_error 403, I18n.t("api.endpoint_errors.posts.failed_delete") + render_error 403, "Not allowed to delete the post" end private diff --git a/app/controllers/api/v1/reshares_controller.rb b/app/controllers/api/v1/reshares_controller.rb index dd9052e40..280f0ded3 100644 --- a/app/controllers/api/v1/reshares_controller.rb +++ b/app/controllers/api/v1/reshares_controller.rb @@ -12,11 +12,11 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end rescue_from Diaspora::NonPublic do - render_error 404, I18n.t("api.endpoint_errors.posts.post_not_found") + render_error 404, "Post with provided guid could not be found" end def show @@ -35,9 +35,9 @@ module Api def create reshare = reshare_service.create(params.require(:post_id)) rescue ActiveRecord::RecordInvalid - render_error 409, I18n.t("reshares.create.error") + render_error 409, "Reshare already exists" rescue ActiveRecord::RecordNotFound, RuntimeError - render_error 422, I18n.t("reshares.create.error") + render_error 422, "Failed to reshare" else render json: PostPresenter.new(reshare, current_user).as_api_response end diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 555c04c7c..c3464a194 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -8,7 +8,7 @@ module Api end rescue_from ActionController::ParameterMissing, RuntimeError do - render_error 422, I18n.t("api.endpoint_errors.search.cant_process") + render_error 422, "Search request could not be processed" end def user_index diff --git a/app/controllers/api/v1/tag_followings_controller.rb b/app/controllers/api/v1/tag_followings_controller.rb index 92a45b493..40d393957 100755 --- a/app/controllers/api/v1/tag_followings_controller.rb +++ b/app/controllers/api/v1/tag_followings_controller.rb @@ -19,16 +19,16 @@ module Api tag_followings_service.create(params.require(:name)) head :no_content rescue TagFollowingService::DuplicateTag - render_error 409, I18n.t("api.endpoint_errors.tags.cant_process") + render_error 409, "Already following this tag" rescue StandardError - render_error 422, I18n.t("api.endpoint_errors.tags.cant_process") + render_error 422, "Failed to process the tag followings request" end def destroy tag_followings_service.destroy_by_name(params.require(:id)) head :no_content rescue ActiveRecord::RecordNotFound - render_error 410, I18n.t("api.endpoint_errors.tags.cant_process") + render_error 410, "Not following this tag" end private diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 64f3b77ba..a7cf3effb 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -22,7 +22,7 @@ module Api end rescue_from ActiveRecord::RecordNotFound do - render_error 404, I18n.t("api.endpoint_errors.users.not_found") + render_error 404, "User not found" end def show @@ -42,15 +42,15 @@ module Api if params_to_update && current_user.update_profile(params_to_update) render json: PersonPresenter.new(current_user.person, current_user).profile_hash_as_api_json else - render_error 422, I18n.t("api.endpoint_errors.users.cant_update") + render_error 422, "Failed to update the user settings" end rescue RuntimeError - render_error 422, I18n.t("api.endpoint_errors.users.cant_update") + render_error 422, "Failed to update the user settings" end def contacts if params.require(:user_id) != current_user.guid - render_error 404, I18n.t("api.endpoint_errors.users.not_found") + render_error 404, "User not found" return end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 5fea36f0a..b683b3073 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -984,50 +984,6 @@ en: contact_developer: "You should contact the developer of the application and include the following detailed error message:" login_required: "You must first login before you can authorize this application" could_not_authorize: "The application could not be authorized" - endpoint_errors: - aspects: - cant_create: "Failed to create the aspect" - cant_delete: "Failed to delete the aspect" - cant_update: "Failed to update the aspect" - not_found: "Aspect with provided ID could not be found" - conversations: - not_found: "Conversation with provided guid could not be found" - cant_process: "Couldn’t accept or process the conversation" - comments: - not_found: "Comment not found for the given post" - not_allowed: "User is not allowed to comment" - no_delete: "User not allowed to delete the comment" - duplicate_report: "This item already has been reported by this user" - contacts: - not_found: "Aspect or contact on aspect not found" - cant_create: "Failed to add user to aspect" - cant_delete: "Failed to remove user from aspect" - likes: - user_not_allowed_to_like: "User is not allowed to like" - like_exists: "Like already exists" - no_like: "Like doesn’t exist" - interactions: - cant_subscribe: "Can't subscribe to this post" - cant_vote: "Can't vote on this post" - notifications: - not_found: "Notification with provided guid could not be found" - cant_process: "Couldn't process the notifications request" - photos: - not_found: "Photo with provided guid could not be found" - failed_create: "Failed to create the photo" - failed_delete: "Not allowed to delete the photo" - posts: - post_not_found: "Post with provided guid could not be found" - failed_create: "Failed to create the post" - failed_delete: "Not allowed to delete the post" - cant_report: "Failed to create report on this post" - users: - cant_update: "Failed to update the user settings" - not_found: "User not found" - search: - cant_process: "Search request could not be processed" - tags: - cant_process: "Failed to process the tag followings request" error: not_found: "No record found for given id." diff --git a/spec/integration/api/aspects_controller_spec.rb b/spec/integration/api/aspects_controller_spec.rb index 0ed32e2fb..a664b66ea 100644 --- a/spec/integration/api/aspects_controller_spec.rb +++ b/spec/integration/api/aspects_controller_spec.rb @@ -91,7 +91,7 @@ describe Api::V1::AspectsController do api_v1_aspect_path("-1"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.not_found")) + confirm_api_error(response, 404, "Aspect with provided ID could not be found") end end @@ -136,7 +136,7 @@ describe Api::V1::AspectsController do params: {name: @aspect1.name, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.aspects.cant_create")) + confirm_api_error(response, 422, "Failed to create the aspect") end end @@ -147,7 +147,7 @@ describe Api::V1::AspectsController do params: {order: 0, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.aspects.cant_create")) + confirm_api_error(response, 422, "Failed to create the aspect") end end @@ -234,7 +234,7 @@ describe Api::V1::AspectsController do params: {name: @aspect1.name, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.aspects.cant_update")) + confirm_api_error(response, 422, "Failed to update the aspect") end it "fails with bad id" do @@ -243,7 +243,7 @@ describe Api::V1::AspectsController do params: {name: "NewAspectName", access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.cant_update")) + confirm_api_error(response, 404, "Failed to update the aspect") end end @@ -284,7 +284,7 @@ describe Api::V1::AspectsController do api_v1_aspect_path("-1"), params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.aspects.cant_delete")) + confirm_api_error(response, 422, "Failed to delete the aspect") end end diff --git a/spec/integration/api/comments_controller_spec.rb b/spec/integration/api/comments_controller_spec.rb index aae3f3490..2a69ecbb2 100644 --- a/spec/integration/api/comments_controller_spec.rb +++ b/spec/integration/api/comments_controller_spec.rb @@ -80,7 +80,7 @@ describe Api::V1::CommentsController do api_v1_post_comments_path(post_id: "999_999_999"), params: {body: "text", access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -101,7 +101,7 @@ describe Api::V1::CommentsController do api_v1_post_comments_path(post_id: @private_post.guid), params: {body: "comment text", access_token: access_token_public_only} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "fails without interactions scope" do @@ -152,7 +152,7 @@ describe Api::V1::CommentsController do api_v1_post_comments_path(post_id: "999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -162,7 +162,7 @@ describe Api::V1::CommentsController do api_v1_post_comments_path(post_id: @private_post.guid), params: {access_token: access_token_public_only} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "fails without valid token" do @@ -206,7 +206,7 @@ describe Api::V1::CommentsController do ), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -232,7 +232,7 @@ describe Api::V1::CommentsController do ), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.comments.not_found")) + confirm_api_error(response, 404, "Comment not found for the given post") end end @@ -246,7 +246,7 @@ describe Api::V1::CommentsController do ), params: {access_token: access_token} ) - confirm_api_error(response, 403, I18n.t("api.endpoint_errors.comments.no_delete")) + confirm_api_error(response, 403, "User not allowed to delete the comment") end end @@ -309,7 +309,7 @@ describe Api::V1::CommentsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.comments.not_found")) + confirm_api_error(response, 404, "Comment not found for the given post") end end @@ -325,7 +325,7 @@ describe Api::V1::CommentsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -341,7 +341,7 @@ describe Api::V1::CommentsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -357,7 +357,7 @@ describe Api::V1::CommentsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.comments.not_found")) + confirm_api_error(response, 404, "Comment not found for the given post") end end @@ -385,7 +385,7 @@ describe Api::V1::CommentsController do access_token: access_token } ) - confirm_api_error(response, 409, I18n.t("api.endpoint_errors.comments.duplicate_report")) + confirm_api_error(response, 409, "This item already has been reported by this user") end end @@ -401,7 +401,7 @@ describe Api::V1::CommentsController do access_token: access_token_public_only } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "fails without valid token" do diff --git a/spec/integration/api/contacts_controller_spec.rb b/spec/integration/api/contacts_controller_spec.rb index 1a07e1eb5..f6953d030 100644 --- a/spec/integration/api/contacts_controller_spec.rb +++ b/spec/integration/api/contacts_controller_spec.rb @@ -68,7 +68,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(-1), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.not_found")) + confirm_api_error(response, 404, "Aspect with provided ID could not be found") end it "fails for other user's Aspect ID" do @@ -76,7 +76,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(@eve_aspect.id), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.not_found")) + confirm_api_error(response, 404, "Aspect with provided ID could not be found") end end @@ -117,7 +117,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(@aspect2.id), params: {person_guid: alice.guid, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.contacts.cant_create")) + confirm_api_error(response, 422, "Failed to add user to aspect") end end @@ -127,7 +127,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(-1), params: {person_guid: alice.guid, access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.not_found")) + confirm_api_error(response, 404, "Aspect with provided ID could not be found") end it "fails for other user's Aspect ID" do @@ -135,7 +135,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(@eve_aspect.id), params: {person_guid: alice.guid, access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.aspects.not_found")) + confirm_api_error(response, 404, "Aspect with provided ID could not be found") end end @@ -145,7 +145,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contacts_path(@aspect2.id), params: {person_guid: "999_999_999", access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.contacts.cant_create")) + confirm_api_error(response, 422, "Failed to add user to aspect") end end @@ -188,7 +188,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contact_path(@aspect2.id, eve.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.contacts.not_found")) + confirm_api_error(response, 404, "Aspect or contact on aspect not found") end end @@ -198,7 +198,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contact_path(-1, eve.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.contacts.not_found")) + confirm_api_error(response, 404, "Aspect or contact on aspect not found") end it "fails for other user's Aspect ID" do @@ -206,7 +206,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contact_path(@eve_aspect.id, eve.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.contacts.not_found")) + confirm_api_error(response, 404, "Aspect or contact on aspect not found") end end @@ -216,7 +216,7 @@ describe Api::V1::ContactsController do api_v1_aspect_contact_path(@aspect2.id, "999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.contacts.cant_delete")) + confirm_api_error(response, 422, "Failed to remove user from aspect") end end diff --git a/spec/integration/api/conversations_controller_spec.rb b/spec/integration/api/conversations_controller_spec.rb index ab03c77fe..07ecb5f02 100644 --- a/spec/integration/api/conversations_controller_spec.rb +++ b/spec/integration/api/conversations_controller_spec.rb @@ -57,7 +57,7 @@ describe Api::V1::ConversationsController do context "without valid data" do it "fails with empty body" do post api_v1_conversations_path, params: {access_token: access_token} - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "fails with missing subject " do @@ -67,7 +67,7 @@ describe Api::V1::ConversationsController do access_token: access_token } post api_v1_conversations_path, params: incomplete_conversation - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "fails with missing body " do @@ -77,7 +77,7 @@ describe Api::V1::ConversationsController do access_token: access_token } post api_v1_conversations_path, params: incomplete_conversation - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "fails with missing recipients " do @@ -87,7 +87,7 @@ describe Api::V1::ConversationsController do access_token: access_token } post api_v1_conversations_path, params: incomplete_conversation - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "fails with bad recipient ID " do @@ -98,7 +98,7 @@ describe Api::V1::ConversationsController do access_token: access_token } post api_v1_conversations_path, params: incomplete_conversation - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "fails with invalid recipient (not allowed to message) " do @@ -109,7 +109,7 @@ describe Api::V1::ConversationsController do access_token: access_token } post api_v1_conversations_path, params: incomplete_conversation - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end end @@ -231,7 +231,7 @@ describe Api::V1::ConversationsController do api_v1_conversation_path(-1), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.conversations.not_found")) + confirm_api_error(response, 404, "Conversation with provided guid could not be found") end end @@ -284,7 +284,7 @@ describe Api::V1::ConversationsController do @conversation_guid, params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.conversations.not_found")) + confirm_api_error(response, 404, "Conversation with provided guid could not be found") get api_v1_conversation_path( @conversation_guid, params: {access_token: access_token_participant} @@ -309,7 +309,7 @@ describe Api::V1::ConversationsController do @conversation_guid, params: {access_token: access_token_participant} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.conversations.not_found")) + confirm_api_error(response, 404, "Conversation with provided guid could not be found") expect { Conversation.find(guid: @conversation_guid) @@ -323,7 +323,7 @@ describe Api::V1::ConversationsController do api_v1_conversation_path(42), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.conversations.not_found")) + confirm_api_error(response, 404, "Conversation with provided guid could not be found") end end diff --git a/spec/integration/api/likes_controller_spec.rb b/spec/integration/api/likes_controller_spec.rb index 56f232d7c..88e7ac95e 100644 --- a/spec/integration/api/likes_controller_spec.rb +++ b/spec/integration/api/likes_controller_spec.rb @@ -85,7 +85,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: "badguid"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -96,7 +96,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: @private_status.guid), params: {access_token: access_token_public_only} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.likes.user_not_allowed_to_like")) + confirm_api_error(response, 422, "User is not allowed to like") end end @@ -134,7 +134,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: @status.guid), params: {access_token: access_token} ) - confirm_api_error(response, 409, I18n.t("api.endpoint_errors.likes.like_exists")) + confirm_api_error(response, 409, "Like already exists") likes = like_service.find_for_post(@status.guid) expect(likes.length).to eq(1) @@ -148,7 +148,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: 99_999_999), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -206,7 +206,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: @status.guid), params: {access_token: access_token} ) - confirm_api_error(response, 410, I18n.t("api.endpoint_errors.likes.no_like")) + confirm_api_error(response, 410, "Like doesn’t exist") likes = like_service.find_for_post(@status.guid) expect(likes.length).to eq(0) @@ -219,7 +219,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: 99_999_999), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -230,7 +230,7 @@ describe Api::V1::LikesController do api_v1_post_likes_path(post_id: @private_status.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "fails in unliking post without interactions" do diff --git a/spec/integration/api/messages_controller_spec.rb b/spec/integration/api/messages_controller_spec.rb index 120f691e8..b345c9e70 100644 --- a/spec/integration/api/messages_controller_spec.rb +++ b/spec/integration/api/messages_controller_spec.rb @@ -71,7 +71,7 @@ describe Api::V1::MessagesController do api_v1_conversation_messages_path(@conversation_guid), params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end it "empty string returns a unprocessable entity (422)" do @@ -79,7 +79,7 @@ describe Api::V1::MessagesController do api_v1_conversation_messages_path(@conversation_guid), params: {body: "", access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.conversations.cant_process")) + confirm_api_error(response, 422, "Couldn’t accept or process the conversation") end end @@ -89,7 +89,7 @@ describe Api::V1::MessagesController do api_v1_conversation_messages_path(42), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.conversations.not_found")) + confirm_api_error(response, 404, "Conversation with provided guid could not be found") end end diff --git a/spec/integration/api/notifications_controller_spec.rb b/spec/integration/api/notifications_controller_spec.rb index e38be1e59..d362bb354 100644 --- a/spec/integration/api/notifications_controller_spec.rb +++ b/spec/integration/api/notifications_controller_spec.rb @@ -87,7 +87,7 @@ describe Api::V1::NotificationsController do api_v1_notifications_path, params: {only_after: "January 1, 2018", access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.notifications.cant_process")) + confirm_api_error(response, 422, "Couldnt process the notifications requestt process the notifications request") end it "with insufficient credentials" do @@ -129,7 +129,7 @@ describe Api::V1::NotificationsController do api_v1_notification_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.notifications.not_found")) + confirm_api_error(response, 404, "Notification with provided guid could not be found") end it "on someone else's notification" do @@ -145,7 +145,7 @@ describe Api::V1::NotificationsController do api_v1_notification_path(alice_notification.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.notifications.not_found")) + confirm_api_error(response, 404, "Notification with provided guid could not be found") end it "with insufficient credentials" do @@ -190,7 +190,7 @@ describe Api::V1::NotificationsController do api_v1_notification_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.notifications.cant_process")) + confirm_api_error(response, 422, "Couldnt process the notifications requestt process the notifications request") end it "with proper missing read field" do @@ -198,7 +198,7 @@ describe Api::V1::NotificationsController do api_v1_notification_path(@notification.guid), params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.notifications.cant_process")) + confirm_api_error(response, 422, "Couldnt process the notifications requestt process the notifications request") end it "with insufficient credentials" do diff --git a/spec/integration/api/photos_controller_spec.rb b/spec/integration/api/photos_controller_spec.rb index ec7686ca6..7e57bb601 100644 --- a/spec/integration/api/photos_controller_spec.rb +++ b/spec/integration/api/photos_controller_spec.rb @@ -109,7 +109,7 @@ describe Api::V1::PhotosController do api_v1_photo_path(@shared_photo1.guid), params: {access_token: access_token_public_only_read_only} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.photos.not_found")) + confirm_api_error(response, 404, "Photo with provided guid could not be found") end it "with other user's private photo" do @@ -117,7 +117,7 @@ describe Api::V1::PhotosController do api_v1_photo_path(@private_photo1.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.photos.not_found")) + confirm_api_error(response, 404, "Photo with provided guid could not be found") end it "with invalid GUID" do @@ -125,7 +125,7 @@ describe Api::V1::PhotosController do api_v1_photo_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.photos.not_found")) + confirm_api_error(response, 404, "Photo with provided guid could not be found") end it "with invalid access token" do @@ -241,7 +241,7 @@ describe Api::V1::PhotosController do api_v1_photos_path, params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.photos.failed_create")) + confirm_api_error(response, 422, "Failed to create the photo") end it "with non-image file" do @@ -253,7 +253,7 @@ describe Api::V1::PhotosController do api_v1_photos_path, params: {image: text_file, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.photos.failed_create")) + confirm_api_error(response, 422, "Failed to create the photo") end it "with impromperly identified file" do @@ -265,7 +265,7 @@ describe Api::V1::PhotosController do api_v1_photos_path, params: {image: text_file, access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.photos.failed_create")) + confirm_api_error(response, 422, "Failed to create the photo") end it "with invalid access token" do @@ -313,7 +313,7 @@ describe Api::V1::PhotosController do api_v1_photo_path(@alice_public_photo.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.photos.not_found")) + confirm_api_error(response, 404, "Photo with provided guid could not be found") end it "with other invalid GUID" do @@ -321,7 +321,7 @@ describe Api::V1::PhotosController do api_v1_photo_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.photos.not_found")) + confirm_api_error(response, 404, "Photo with provided guid could not be found") end it "with invalid access token" do diff --git a/spec/integration/api/post_interactions_controller_spec.rb b/spec/integration/api/post_interactions_controller_spec.rb index e7e9eb35d..b28a73dd0 100644 --- a/spec/integration/api/post_interactions_controller_spec.rb +++ b/spec/integration/api/post_interactions_controller_spec.rb @@ -82,7 +82,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "with insufficient token" do @@ -140,7 +140,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "with insufficient token" do @@ -208,7 +208,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "when not subscribed already" do @@ -285,7 +285,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "when already reported" do @@ -304,7 +304,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 409, I18n.t("api.endpoint_errors.posts.cant_report")) + confirm_api_error(response, 409, "Failed to create report on this post") end it "when missing reason" do @@ -314,7 +314,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.cant_report")) + confirm_api_error(response, 422, "Failed to create report on this post") end it "with insufficient token" do @@ -389,7 +389,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.interactions.cant_vote")) + confirm_api_error(response, 422, "Cant vote on this post") end it "fails with bad answer id" do @@ -400,7 +400,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.interactions.cant_vote")) + confirm_api_error(response, 422, "Cant vote on this post") end it "fails with bad post id" do @@ -411,7 +411,7 @@ describe Api::V1::PostInteractionsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "with insufficient token" do diff --git a/spec/integration/api/posts_controller_spec.rb b/spec/integration/api/posts_controller_spec.rb index 35af66452..7a5b10516 100644 --- a/spec/integration/api/posts_controller_spec.rb +++ b/spec/integration/api/posts_controller_spec.rb @@ -128,7 +128,7 @@ describe Api::V1::PostsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -145,7 +145,7 @@ describe Api::V1::PostsController do access_token: access_token_public_only_read_only } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") get( api_v1_post_path(shared_post.guid), @@ -165,7 +165,7 @@ describe Api::V1::PostsController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -319,7 +319,7 @@ describe Api::V1::PostsController do photos: ["999_999_999"] } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "creates with poll" do @@ -360,7 +360,7 @@ describe Api::V1::PostsController do } } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails poll with blank answer" do @@ -377,7 +377,7 @@ describe Api::V1::PostsController do } } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails poll with blank question and message text" do @@ -393,7 +393,7 @@ describe Api::V1::PostsController do } } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "creates with location" do @@ -469,7 +469,7 @@ describe Api::V1::PostsController do public: true } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails when no public field and no aspects" do @@ -481,7 +481,7 @@ describe Api::V1::PostsController do body: message_text } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails when private no aspects" do @@ -494,7 +494,7 @@ describe Api::V1::PostsController do public: false } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails when unknown aspect IDs" do @@ -508,7 +508,7 @@ describe Api::V1::PostsController do aspects: ["-1"] } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end it "fails when no public field but aspects" do @@ -523,7 +523,7 @@ describe Api::V1::PostsController do aspects: [aspect.id] } ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.posts.failed_create")) + confirm_api_error(response, 422, "Failed to create the post") end end @@ -626,7 +626,7 @@ describe Api::V1::PostsController do api_v1_post_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -643,7 +643,7 @@ describe Api::V1::PostsController do api_v1_post_path(status.guid), params: {access_token: access_token} ) - confirm_api_error(response, 403, I18n.t("api.endpoint_errors.posts.failed_delete")) + confirm_api_error(response, 403, "Not allowed to delete the post") end end end diff --git a/spec/integration/api/reshares_controller_spec.rb b/spec/integration/api/reshares_controller_spec.rb index 797e0b792..16cdbe12b 100644 --- a/spec/integration/api/reshares_controller_spec.rb +++ b/spec/integration/api/reshares_controller_spec.rb @@ -85,7 +85,7 @@ describe Api::V1::ResharesController do params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end it "fails with private post it shouldn't see" do @@ -96,7 +96,7 @@ describe Api::V1::ResharesController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end @@ -137,7 +137,7 @@ describe Api::V1::ResharesController do params: {access_token: access_token} ) - confirm_api_error(response, 409, I18n.t("reshares.create.error")) + confirm_api_error(response, 409, "Reshare already exists") end end @@ -148,7 +148,7 @@ describe Api::V1::ResharesController do params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("reshares.create.error")) + confirm_api_error(response, 422, "Failed to reshare") end it "fails with own post" do @@ -157,7 +157,7 @@ describe Api::V1::ResharesController do params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("reshares.create.error")) + confirm_api_error(response, 422, "Failed to reshare") end it "fails with private post it shouldn't see" do @@ -168,7 +168,7 @@ describe Api::V1::ResharesController do access_token: access_token } ) - confirm_api_error(response, 422, I18n.t("reshares.create.error")) + confirm_api_error(response, 422, "Failed to reshare") end it "fails with private post it can see" do @@ -179,7 +179,7 @@ describe Api::V1::ResharesController do access_token: access_token } ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.posts.post_not_found")) + confirm_api_error(response, 404, "Post with provided guid could not be found") end end diff --git a/spec/integration/api/search_controller_spec.rb b/spec/integration/api/search_controller_spec.rb index 80c1bb454..67e11ad8d 100644 --- a/spec/integration/api/search_controller_spec.rb +++ b/spec/integration/api/search_controller_spec.rb @@ -128,7 +128,7 @@ describe Api::V1::SearchController do "/api/v1/search/users", params: {tag: "tag1", name_or_handle: "name", access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.search.cant_process")) + confirm_api_error(response, 422, "Search request could not be processed") end it "fails with no fields" do @@ -136,7 +136,7 @@ describe Api::V1::SearchController do "/api/v1/search/users", params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.search.cant_process")) + confirm_api_error(response, 422, "Search request could not be processed") end it "fails with bad credentials" do @@ -208,7 +208,7 @@ describe Api::V1::SearchController do "/api/v1/search/posts", params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.search.cant_process")) + confirm_api_error(response, 422, "Search request could not be processed") end it "fails with bad credentials" do diff --git a/spec/integration/api/tag_followings_controller_spec.rb b/spec/integration/api/tag_followings_controller_spec.rb index 75514ae96..18446affc 100755 --- a/spec/integration/api/tag_followings_controller_spec.rb +++ b/spec/integration/api/tag_followings_controller_spec.rb @@ -56,7 +56,7 @@ describe Api::V1::TagFollowingsController do params: {access_token: access_token} ) - confirm_api_error(response, 422, I18n.t("api.endpoint_errors.tags.cant_process")) + confirm_api_error(response, 422, "Failed to process the tag followings request") end end @@ -67,7 +67,7 @@ describe Api::V1::TagFollowingsController do params: {name: "tag3", access_token: access_token} ) - confirm_api_error(response, 409, I18n.t("api.endpoint_errors.tags.cant_process")) + confirm_api_error(response, 409, "Already following this tag") end end @@ -150,7 +150,7 @@ describe Api::V1::TagFollowingsController do api_v1_tag_following_path(SecureRandom.uuid.to_s), params: {access_token: access_token} ) - confirm_api_error(response, 410, I18n.t("api.endpoint_errors.tags.cant_process")) + confirm_api_error(response, 410, "Not following this tag") get( api_v1_tag_followings_path, diff --git a/spec/integration/api/users_controller_spec.rb b/spec/integration/api/users_controller_spec.rb index 6edc7739b..c67a6b3cb 100644 --- a/spec/integration/api/users_controller_spec.rb +++ b/spec/integration/api/users_controller_spec.rb @@ -168,7 +168,7 @@ describe Api::V1::UsersController do "/api/v1/users/999_999_999", params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.users.not_found")) + confirm_api_error(response, 404, "User not found") end end end @@ -334,7 +334,7 @@ describe Api::V1::UsersController do api_v1_user_contacts_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.users.not_found")) + confirm_api_error(response, 404, "User not found") end it "fails with other user's GUID" do @@ -342,7 +342,7 @@ describe Api::V1::UsersController do api_v1_user_contacts_path(alice.guid), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.users.not_found")) + confirm_api_error(response, 404, "User not found") end it "fails if insufficient scope token" do @@ -424,7 +424,7 @@ describe Api::V1::UsersController do api_v1_user_photos_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.users.not_found")) + confirm_api_error(response, 404, "User not found") end it "fails if invalid token" do @@ -497,7 +497,7 @@ describe Api::V1::UsersController do api_v1_user_posts_path("999_999_999"), params: {access_token: access_token} ) - confirm_api_error(response, 404, I18n.t("api.endpoint_errors.users.not_found")) + confirm_api_error(response, 404, "User not found") end it "fails if invalid token" do