Commit Graph

2226 Commits

Author SHA1 Message Date
John Paul Ashenfelter d75992b0b2 `DateTime#to_f` now preserves fractional seconds.
Previously this method always returns `.0` in the fractional part. This commit
changes it to preserve the fractional seconds instead.

Fixes #15994.
2014-07-02 15:01:35 -07:00
Sean Griffin b2cf8b251a Add `Hash#map_values` to ActiveSupport
Didn't get a chance to convert existing code, I'll skim through the code
base to make use of this later this afternoon.
2014-06-29 13:31:43 -06:00
Robin Dupret 643409dcb0 Make the apply_inflections method case-sensitive
Since d3071db1, the apply_inflections method check if the downcased
version of a string is contained inside the "whitelist" of uncountable
words. However, if the word is composed of capital letters, it won't be
matched in the list while it should.

We can't simply revert to the previous behavior as there is a
performance concern (benchmarked over /usr/share/dict/words):

Before d3071db1  135.610000   0.290000  135.900000 (137.807081)
Since d3071db1   22.170000    0.020000  22.190000  ( 22.530005)
With the patch   22.060000    0.020000  22.080000  ( 22.125771)

Benchmarked with http://git.io/aFnWig

This way, the solution is to put the down-case version of words inside
the @uncountables array.
2014-06-26 14:03:56 +02:00
Yuki Nishijima 98f0cab396 Fix a bug where NameError#name returns a qualified name in string
Ruby's original behaviour is that :

  * It only returns a const name, not a qualified aname
  * It returns a symbol, not a string
2014-06-24 10:13:17 -07:00
Zuhao Wan 023d14ecbb Create with_env helper for tests. 2014-06-22 20:31:34 +08:00
Yves Senn e32dade866 Merge pull request #15856 from zuhao/refactor_activesupport_decoding_test
Use with_parse_json_times helper in tests.
2014-06-22 13:47:25 +02:00
Zuhao Wan 42b33590f3 Avoid hardcoded magic number in test teardown. 2014-06-22 18:36:07 +08:00
Zuhao Wan 17ad556a3f Use with_parse_json_times helper in tests. 2014-06-22 18:30:44 +08:00
Arthur Neves bd3fde0931
Add regression test for NameError#name 2014-06-20 09:55:41 -04:00
Yves Senn 911b282cf0 Merge pull request #15799 from zuhao/refactor_activesupport_time_zone_test_helpers
Extract out with_env_tz helper method.
2014-06-18 13:59:57 +02:00
Zuhao Wan 9c492885d1 Extract out with_env_tz helper method.
It’s used at so many places that extracting it out into a helper file
is worth doing.
2014-06-18 19:46:04 +08:00
Zuhao Wan 0c2fbc5095 Move test teardown into `ensure` block. 2014-06-17 20:57:02 +08:00
Rafael Mendonça França d8569bd498 Merge pull request #15684 from aditya-kapoor/add-tests-for-assert-valid-keys
Add test cases for Hash#asset_valid_keys
2014-06-16 13:27:59 -03:00
Kuldeep Aggarwal 880721434c remove unnecessary calling of `I18n.backend.store_translations(empty, {})`
Clean up I18n stored translations after test
continuation with #15714
2014-06-15 08:53:58 +05:30
Aditya Kapoor fedb16ae12 Add test cases for Hash#asset_valid_keys 2014-06-14 14:13:06 +05:30
Akshay Vishnoi bb5c1321d6 Add missing test cases for #assert_no_difference 2014-06-13 06:52:58 +05:30
Akshay Vishnoi 5505131cc1 Move test for blank.rb under object 2014-06-11 22:53:05 +05:30
Yves Senn 47baab0c41 Merge pull request #15628 from akshay-vishnoi/test-cases
Add test cases for #in? and #presence_in
2014-06-11 17:25:36 +02:00
Akshay Vishnoi f648195247 Add test cases for #in? and #presence_in 2014-06-11 06:50:18 +05:30
Adam Panzer 9010274627 fix error with long keys in ActiveSupport::Cache::FileStore 2014-06-10 10:53:48 -07:00
Rafael Mendonça França 3fe33a318f Fix bug that make HashWithIndifferentAccess work differently of Hash
Before HashWithIndifferentAccess were doing deep_dup of the inner hashes
when Hash doesn't do. Now both are behaving in the same way.
2014-06-09 18:30:05 -03:00
Aditya Kapoor 885ebda266 Add Missing Test Cases for the constantize 2014-06-07 23:58:38 +05:30
Matthew Draper b2d070ddf6 Merge pull request #15421 from gchan/time_with_zone_precision
Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
2014-06-05 16:23:47 +09:30
Rafael Mendonça França d516971155 Merge pull request #15447 from akshay-vishnoi/test-cases
Test `except!` in other cases too
2014-06-03 18:38:00 -03:00
Juanjo Bazán 60062cf39a Fix AS::NumberHelper results with rationals
:precision was incorrectly being applied to Rationals

