Navigation Menu

Skip to content
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.

Commit

Permalink
Fix Package#cents_from incorrectly converting from an inprecise Float…
Browse files Browse the repository at this point in the history
… to Integer
  • Loading branch information
Denis Odorcic committed Sep 12, 2011
1 parent c4d6a41 commit d017ff6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/active_shipping/shipping/package.rb
Expand Up @@ -98,9 +98,9 @@ def self.cents_from(money)
else
case money
when Float
(money * 100).to_i
(money * 100).round
when String
money =~ /\./ ? (money.to_f * 100).to_i : money.to_i
money =~ /\./ ? (money.to_f * 100).round : money.to_i
else
money.to_i
end
Expand Down Expand Up @@ -144,4 +144,4 @@ def process_dimensions

end
end
end
end
4 changes: 2 additions & 2 deletions test/unit/carriers/kunaki_test.rb
Expand Up @@ -48,6 +48,6 @@ def test_successfully_get_rates
assert_equal "USPS", rate.carrier
assert_equal 800, rate.total_price
assert_equal ["UPS 2nd Day Air", "UPS Ground", "UPS Next Day Air Saver", "USPS Priority Mail"], response.rates.collect(&:service_name).sort
assert_equal [800, 1234, 2186, 3604], response.rates.collect(&:total_price).sort
assert_equal [800, 1234, 2186, 3605], response.rates.collect(&:total_price).sort
end
end
end

0 comments on commit d017ff6

Please sign in to comment.