diff options
author | Vipul A M <vipulnsward@gmail.com> | 2014-11-04 12:52:41 +0530 |
---|---|---|
committer | Vipul A M <vipulnsward@gmail.com> | 2015-08-28 11:34:17 +0530 |
commit | 7f23c5d52438f12d7af167a399a77025b1d58a9c (patch) | |
tree | e02e8752146e89548cf31cede51fa5eb474655c2 /actionview | |
parent | 2a6071a5e81cbc3b83625f5e6d5aff61c69f1720 (diff) | |
download | rails-7f23c5d52438f12d7af167a399a77025b1d58a9c.tar.gz rails-7f23c5d52438f12d7af167a399a77025b1d58a9c.tar.bz2 rails-7f23c5d52438f12d7af167a399a77025b1d58a9c.zip |
- Extracted `DELIMITED_REGEX` to `delimited_regex` method and made use of user passed `options[:delimited_regex]` if available. Changed `DELIMITED_REGEX` to `DEFAULT)DELIMITED_REGEX` to signify what it means.
- Added tests for number to delimited and number to currency in both actionview and activesupport.
Changes
Changes
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/CHANGELOG.md | 10 | ||||
-rw-r--r-- | actionview/test/template/number_helper_test.rb | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 90c9c2171c..f97ca88b87 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,13 @@ +* `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option + to handle placement of delimiter, to support currency formats like INR + + Example: + + number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n") + # => '₹ 12,30,000.00' + + *Vipul A M* + * Make `disable_with` the default behavior for submit tags. Disables the button on submit to prevent double submits. diff --git a/actionview/test/template/number_helper_test.rb b/actionview/test/template/number_helper_test.rb index b70b750869..631d45586b 100644 --- a/actionview/test/template/number_helper_test.rb +++ b/actionview/test/template/number_helper_test.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "abstract_unit" class NumberHelperTest < ActionView::TestCase @@ -21,6 +22,7 @@ class NumberHelperTest < ActionView::TestCase assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("1234567890.50", format: "<b>%n</b> %u") assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("-1234567890.50", negative_format: "<b>%n</b> %u") assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("-1234567890.50", 'negative_format' => "<b>%n</b> %u") + assert_equal '₹ 12,30,000.00', number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n") end def test_number_to_percentage |