From 6d60b77cc85f36bbce2cbe45aca5dfa04caa118d Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 16 Aug 2022 12:24:28 +0200 Subject: [PATCH] Translate country name in Spree::Price#display_country It was not translated --- core/app/models/spree/price.rb | 2 +- core/spec/models/spree/price_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/app/models/spree/price.rb b/core/app/models/spree/price.rb index 59cf304d51f..388f1a105ae 100644 --- a/core/app/models/spree/price.rb +++ b/core/app/models/spree/price.rb @@ -55,7 +55,7 @@ def for_any_country? def display_country if country_iso - "#{country_iso} (#{country.name})" + "#{country_iso} (#{I18n.t(country_iso, scope: [:spree, :country_names])})" else I18n.t(:any_country, scope: [:spree, :admin, :prices]) end diff --git a/core/spec/models/spree/price_spec.rb b/core/spec/models/spree/price_spec.rb index 9910ee175fb..9de134db53b 100644 --- a/core/spec/models/spree/price_spec.rb +++ b/core/spec/models/spree/price_spec.rb @@ -149,6 +149,24 @@ end end + describe "#display_country" do + subject { price.display_country } + + context "when country_iso nil" do + let(:price) { build_stubbed(:price, country_iso: nil) } + + it { is_expected.to eq "Any Country" } + end + + context "when country_iso is set" do + let(:price) { build_stubbed(:price, country_iso: "DE") } + + it "shows country iso and translated country name" do + is_expected.to eq "DE (Germany)" + end + end + end + describe 'scopes' do describe '.for_any_country' do let(:country) { create(:country) }