Commit Graph

1191 Commits

Author SHA1 Message Date
David Cornu 38a990237a Match HashWithIndifferentAccess#default's behaviour with Hash#default 2016-01-07 15:39:36 -05:00
Akshay Vishnoi 007bb117c1 Fix - to_s(:db) on Numeric range 2015-12-29 17:03:36 +05:30
Yves Senn 468df261f8 Merge pull request #22824 from maclover7/add-numericwithformat-tests
Add test coverage for ActiveSupport::NumericWithFormat#to_formatted_s
2015-12-29 08:42:36 +01:00
Jon Moss 66caf9ce76 Add test coverage for ActiveSupport::NumericWithFormat#to_formatted_s 2015-12-28 22:20:53 -05:00
Akshay Vishnoi 3d1f95d0e8 Add support for Petabyte and Exabyte in number to human size 2015-12-22 23:07:06 +05:30
David Heinemeier Hansson 8a40cba66a Use separate test class name 2015-12-17 15:27:29 +01:00
David Heinemeier Hansson 748b21db8f Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread 2015-12-17 14:28:19 +01:00
Genadi Samokovarov bb29fbc132 Don't leak Object constants in core_ext/module/qualified_const 2015-12-16 18:10:50 +01:00
Jon Pascoe 55b463f599 Add days_in_year method 2015-11-10 16:17:07 +00:00
Kasper Timm Hansen ccdc84c09c Merge pull request #21897 from swaathi/master
Parameterize with options to preserve the case of string
2015-11-07 21:20:57 +01:00
Eileen M. Uchitelle 24bddfc542 Merge pull request #21806 from kachick/fix-transformer-size
Return a sized Enumerator from Hash#transform_values{!}
2015-11-07 11:27:17 -05:00
Swaathi K c9143e15a1 Parameterize with options to preserve case of string
Added test cases

Using kwargs instead of three seperate functions

Updated parameterize in transliterate.rb

Updated parameterize in transliterate.rb

Added deprecation warnings and updating RDoc+Guide

Misspelled separtor. Fixed.

Deprecated test cases and added support to parameterize with keyword parameters

Squashing commits.

Fixed test cases and added deprecated test cases

Small changes to Gemfile.lock and CHANGELOG

Update Gemfile.lock
2015-11-07 16:57:04 +05:30
Rafael Mendonça França 08225104d1 ✂️ 2015-10-30 17:50:53 -02:00
Sean Griffin 35085c9540 Deprecate `HWIDA.new_from_hash_copying_default`
This method was already niche, and is now redundant with `.new`
2015-10-29 10:01:33 -06:00
Sean Griffin ddb886ef13 Merge pull request #16357 from gchan/hwia-respects-to-hash-default
`HashWithIndifferentAccess.new` respects the default value or proc on
objects that respond to `#to_hash`
2015-10-29 09:54:55 -06:00
yui-knk 7189e5554e Make `Module#redefine_method` to keep method visibility
Before this commit `Module#redefine_method` always changes
visibility of redefined method to `public`.
This commit changes behavior of Module#redefine_method` to
keep method visibility.
2015-10-26 19:40:46 +09:00
Andrew White 94ca3e0a57 Add Module#remove_possible_singleton_method
This is primarily to fix method redefinition warnings in class_attribute
but may be of use in other places where we define singleton methods.
2015-10-21 16:00:35 +01:00
Sean Griffin d94ae72a52 Merge pull request #19992 from greysteil/handle-invalid-utf8-in-html-escape
Handle invalid UTF-8 strings when HTML escaping
2015-10-20 16:50:01 -06:00
Sean Griffin 7b92798d2f Merge pull request #21302 from theunraveler/delegate_reserved_argument_names
ActiveSupport: Fixing issue when delegating to methods named "block", "args", or "arg"
2015-10-20 15:04:05 -06:00
Maarten Jacobs 86d2924a11 fixes #21815
The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM.

This commit adds:

A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because
- model couldn't be defined inline
- transactional testing needed to be turned off to get it to pass the MySQL tests
This seemed cleaner than putting it in an existing testcase file.

It adds :usec as a dateformat that calculates datetime in microseconds

It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
2015-10-16 15:09:45 +02:00
David Celis 8e847dcde8 Expand support for ActiveSupport::TimeWithZone#utc?
Currently, ActiveSupport::TimeWithZone#utc? simply runs a check to see
if the linked ActiveSupport::TimeZone's name is "UTC". This will only
return true for ActiveSupport::TimeZone["UTC"], but not for time zones
such as "Etc/UTC", "Etc/Universal", or other time zones that are aliases
for UTC. Interestingly enough, ActiveSupport::TimeWithZone#utc? is also
aliased as #gmt? but will return false for the "GMT" timezone (along
with other TZInfo aliases for GMT).

Instead of running a simple check on the TimeZone name, we can rely on
the underlying TZInfo::TimezonePeriod and TZInfo::TimezoneOffset which
keep a record of of the offset's abbreviated name. The possibilities
here for UTC time zones are `:UTC`, `:UCT`, and `:GMT`.

