Skip to content

Commit

Permalink
Translate country name in Spree::Price#display_country
Browse files Browse the repository at this point in the history
It was not translated
  • Loading branch information
tvdeyen committed Aug 16, 2022
1 parent 111e585 commit 6d60b77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions core/spec/models/spree/price_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 6d60b77

Please sign in to comment.