Commit Graph

320 Commits

Author SHA1 Message Date
Adam Panzer
9010274627 fix error with long keys in ActiveSupport::Cache::FileStore 2014-06-10 10:53:48 -07:00
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
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
Robin Dupret
b1867187d4 Tiny formatting fix in AS change log [ci skip] 2014-05-31 19:08:49 +02:00
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
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
Yves Senn
8109dc8067 formatting pass through CHANGELOGS. [ci skip] 2014-05-16 09:03:26 +02:00
eileencodes
b342d2baef remove deprecation warning
This deprecation was released in 4.1.0 and can be removed for 4.2.0,
deprecation message / handling is no longer necessary.
2014-05-13 19:51:57 -04: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
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
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
d65ab433ae Improve CHANGELOG [ci skip] 2014-05-04 18:35:04 -03:00
Bogdan Gusiev
41bbac6ff4 [Fixes #14948] Hash#to_query: Changed a way how empty hash and empty array are serialized
Empty Hash or Array should not present in serialization result

    {a: []}.to_query # => ""
    {a: {}}.to_query # => ""

For more info see #14948.
2014-05-03 07:40:50 +03:00
Rafael Mendonça França
085ce4f141 Merge branch 'master' into rm-uuid-fixtures
Conflicts:
	activerecord/CHANGELOG.md
	activesupport/CHANGELOG.md
2014-04-10 15:34:55 -03:00
Emily Dobervich
5aeb3cd3ac Fixed problem where 1.day.eql?(1.day) is false
This fixes:
    1.second.eql?(1.second) #=> false

The new `eql?` requires that `other` is an `ActiveSupport::Duration`.
This requirement makes `ActiveSupport::Duration`'s behavior consistent
with other numeric types in Ruby.

    1.eql?(1.0) #=> false
    1.0.eql?(1) #=> false

    1.second.eql?(1) #=> false (was true)
    1.eql?(1.second) #=> false

    { 1 => "foo", 1.0 => "bar" }
    #=> { 1 => "foo", 1.0 => "bar" }

    { 1 => "foo", 1.second => "bar" }
    # now => { 1 => "foo", 1.second => "bar" }
    # was => { 1 => "bar" }

And though the behavior here hasn't changed, for reference:

    1 == 1.0 #=> true
    1.0 == 1 #=> true

    1 == 1.second #=> true
    1.second == 1 #=> true
2014-04-08 16:24:35 -07:00
Rafael Mendonça França
54d8c81fef Merge pull request #12016 from roderickvd/uuid_fixes
Auto-generate stable fixture UUIDs on PostgreSQL

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/fixtures.rb
	activerecord/test/cases/adapters/postgresql/uuid_test.rb
	activesupport/CHANGELOG.md
2014-04-04 12:52:49 -03:00
Pavel Pravosud
6df507e884 Make AS::SafeBuffer#prepend act like String#prepend
Make `#prepend` method modify instance in-place and return self
instead of just returning modified value. That is exactly what
`#prepend!` method was doing previously, so it's deprecated from
now on.
2014-03-31 22:33:53 -04:00
Peter Jaros
03f35a27dc HashWithIndifferentAccess better respects #to_hash
In particular, `.new`, `#update`, `#merge`, `#replace` all accept
objects which respond to `#to_hash`, even if those objects are not
Hashes directly.
2014-03-28 10:25:06 -04:00
Akshay Vishnoi
41548df342 Deprecate Class#superclass_delegating_accessor 2014-03-20 18:29:09 +05:30
Sammy Larbi
d75eeadf74 Fix #to_json for BasicObject Enumerables 2014-03-14 16:55:34 -05:00
Godfrey Chan
ccf8f27ddd Revert "Merge pull request #14269 from arthurnn/expanded_key_array"
This reverts commit 475c96589ca65282e1a61350271c2f83f0d4044f, reversing
changes made to 705915ab5cf24430892107764b0050c07e1df583.

We decided that this is not worth busting everyone's cache as this
seems like a very unlikely problem. The problem only occurs when the
user is 1) not using a namespace, or 2) using the same namesapce for
different *kinds* of cache items. The recommended "fix" is to put
those cache items into their own namspace:

    id = 1
    Rails.cache.fetch(id, namespace: "user"){ User.find(id) }

    ids = [1]
    Rails.cache.fetch(ids, namespace: "users"){ User.find(ids) }

See the discussion on #14269 for details.
2014-03-04 17:58:58 -08:00
Arthur Neves
7d98247446
Cache key should be different when is Array.
`cache.fetch(['foo'])` and `cache.fetch('foo')` should generate
different cache keys as they are not equivalents.

