Skip to content

Commit

Permalink
Add empty? check method
Browse files Browse the repository at this point in the history
Solidus has deprecated the `empty?` method on
solidusio/solidus#1686 . This adds a private
`empty?` method for avoid future problems and remove the deprecation
warning in projects that uses this gem.
  • Loading branch information
JuanCrg90 committed Mar 12, 2019
1 parent 9a83ec4 commit f2df1e9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/super_good/solidus_taxjar/tax_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(order, api: self.class.default_api)

def calculate
return no_tax if SuperGood::SolidusTaxJar.test_mode
return no_tax if order.tax_address.empty? || order.line_items.none?
return no_tax if empty?(order.tax_address) || order.line_items.none?
return no_tax unless taxable_address? order.tax_address

cache do
Expand Down Expand Up @@ -150,6 +150,12 @@ def shipping_tax_label(shipment, shipping_tax)
def line_item_tax_label(taxjar_line_item, spree_line_item)
SuperGood::SolidusTaxJar.line_item_tax_label_maker.(taxjar_line_item, spree_line_item)
end

def empty?(tax_address)
tax_address
.attributes
.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, v| v.nil? }
end
end
end
end

0 comments on commit f2df1e9

Please sign in to comment.