shopify-money 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/money/helpers.rb +1 -0
- data/lib/money/money.rb +6 -3
- data/lib/money/version.rb +1 -1
- data/spec/money_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68cd70a11908e256c3743d9cd5c66ad2d3fb93eac02fd7973a5e8c20c6ca3e6b
|
4
|
+
data.tar.gz: c5619ce2dc46b6271ae96c326c57b8d4fc7dfef9f3696db1f140c83b5df0f5bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 116fc4ca873f7373653509bc104d8343160877c3085ac2446dacbb918ecf2e823a915b9f2bb97ab48d7a39c4f2515518fa64ffece7a2c501b4a3958ea5455457
|
7
|
+
data.tar.gz: 3b702aa16acd05f2100589ac319931c268999e616ce28e741c921539000c39b48521807c6a81d1a0aaaf70c2f436a02a4f236109104db00bd4cdb5b9c8e9c01e
|
data/lib/money/helpers.rb
CHANGED
data/lib/money/money.rb
CHANGED
@@ -232,9 +232,12 @@ class Money
|
|
232
232
|
if units == 0
|
233
233
|
sprintf("%d", rounded_value)
|
234
234
|
else
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
formatted = rounded_value.to_s("F")
|
236
|
+
decimal_digits = formatted.size - formatted.index(".") - 1
|
237
|
+
(units - decimal_digits).times do
|
238
|
+
formatted << '0'
|
239
|
+
end
|
240
|
+
formatted
|
238
241
|
end
|
239
242
|
end
|
240
243
|
alias_method :to_s, :to_fs
|
data/lib/money/version.rb
CHANGED
data/spec/money_spec.rb
CHANGED
@@ -376,6 +376,10 @@ RSpec.describe "Money" do
|
|
376
376
|
expect(Money.from_subunits(100, 'ISK', format: :stripe)).to eq(Money.new(1, 'ISK'))
|
377
377
|
end
|
378
378
|
|
379
|
+
it 'overrides the subunit_to_unit amount for UGX' do
|
380
|
+
expect(Money.from_subunits(100, 'UGX', format: :stripe)).to eq(Money.new(1, 'UGX'))
|
381
|
+
end
|
382
|
+
|
379
383
|
it 'fallbacks to the default subunit_to_unit amount if no override is specified' do
|
380
384
|
expect(Money.from_subunits(100, 'USD', format: :stripe)).to eq(Money.new(1, 'USD'))
|
381
385
|
end
|
@@ -622,6 +626,10 @@ RSpec.describe "Money" do
|
|
622
626
|
expect(Money.new(1, 'ISK').subunits(format: :stripe)).to eq(100)
|
623
627
|
end
|
624
628
|
|
629
|
+
it 'overrides the subunit_to_unit amount for UGX' do
|
630
|
+
expect(Money.new(1, 'UGX').subunits(format: :stripe)).to eq(100)
|
631
|
+
end
|
632
|
+
|
625
633
|
it 'fallbacks to the default subunit_to_unit amount if no override is specified' do
|
626
634
|
expect(Money.new(1, 'USD').subunits(format: :stripe)).to eq(100)
|
627
635
|
end
|