From ef22269324137992776acdceb72d5cc274cbde70 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 29 May 2025 14:04:11 +1000 Subject: [PATCH] Clarify voucher code not found can mean fully redeemed --- app/controllers/voucher_adjustments_controller.rb | 4 ++-- config/locales/en.yml | 3 ++- spec/requests/voucher_adjustments_spec.rb | 6 +++--- spec/system/consumer/checkout/payment_spec.rb | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/voucher_adjustments_controller.rb b/app/controllers/voucher_adjustments_controller.rb index cb9d0c83e4..857e7c5e6f 100644 --- a/app/controllers/voucher_adjustments_controller.rb +++ b/app/controllers/voucher_adjustments_controller.rb @@ -5,7 +5,7 @@ class VoucherAdjustmentsController < BaseController def create if voucher_params[:voucher_code].blank? - @order.errors.add(:voucher_code, I18n.t('checkout.errors.voucher_not_found')) + @order.errors.add(:voucher_code, I18n.t('checkout.errors.voucher_code_blank')) return render_error end @@ -43,7 +43,7 @@ class VoucherAdjustmentsController < BaseController return false if @order.errors.present? if voucher.nil? - @order.errors.add(:voucher_code, I18n.t('checkout.errors.voucher_not_found')) + @order.errors.add(:voucher_code, I18n.t('checkout.errors.voucher_code_not_found')) return false end diff --git a/config/locales/en.yml b/config/locales/en.yml index 64c88cb229..0015907cc1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2172,7 +2172,8 @@ en: select_a_shipping_method: Select a shipping method select_a_payment_method: Select a payment method no_shipping_methods_available: Checkout is not possible due to absence of shipping options. Please contact the shop owner. - voucher_not_found: Not found + voucher_code_blank: Please enter a valid voucher code + voucher_code_not_found: invalid. It either doesn't exist or has been redeemed fully add_voucher_error: There was an error while adding the voucher create_voucher_error: "There was an error while creating the voucher: %{error}" voucher_redeeming_error: There was an error while trying to redeem your voucher diff --git a/spec/requests/voucher_adjustments_spec.rb b/spec/requests/voucher_adjustments_spec.rb index 34c374e30d..4fcb382f5b 100644 --- a/spec/requests/voucher_adjustments_spec.rb +++ b/spec/requests/voucher_adjustments_spec.rb @@ -47,7 +47,7 @@ RSpec.describe VoucherAdjustmentsController do post("/voucher_adjustments", params:) expect(response).to be_unprocessable - expect(flash[:error]).to match "Voucher code Not found" + expect(flash[:error]).to match "Voucher code invalid." end end @@ -123,7 +123,7 @@ RSpec.describe VoucherAdjustmentsController do post("/voucher_adjustments", params:) expect(response).to be_unprocessable - expect(flash[:error]).to match "Voucher code Not found" + expect(flash[:error]).to match "Voucher code invalid." end end @@ -149,7 +149,7 @@ RSpec.describe VoucherAdjustmentsController do post("/voucher_adjustments", params:) expect(response).to be_unprocessable - expect(flash[:error]).to match "Voucher code Not found" + expect(flash[:error]).to match "Voucher code invalid" end end diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index d56d748666..7daff49b42 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -169,7 +169,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do fill_in "Enter voucher code", with: "non_code" click_button("Apply") - expect(page).to have_content("Voucher code Not found") + expect(page).to have_content("Voucher code invalid") end end