Skip to content

Commit

Permalink
Normalize locale string to expected format (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav (Stas) Katkov committed Jul 5, 2020
1 parent 3bc2101 commit 79f5403
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.3.1]
## Add
- Normalize locale to expected format

## [1.3.0]
## Add
- Code-style now adheres to standard gem
Expand Down
4 changes: 2 additions & 2 deletions lib/carriage/builder.rb
Expand Up @@ -19,8 +19,8 @@ def call(items, tag: nil, key_id: nil, locale: :us)

params[:AssociateTag] = tag unless tag.nil? || tag.empty?
params[:AWSAccessKeyId] = key_id unless key_id.nil? || key_id.empty?

Carriage.call(locale, params)
Carriage.call(locale.downcase.to_sym, params)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/carriage/version.rb
@@ -1,3 +1,3 @@
module Carriage
VERSION = "1.3.0"
VERSION = "1.3.1"
end
8 changes: 8 additions & 0 deletions test/carriage_test.rb
Expand Up @@ -67,6 +67,14 @@ def test_available_locales
assert Carriage.build(items, tag: TAG, locale: :in).start_with?("https://www.amazon.in")
end

def test_normalize_locales
items = [{asin: "B00WR23X5I", quantity: 1}]

assert Carriage.build(items, tag: TAG, locale: 'UK').start_with?("https://www.amazon.co.uk")
assert Carriage.build(items, tag: TAG, locale: :IN).start_with?("https://www.amazon.in")

end

def test_verify_locale
assert_raises(Carriage::Locale::NotFound) do
Carriage.call(:oo, {"ASIN.1": "B00WR23X5I", "Quantity.1": 1})
Expand Down

0 comments on commit 79f5403

Please sign in to comment.