[related #8615]
[related #8614]
2014-03-03 21:00:15 -05:00
Parker Selbert
c046e60965 Return a hash rather than array from fetch_multi
The current implementation of `fetch_multi` returns an array and has no
means to easily backtrack which names yielded which results. By changing
the return value to a Hash we retain the name information. Hash#values
can be used on the response if only the values are needed.
2014-02-26 20:31:46 -06:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
David Heinemeier Hansson
d61baee52a Go with #presence_in instead of #present_in -- it doesnt sound quite as good, but the closer relationship to #presence over #present is ultimately worth it 2014-02-24 14:17:47 +01:00
Jeremy Kemper
b16c36e688 Introduce Concern#class_methods and Kernel#concern 2014-02-23 12:06:23 -07:00
Carlos Antonio da Silva
68345d4a1a Move changelog entry to the top, fix examples indent [ci skip] 2014-02-18 12:53:01 -03:00
David Heinemeier Hansson
4edca106da Added Object#present_in to simplify value whitelisting 2014-02-18 16:35:07 +01:00
Xavier Noria
65a7c57105 time helpers honor the application time zone when passed a date
Rails applications are expected to be always aware of the application
time zone.

To be consistent with that contract, we have to assume that a bare
date passed to time helpers is a date in the application time zone,
not in the system time zone. The system time zone is irrelevant, we
should totally ignore it.

For example,

    travel_to user.birth_date + 40.years

should make that user be 40th years old regardless of the system
time zone. Without this patch that may not be true.
2014-02-18 09:42:06 +01:00
Justin Coyne
ae28e4beb3 Fix tidy_bytes for JRuby
The previous implementation was broken because JRuby (1.7.10) doesn't
have a code converter for UTF-8 to UTF8-MAC.
2014-02-10 08:10:44 -06:00
Yves Senn
580f0b61dc synchronize 4.1 release notes with CHANGELOGS. [ci skip]
/cc @chancancode
2014-02-06 11:43:16 +01:00
Rafael Mendonça França
7aa4b7dc6b Add CHANGELOG entry
Closes #13909
2014-02-05 23:55:50 -02:00
Rafael Mendonça França
a60ccadbf0 Merge pull request #13911 from davidcelis/remove-bigdecimal-serialization
Deprecate custom BigDecimal serialization

Conflicts:
	activesupport/CHANGELOG.md
2014-02-01 18:03:21 -02:00
David Celis
85d820b169 Don't require BigDecimal serialization extension
Rails currently provides an extension to BigDecimal that redefines how
it is serialized to YAML. However, as noted in #12467, this does not
work as expected. When ActiveSupport is required, BigDecimal YAML
serialization does not maintain the object type. It instead ends up
serializing the number represented by the BigDecimal itself which, when
loaded by YAML later, becomes a Float:

```ruby
require 'yaml'
require 'bigdecimal'

yaml = BigDecimal('13.37').to_yaml
YAML.load(yaml).class

require 'active_support/all'

yaml = BigDecimal('13.37').to_yaml
YAML.load(yaml).class
```

@tenderlove posits that we should deprecate the custom BigDecimal
serialization and let Ruby handle it. For the time being, users who
require this serialization for backwards compatibility can manually
`require 'active_support/core_ext/big_decimal/yaml_conversions'`.

This will close #12467 and deprecate the custom BigDecimal#to_yaml.

Signed-off-by: David Celis <me@davidcel.is>
2014-02-01 10:45:51 -08:00
Rafael Mendonça França
82701cd61e Merge pull request #12769 from birkirb/master
Boolean parser blows up on a Fixnum.

Conflicts:
	activesupport/CHANGELOG.md
2014-02-01 14:49:32 -02:00
Andrew White
63f8fabe49 Maintain the current timezone in wrap_with_time_zone
Extend the solution from the fix for #12163 to the general case where
`Time` methods are wrapped with a time zone.

Fixes #12596.
2014-01-31 17:13:12 +00:00
Rafael Mendonça França
7abb6e00c0 Remove automatic removal of Date/Time stubs after each test case
This behavior is only work out-of-box with minitest and also add a
downside to run after each test case, even if we don't used the travel
or travel_to methods
2014-01-30 10:17:48 -02:00
Rafael Mendonça França
6b16c27881 Add travel_back to remove stubs from travel and travel_to 2014-01-30 10:17:47 -02:00
Yves Senn
02f9f33142 tidy CHANGELOGs [ci skip] 2014-01-30 11:12:46 +01:00
Kassio Borges
42566626e9 Fix documentation of new controller filters api [ci skip]
The api for filters with classes change and the guides weren't updated.
Now the class must respond for methods with the same name as the filter,
so the `before_action` calls a `before` method, and so on.

The method `#filter` has been deprecated in 4.0.0 and has been removed
in 4.1.0: #7560
2014-01-29 18:47:08 -02:00
Andrew White
9484f4b821 Add CHANGELOG entry for #11464 2014-01-26 21:25:54 +00:00
Andrew White
b594492870 Maintain current timezone when changing time during DST overlap
Currently if a time is changed during DST overlap in the autumn then the
method `period_for_local` will return the DST period. However if the
original time is not DST then this can be surprising and is not what is
generally wanted. This commit changes that behavior to maintain the current
period if it's in the list of periods returned by `periods_for_local`.

It is possible to alter the behavior of `period_for_local` by specifying a
second argument but since we may be change from another time that could be
either DST or not then this would give inconsistent results.

Fixes #12163.
2014-01-26 16:56:33 +00:00
tinogomes
5121593787 Adding Hash#compact and Hash#compact! methods
* Adding Hash#compact and Hash#compact! methods
  * Using Ruby 1.9 syntax on documentation
  * Updating guides for `Hash#compact` and `Hash#compact!` methods
  * Updating CHANGELOG for ActiveSupport
  * Removing unecessary protected method and lambda for `Hash#compact` implementations
  * Performing `Hash#compact` implementation - https://gist.github.com/tinogomes/8332883
  * fixing order position
  * Fixing typo
2014-01-09 16:02:55 -02:00
Roderick van Domburg
9330631888 Auto-generate stable fixture UUIDs on PostgreSQL.
Fixes: #11524
2014-01-07 19:05:50 +01:00
Carlos Antonio da Silva
6bf93b22d5 Fix typo in AS changelog, improve highlight [ci skip] 2014-01-06 10:28:44 -02:00