From c28df097c661387e3e37d06eb56380fb59f58754 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Wed, 22 Jan 2020 10:22:42 +0100 Subject: Avoid raising unnecessary errors with incomplete address When validating addresses, it may happen that the address has no country, so trying to fetch the country ISO raises an unnecessary error. Using ruby safe navigation prevents this to happen. Of course, the address will still result invalid eventually. --- lib/super_good/solidus_taxjar/calculator_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/super_good') diff --git a/lib/super_good/solidus_taxjar/calculator_helper.rb b/lib/super_good/solidus_taxjar/calculator_helper.rb index 89dedc0..636f322 100644 --- a/lib/super_good/solidus_taxjar/calculator_helper.rb +++ b/lib/super_good/solidus_taxjar/calculator_helper.rb @@ -17,7 +17,7 @@ module SuperGood address.city, address&.state&.abbr || address.state_name, address.zipcode, - address.country.iso + address.country&.iso ].any?(&:blank?) end -- cgit v1.2.3 From ac30ff69f619bc504cd295de2f983310077b30e0 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Wed, 22 Jan 2020 10:25:58 +0100 Subject: Remove unnecessay safe navigator The safe navigator is not necessary here, as all other method calls on `address` don't have it. --- lib/super_good/solidus_taxjar/calculator_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/super_good') diff --git a/lib/super_good/solidus_taxjar/calculator_helper.rb b/lib/super_good/solidus_taxjar/calculator_helper.rb index 636f322..dbde950 100644 --- a/lib/super_good/solidus_taxjar/calculator_helper.rb +++ b/lib/super_good/solidus_taxjar/calculator_helper.rb @@ -15,7 +15,7 @@ module SuperGood [ address.address1, address.city, - address&.state&.abbr || address.state_name, + address.state&.abbr || address.state_name, address.zipcode, address.country&.iso ].any?(&:blank?) -- cgit v1.2.3