before:
  ActiveSupport::NumberHelper.number_to_rounded Rational(10, 3), precision: 2
  => "3.3"
after:
  ActiveSupport::NumberHelper.number_to_rounded Rational(10, 3), precision: 2
  => "3.33"
2014-05-31 20:07:47 +02:00
Akshay Vishnoi 6976c7254d Test `except!` in other cases too 2014-05-31 22:40:00 +05:30
Godfrey Chan f1eddea1e3 ✂️ removed deprecated `Numeric#ago` and friends
Replacements:

   5.ago   => 5.seconds.ago
   5.until => 5.seconds.until
   5.since => 5.seconds.since
   5.from_now => 5.seconds.from_now

The removed tests does not affect coverage – we have equivalent test cases in
the tests for `AS::Duration`.

See #12389 for the history and rationale behind this.
2014-05-30 02:47:56 -07:00
Gordon Chan c69baffdf7 Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
When working with objects with a nanosecond component, the `-` method may
unnecessarily cause loss of precision.

`ActiveSupport::TimeWithZone#-` should return the same result as if we were
using `Time#-`:

    Time.now.end_of_day - Time.now.beginning_of_day #=> 86399.999999999

Before:

    Time.zone.now.end_of_day.nsec #=> 999999999
    Time.zone.now.end_of_day - Time.zone.now.beginning_of_day #=> 86400.0

After:

    Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
    #=> 86399.999999999
2014-05-30 20:41:39 +12:00
Matthew Draper 086ee1cc13 Merge pull request #12080 from ShayDavidson/fix_datetime_partial_dates
Added partial days support to `DateTime`'s `advance` method.
2014-05-28 03:32:21 +09:30
Yves Senn 42fe948917 Merge pull request #15316 from akshay-vishnoi/test-cases
Fix test cases for inflector.rb
2014-05-26 08:56:26 +02:00
Akshay Vishnoi 93c193ed82 Fix test cases for inflector.rb
`yield` was missing in #with_dup, due to which 57 assertions were not running
in real, and all tests were passing by default.
Error was introduced in commit - 31ceb5e.
2014-05-25 21:36:02 +05:30
Rafael Mendonça França a312770118 Merge pull request #15276 from kuldeepaggarwal/fix-array-to
Array#to now accept negative position also.
2014-05-23 15:05:28 -03:00
Rafael Mendonça França fbdcba86cf Merge pull request #15275 from kuldeepaggarwal/add-test
add test cases for negative position in Array#from
2014-05-23 14:59:55 -03:00
Kuldeep Aggarwal 0e9401733c revert 96525d63
`Array#to` is working for negative position
2014-05-23 21:32:52 +05:30
Kuldeep Aggarwal 3920d64479 add test cases for negative position in Array#from 2014-05-23 20:47:21 +05:30
Rafael Mendonça França 2fdddcee6f Remove warning remeving the method before redefining
We need to test if the same method defined more than once only register
one subscriber for it. We can safelly remove because the method body is
the same and Subscriber use method_added hook for register the
subscriber.
2014-05-23 11:45:28 -03:00
Rafael Mendonça França decd719711 Merge pull request #10887 from sakuro/deep_transform_keys_in_nested_arrays
Hash#deep_*_keys(!) recurse into nested arrays.

