rents 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rents/currency.rb +1 -0
- data/lib/rents/version.rb +1 -1
- data/spec/rents/currency_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8d72ef9093b027a4437f1a2cd499e82fa5d1093
|
4
|
+
data.tar.gz: d244eeb77446e3cb30b433af713bf4f031061351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712dc85f830cf3526d0f4f87f6256f839654ffe5988e4545c57a78745b061e570d7a2bd4aebdb98455370e3a21109d536eb838593911d74a29c7666995999f5c
|
7
|
+
data.tar.gz: fd47a2cae1ea33d90ccb3db781d120756edbefb8d5a25456017c301cf4f2f5811093f2d120c14d3b8c67df66496544dafb618f3c8e4170d8aa10c076dcc437f3
|
data/lib/rents/currency.rb
CHANGED
@@ -6,6 +6,7 @@ module Rents
|
|
6
6
|
# Check invalid entry
|
7
7
|
return nil if amount.nil?
|
8
8
|
return amount.to_s if amount.is_a?Integer
|
9
|
+
return amount if amount.is_a?(String) && amount.index('.').nil? && amount.index(',').nil?
|
9
10
|
amount = format('%.2f', amount) if amount.to_s.float?
|
10
11
|
|
11
12
|
if amount.is_a?String
|
data/lib/rents/version.rb
CHANGED
data/spec/rents/currency_spec.rb
CHANGED
@@ -19,6 +19,7 @@ describe Rents::Currency do
|
|
19
19
|
decimal_expected_value = BigDecimal.new '1999.00'
|
20
20
|
expected_float_unit_cents = '100005'
|
21
21
|
expected_float_decimal_cents = '100050'
|
22
|
+
expected_float_without_cents = '100000'
|
22
23
|
|
23
24
|
# Float values
|
24
25
|
float_with_cents = 1000.55
|
@@ -39,6 +40,7 @@ describe Rents::Currency do
|
|
39
40
|
non_formatted_with_cents_converted = Rents::Currency.to_operator_str non_formatted_with_cents
|
40
41
|
float_unit_cents_conv = Rents::Currency.to_operator_str float_unit_cents
|
41
42
|
float_decimal_cents_conv = Rents::Currency.to_operator_str float_decimal_cents
|
43
|
+
float_without_cents_conv = Rents::Currency.to_operator_str float_without_cents
|
42
44
|
|
43
45
|
context 'Decimal to Operator' do
|
44
46
|
# Convert PT_BR
|
@@ -87,6 +89,10 @@ describe Rents::Currency do
|
|
87
89
|
it 'decimal cents con must be on Operator format' do
|
88
90
|
expect(float_decimal_cents_conv).to be == expected_float_decimal_cents
|
89
91
|
end
|
92
|
+
|
93
|
+
it 'no cents must be an Operator format' do
|
94
|
+
expect(float_without_cents_conv).to be == expected_float_without_cents
|
95
|
+
end
|
90
96
|
end
|
91
97
|
|
92
98
|
context 'Operator to Decimal' do
|