Use activerecord error translations properly

This commit is contained in:
Rob Harrington
2017-11-30 12:07:01 +11:00
parent 1bf2f7ad03
commit 7ca60e1990
3 changed files with 4 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ class StandingOrderConfirmJob
result = payment_updater.new(@order).update!
case result
when :no_card
@order.errors.add(:base, I18n.t("activerecord.errors.models.standing_order.no_card"))
@order.errors.add(:base, :no_card)
end
end

View File

@@ -70,11 +70,11 @@ en:
attributes:
email:
taken: "There's already an account for this email. Please login or reset your password."
spree/order:
no_card: There are no valid credit cards available
activemodel:
errors:
models:
standing_order:
no_card: There are no valid credit cards available
standing_order_form:
attributes:
standing_line_items:

View File

@@ -124,7 +124,7 @@ describe StandingOrderConfirmJob do
it "adds and error to the order" do
expect{ job.send(:update_payment!) }.to change(order.errors, :count).from(0).to(1)
expect(order.errors.full_messages).to include I18n.t("activerecord.errors.models.standing_order.no_card")
expect(order.errors.full_messages).to include I18n.t("activerecord.errors.models.spree/order.no_card")
end
end
end