Conflicts:
	activesupport/CHANGELOG.md
2014-05-20 21:49:58 -03:00
Vladimir Yarotsky 6cc5a86a54 Fix confusing exception in ActiveSupport delegation 2014-05-20 08:10:40 -07:00
Rafael Mendonça França fd119467b6 Merge pull request #15037 from roccoblues/fix_duplicate_activesupport_subscribers
Fixed duplicate subscribers in ActiveSupport::Subscriber

Conflicts:
	activesupport/CHANGELOG.md
2014-05-16 21:13:34 -03:00
Rafael Mendonça França 2b84eea9c0 Merge pull request #15072 from mjtko/fix/issue-15064
[Fixes #15064] Calling number_to_delimited on a ActiveSupport::SafeBuffer results in mangled output
2014-05-13 16:11:40 -03:00
wendi 70710c9764 Update require in `array_ext_test.rb`
Removed `FIMXE` tag to require necessary file but not the whole core_ext
2014-05-13 02:11:49 +08:00
wendi 9eadf528e9 Update and add tests in array_ext_test.rb
- Fix `test_to_with_instruct` typo to `test_to_xml_with_instruct`

- Rename `test_to_xml` to `test_to_xml_with_hash_elements` to make test
name more specific.

- Add `test_to_xml_with_non_hash_elements` and
`test_to_xml_with_non_hash_different_type_elements`

  `to_xml` behaves different when containing elements are same and
  different types.

- Add `test_to_xml_with_indent_set`
2014-05-13 00:54:58 +08:00
Mark J. Titorenko 3703a8ae9b Require active_support/core_ext/string/output_safety and use html_safe rather than use non-public SafeBuffer API. 2014-05-12 17:23:28 +01:00
Mark J. Titorenko 9c8242ee6a Use block parameter rather than `$1` during `gsub!` so `ActiveSupport::SafeBuffer` values aren't mangled.
Fixes #15064
2014-05-12 17:13:19 +01:00
Andrew White 7dce1e6d98 Tidy up implementation of #15010 2014-05-11 16:00:55 +01:00
Ulysse Carion 0e909cd307 Make TimeZone#parse behave more like Time#parse.
Namely, if the mday is omitted but any other upper components are, then instead
of supplying the mday from the current time, it defaults to 1.
2014-05-11 15:04:49 +01:00
Dennis Schoen b50468d13d Fixed duplicate subscribers in ActiveSupport::Subscriber
ActiveSupport::Subscriber no longer creates multiple subscribers when
you redefine a method.
2014-05-09 11:16:18 +02:00
Rafael Mendonça França 6b2f37741c Merge pull request #12746 from coreyward/master
Fix Hash#deep_merge bug and improve documentation — resolves #12738
2014-05-07 18:03:03 -03:00
Xavier Noria daaa21bc7d several enhancements to humanize [closes #12288]
* Strips leading underscores.
* Changes some unnecessary gsub!s to sub!s.
* Replaces some anchors ^, $ with \A, \z.
* Documents that human inflection rules are applied.
* Documents that words are downcased except acronyms.
* Adds an example with an acronym.
* Rewords docs.
2014-05-06 21:35:40 +02:00
Rafael Mendonça França b4b0d9d1c1 Merge pull request #14949 from bogdan/empty-hash-array-parameterization
[Fixes #14948] Hash#to_query: right serialization for  empty hash and array
2014-05-04 18:29:31 -03:00