From dc40bc988347192c1a093eedec095df1a7fd1c7d Mon Sep 17 00:00:00 2001 From: Edwin Cruz Date: Wed, 17 Jan 2018 11:27:43 -0600 Subject: [PATCH] Using find_or_build_default_price when getting variants price in its edit form --- backend/app/views/spree/admin/variants/_form.html.erb | 2 +- core/spec/models/spree/variant/pricing_options_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/views/spree/admin/variants/_form.html.erb b/backend/app/views/spree/admin/variants/_form.html.erb index 1856ff33186..e09fbaff561 100644 --- a/backend/app/views/spree/admin/variants/_form.html.erb +++ b/backend/app/views/spree/admin/variants/_form.html.erb @@ -65,7 +65,7 @@
<%= f.label :price %> - <%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :price, currency: @variant.default_price.currency %> + <%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :price, currency: @variant.find_or_build_default_price.currency %>
diff --git a/core/spec/models/spree/variant/pricing_options_spec.rb b/core/spec/models/spree/variant/pricing_options_spec.rb index 0cbcd6861eb..5093921fcd9 100644 --- a/core/spec/models/spree/variant/pricing_options_spec.rb +++ b/core/spec/models/spree/variant/pricing_options_spec.rb @@ -75,7 +75,7 @@ subject { described_class.from_context(view_context) } context "if the store has not defined default_currency" do - let(:store) { FactoryBot.create :store, default_currency: nil , cart_tax_country_iso: nil } + let(:store) { FactoryBot.create :store, default_currency: nil, cart_tax_country_iso: nil } it "fallbacks to Spree::Config.currency" do expect(Spree::Variant::PricingOptions).to receive(:new).with(currency: Spree::Config.currency, country_iso: nil)