diff --git a/config/locales/en.yml b/config/locales/en.yml index e2c360b9af..f64b2381cd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,15 @@ en: spree/product: Product spree/shipping_method: Shipping Method attributes: + spree/order/ship_address: + address1: "Shipping address line 1" + address2: "Shipping address line 2" + city: "Shipping address suburb 1" + country: "Shipping address country" + phone: "Phone number" + firstname: "First name" + lastname: "Last name" + zipcode: "Shipping address postcode" spree/user: password: "Password" password_confirmation: "Password confirmation" @@ -1996,7 +2005,6 @@ en: submit: Complete order cancel: Back to Payment method errors: - global: "Saving failed, please update the highlighted fields." saving_failed: "Saving failed, please update the highlighted fields. %{messages}" terms_not_accepted: Please accept Terms and Conditions required: Field cannot be blank diff --git a/spec/controllers/split_checkout_controller_spec.rb b/spec/controllers/split_checkout_controller_spec.rb index 40c1f0b354..7f3ad6b074 100644 --- a/spec/controllers/split_checkout_controller_spec.rb +++ b/spec/controllers/split_checkout_controller_spec.rb @@ -86,7 +86,7 @@ describe SplitCheckoutController, type: :controller do put :update, params: params expect(response.status).to eq 422 - expect(flash[:error]).to eq "Saving failed, please update the highlighted fields." + expect(flash[:error]).to match "Saving failed, please update the highlighted fields." expect(order.reload.state).to eq "cart" end end @@ -161,7 +161,7 @@ describe SplitCheckoutController, type: :controller do put :update, params: params expect(response.status).to eq 422 - expect(flash[:error]).to eq "Saving failed, please update the highlighted fields." + expect(flash[:error]).to match "Saving failed, please update the highlighted fields." expect(order.reload.state).to eq "payment" end end @@ -271,7 +271,7 @@ describe SplitCheckoutController, type: :controller do put :update, params: params expect(response.status).to eq 422 - expect(flash[:error]).to eq "Saving failed, please update the highlighted fields." + expect(flash[:error]).to match "Saving failed, please update the highlighted fields." expect(order.reload.state).to eq "confirmation" end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 0f51eb7b7f..8c1adba511 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -8,6 +8,14 @@ describe Spree::Order do let(:user) { build(:user, email: "spree@example.com") } let(:order) { build(:order, user: user) } + describe "#errors" do + it "provides friendly error messages" do + order.ship_address = Spree::Address.new + order.save + expect(order.errors.full_messages).to include "Shipping address line 1 can't be blank" + end + end + context "#products" do let(:order) { create(:order_with_line_items) } diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index f77a6d6cdc..cf0e405847 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -294,7 +294,7 @@ describe "As a consumer, I want to checkout my order" do click_button "Next - Payment method" expect(page).to have_content "Saving failed, please update the highlighted fields." - expect(page).to have_content "Ship address address1 can't be blank" + expect(page).to have_content "Shipping address line 1 can't be blank" expect(page).to have_content "Shipping address same as billing address?" expect(page).to have_content "Save as default shipping address" expect(page).to have_checked_field "Shipping address same as billing address?"