Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #92 from ashchan/master

Let default currency config accept currency without minor unit
  • Loading branch information...
commit 45d60b374d2be23dddb84648582493e9c5c0af8c 2 parents a315524 + 9b4f8fd
@alup alup authored
Showing with 16 additions and 3 deletions.
  1. +2 −2 lib/money-rails/configuration.rb
  2. +14 −1 spec/configuration_spec.rb
View
4 lib/money-rails/configuration.rb
@@ -23,7 +23,7 @@ def configure
def default_currency
Money.default_currency
end
-
+
# Set default currency of money library
def default_currency=(currency_name)
Money.default_currency = Money::Currency.new(currency_name)
@@ -37,7 +37,7 @@ def register_currency=(currency_options)
end
def set_amount_column_for_default_currency!
- amount_column.merge! postfix: "_#{default_currency.subunit.downcase.pluralize}"
+ amount_column.merge! postfix: "_#{default_currency.subunit.downcase.pluralize}" if default_currency.subunit
end
def set_currency_column_for_default_currency!
View
15 spec/configuration_spec.rb
@@ -65,6 +65,19 @@
# Reset global setting
MoneyRails.default_currency = old_currency
end
-
+
+ it "accepts default currency which doesn't have minor unit" do
+ old_currency = MoneyRails.default_currency
+
+ expect {
+ MoneyRails.default_currency = :jpy
+ }.to_not raise_error
+
+ MoneyRails.amount_column[:postfix].should == "_cents"
+
+ # Reset global setting
+ MoneyRails.default_currency = old_currency
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.