Signed-off-by: David <me@davidcel.is>
2015-10-15 09:25:34 -07:00
Andrew White c80b114c45 Merge pull request #20600 from mtsmfm/xmlschema-should-display-more-than-6-digits
TimeWithZone#xmlschema should be able to display more than 6 digits
2015-10-02 13:55:47 +01:00
Aliaksandr Buhayeu 3005c25a36 Regex fix for mattr_accessor validation
Change ^ and $ operators to \A and \z to prevent
code injection after the line breaks
2015-10-01 21:27:58 +03:00
Fumiaki MATSUSHIMA 602ffe2a63 TimeWithZone#xmlschema should be able to display more than 6 digits 2015-09-30 20:10:55 +09:00
Kenichi Kamiya 9addcbb00a Return a sized Enumerator from Hash#{transform_values{!}|transform_keys{!}} 2015-09-29 12:31:58 +09:00
Rafael Mendonça França 767cceefd3 Merge pull request #21767 from ronakjangir47/missing_transform_values_test
Added missing tests for transform_values! which returns Enumerator
2015-09-25 23:35:54 -03:00
Ronak Jangir 40f4f8a0c1 Added missing tests for transform_keys! which returns Enumerator without block 2015-09-26 00:31:51 +05:30
Ronak Jangir 3e97bea38a Added missing tests for transform_values! which returns Enumerator without blocks 2015-09-26 00:23:54 +05:30
Akira Matsuda 64766e82d6 🔪 Typos 2015-09-21 03:17:39 +09:00
Akira Matsuda c971bc0568 ✂️ empty line at the top of files 2015-09-21 01:27:33 +09:00
Jake Bell 47ab9a04d3 Fixing issue when delegating to methods named "block", "args", or "arg" 2015-08-19 16:04:53 -05:00
Roque Pinel d723bc315e Assert that the `:prefix` option of `number_to_human_size` is deprecated 2015-08-12 21:49:12 -04:00
Lachlan Sylvester a51dad1c52 Only invoke the default block for mattr_accessor once so that it does not cause issues if it is not idempotent 2015-08-07 20:05:02 +10:00
Roque Pinel 46b5b8ef40 Fix `TimeWithZone#eql?` to handle `TimeWithZone` created from `DateTime`
Before:

```ruby
  twz = DateTime.now.in_time_zone
  twz.eql?(twz.dup) => false
```

Now:

```ruby
  twz = DateTime.now.in_time_zone
  twz.eql?(twz.dup) => true
```

Please notice that this fix the `TimeWithZone` comparison to itself,
not to `DateTime`. Based on #3725, `DateTime` should not be equal to
`TimeWithZone`.
2015-07-19 11:17:51 -04:00
Bernard Potocki 800d5ae36c ActiveSupport::HashWithIndifferentAccess select and reject should return enumerator if called without block 2015-07-17 17:17:23 -04:00
Godfrey Chan a6b2ace016 Expand coverage of JSON gem tests 2015-07-11 12:48:21 -07:00
Godfrey Chan 2926d73e32 Add tests to ensure we don't interfere with json gem's output 2015-07-11 12:48:09 -07:00
Prem Sichanugrist 2f26f61154 Require yaml for time_with_zone isolation test
Same fix as 109e71d2bb but after
mocha got removed in 2f28e5b641.
2015-07-10 16:58:18 -04:00
Rafael Mendonça França fabcdc711b Reuse the same test for HWIA reverse_merge! 2015-07-10 13:47:09 -03:00
Rafael Mendonça França ebf8961182 Merge pull request #20828 from Sirupsen/hash-indifferent-dup-default-proc
active_support/indifferent_access: fix not raising when default_proc does
2015-07-10 13:32:59 -03:00
Simon Eskildsen 9578d574f3 test/hash: move lonely indifferent hash test 2015-07-10 15:54:37 +00:00
Simon Eskildsen fa30dd6d2e active_support/indifferent_hash: dont raise on to_hash when default_proc raises 2015-07-10 15:54:37 +00:00
Simon Eskildsen 4ff255a690 active_support/indifferent_hash: fix cloning default_proc on dup 2015-07-10 15:54:31 +00:00
Ronak Jangir 2f28e5b641 Removed use of mocha in active_support 2015-07-10 01:58:46 +05:30
Aaron Patterson 04e727dac4 Merge pull request #18365 from pocke/fix_datatime_compare
DateTime#<=> return nil when compare to the invalid String as Time.
2015-06-12 10:56:18 -07:00
Grey Baker 05a2a6a0c5 Handle invalid UTF-8 strings when HTML escaping
Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
Prevents user-entered input passed from a querystring into a form field from
causing invalid byte sequence errors.
2015-06-08 18:50:38 +01:00
Ronak Jangir 81d2ce96d0 Removed mocha stubbing in active_support 2015-06-07 19:18:58 +05:30
Rafael Mendonça França 4e63bde623 Merge pull request #20362 from kddeisz/enumerable_pluck
Allow Enumerable#pluck to take a splat.
2015-06-01 12:40:19 -03:00
Nikolay Kondratyev d98928019a Fix a range of values for parameters of the Time#change
Passing 999999000 < `:nsec` < 999999999 and 999999 < `:usec` < 1000000
to change a time with utc_offset doesn't throw an `ArgumentError`.
2015-06-01 13:25:09 +05:00
Kevin Deisz 777fa257aa Allow Enumerable#pluck to take a splat.
This allows easier integration with ActiveRecord, such that
AR#pluck will now use Enumerable#pluck if the relation is loaded,
without needing to hit the database.
2015-05-29 10:32:32 -04:00