Commit Graph

152 Commits

Author SHA1 Message Date
Steve Klabnik
feaa6e2048 Revert "Merge pull request #8156 from fredwu/acronym_fix-master"
This reverts commit 867dc1700f32aae6f98c4651bd501597e6b52bc0, reversing
changes made to 9a421aaa8285cf2a7ecb1af370748b0337818930.

This breaks anyone who's using ForceSSL: https://travis-ci.org/rails-api/rails-api/jobs/5556065

Please see comments on #8156 for some discussion.
2013-03-16 15:25:49 -07:00
Xavier Noria
e958eabeb1 revises the CHANGELOG entry from 26aa265 [ci skip] 2013-03-16 16:03:09 +01:00
Fred Wu
26aa26564d Added Inflector#underscore fix to the changelog 2013-03-17 00:32:28 +11:00
Yves Senn
f8b0e54939 CHANGELOG entry for improved singularizing of singulars.
Closes #9559.

The actual patch was added with #4719
2013-03-06 08:28:23 +01:00
Steve Klabnik
5112a6ccdf Move AS CHANGELOG entry up.
I merged b883706 but forgot to move the entry past beta1.
2013-02-26 11:21:37 -08:00
Steve Klabnik
95883ca4b1 Merge pull request #9329 from chuckbjones/fix-cache-delete-rc
Fix deletion of empty directories
2013-02-26 11:15:29 -08:00
Rafael Mendonça França
0f75e2c51f Update CHANGELOGS 2013-02-26 13:45:57 -03:00
Charles Jones
b8837066dc Fix deletion of empty directories:
1. When comparing the directory to delete against the top level
   cache_path, use File.realpath to make sure we aren't comparing two
   unequal strings that point to the same path. This occurs, for
   example, when cache_path has a trailing slash, which it does in the
   default Rails configuration. Since the input to
   delete_empty_directories never has a trailing slash, the comparison
   will never be true and the top level cache directory (and above) may
   be deleted. However…

2. File.delete raises EPERM when trying to delete a directory, so no
   directories have ever been deleted. Changing the code to Dir.delete
   fixes that.
2013-02-25 18:54:44 -06:00
David Heinemeier Hansson
c0bc9ce38c Preparing for 4.0.0.beta1 release 2013-02-25 08:31:50 -06:00
Chris Baynes
fa891a2b9d Keep second fraction when DateTime#change is called. 2013-02-25 11:05:49 +01:00
Rafael Mendonça França
51e963790f Add more information to the CHANGELOG entry [ci skip] 2013-02-24 18:36:45 -03:00
stopdropandrew
cb100ca02b Added ActiveSupport::TimeWithZone#to_r for Time#at compatibility. 2013-02-24 13:24:50 -08:00
Xavier Noria
1509844cdd did a pass over the AS changelog [ci skip] 2013-02-24 21:26:02 +01:00
Carlos Antonio da Silva
1fbfdf5e1b Changelog improvements, use 1.9 style hash in examples [ci skip] 2013-02-22 19:44:50 -03:00
hoffm
4e3ceedeba Address edge case for number_to_human with units option.
ActiveSupport::NumberHelper#number_to_human now returns the number unaltered when
the units hash does not contain the needed key, e.g. when the number provided is less
than the largest key provided.
2013-02-22 08:25:51 -05:00
Gagan Awhad
6f380d3778 Added beginning_of_minute support to core_ext calculations for Time and DateTime 2013-02-21 16:14:16 -06:00
Xavier Noria
20ed3e0f71 moves the new :nsec date format to the Active Support changelog [ci skip] 2013-02-20 18:08:55 +01:00
Beyond
d59a877da4 added compress options for gzip
added test for compress options of gzip

update changelog
2013-02-10 20:01:42 +09:00
Carlos Antonio da Silva
2f0c26bf59 Update changelog from #9128 with author name
And improve AS changelog a bit [ci skip]
2013-02-06 19:02:40 -02:00
James Harton
28ab79d7c5 Modify TimeWithZone#as_json to return 3DP of sub-second accuracy by default, since it's allowed by the spec and is very useful. 2013-01-31 14:11:51 +13:00
Carlos Antonio da Silva
68f69ec31e Move AS changelog entry to the top, improve AP changelog a bit
[ci skip]
2013-01-28 19:40:18 -02:00
Antoine Lyset
b5245da94a Improve String#squish whitespaces matching 2013-01-22 22:46:11 +01:00
Andrew White
b79adc4323 Standardise the return value of to_time
This commit standardises the return value of `to_time` to an instance
of `Time` in the local system timezone, matching the Ruby core and
standard library behavior.

The default form for `String#to_time` has been changed from :utc to
:local but research seems to suggest the latter is the more common form.

Also fix an edge condition with `String#to_time` where the string has
a timezone offset in it and the mode is :local. e.g:

  # Before:
  >> "2000-01-01 00:00:00 -0500".to_time(:local)
  => 2000-01-01 05:00:00 -0500

  # After:
  >> "2000-01-01 00:00:00 -0500".to_time(:local)
  => 2000-01-01 00:00:00 -0500

Closes #2453
2013-01-21 12:33:49 +00:00
Yves Senn
3e1ed7818b extract PerformanceTest into rails-performance_tests gem 2013-01-10 17:09:06 +01:00
Jeremy Kemper
46e0d2397e CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml. 2013-01-08 12:42:29 -08:00
Jeremy Kemper
c31cc963da Revert "Merge branch 'master-sec'"
This reverts commit 88cc1688d0cb828c17706b41a8bd27870f2a2beb, reversing
changes made to f049016cd348627bf8db0d72382d7580bf802a79.
2013-01-08 12:41:04 -08:00
Jeremy Kemper
2ced6f2f8a CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml. 2013-01-08 12:03:34 -08:00
Yves Senn
947e1d5e85 deprecate assert_blank and assert_present.
They don't add any benefits over `assert object.blank?`
and `assert object.present?`
2013-01-05 18:04:52 +01:00
Carlos Antonio da Silva
149b86d97b Move changelog entry in railties to the top
Other minor changelog improvements [ci skip]
2013-01-04 22:49:14 -02:00
Kelly Stannard
ebd27d5714 Better error message for String#to_date
I did this because to_date gives a very unhelpful error message if you
do not pass in a correct date. In the process I think this cleans up the
 code nicely and even better it tends to be slightly faster than the
 current implementation.

Benchmark
https://gist.github.com/4440875
2013-01-04 16:39:18 +00:00
bUg
38f28dca3a Added ability to compare date/time with infinity
Date, DateTime, Time and TimeWithZone can now be compared to infinity,
  so it's now possible to create ranges with one infinite bound and
  date/time object as another bound.

  Ex.: @range = Range.new(Date.today, Float::INFINITY)

Also it's possible to check inclusion of date/time in range with
  conversion.

  Ex.: @range.include?(Time.now + 1.year) # => true
       @range.include?(DateTime.now + 1.year) # => true

Ability to create date/time ranges with infinite bound is required
  for handling postgresql range types.
2013-01-04 02:41:09 +01:00
Carlos Antonio da Silva
9f200fb296 Changelog improvements [ci skip] 2013-01-02 21:11:11 -02:00
Akira Matsuda
b6aa59368b missing changelog entry for #8682 2013-01-02 19:19:33 -03:00
Jeremy Kemper
f75addd06b Introduce assert_not to replace 'assert !foo' 2012-12-28 10:34:26 -07:00
Rafael Mendonça França
ecc7751575 Merge pull request #7376 from dmitriy-kiriyenko/fix-double-callback-in-same-statement
Prevent callback from being set twice.

Conflicts:
	activesupport/CHANGELOG.md
2012-12-21 17:39:03 -03:00
David Heinemeier Hansson
95f5f8167f Revert "Make sure that ActiveSupport::Logger includes the Logger extensions from core_ext/logger" (some confusion over deprecation)
This reverts commit d00f568a83a5159ed93618b1081bd17858536d1c.
2012-12-21 19:35:10 +01:00
David Heinemeier Hansson
d00f568a83 Make sure that ActiveSupport::Logger includes the Logger extensions from core_ext/logger 2012-12-21 19:28:24 +01:00
David Heinemeier Hansson
f914454f3a Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension 2012-12-21 19:15:36 +01:00
Dmitriy Kiriyenko
4a9644a0d9 Prevent callback from being set twice.
When you add one callack in two separate `set_callback` calls - it is
only called once.

When you do it in one `set_callback` call - it is called twice.

This violates the principle of least astonishment for me. Duplicating
callback is usually an error. There is a correct and obvious way to do
anything without this "feature".

If you want to do

    before_save :clear_balance, :calculate_tax, :clear_balance

or whatever, you should better do

    before_save :carefully_calculate_tax

    def carefully_calculate_tax
      clear_balance
      calculate_tax
      clear_balance
    end

And this even opens gates for some advanced refactorings, unlike the
first approach.

My assumptions are:

- Principle of least astonishment is violated, when callbacks are either
  prevented from duplication, or not.
- Duplicating callbacks is usually an error. When it is intentional -
  it's a smell of a bad design and can be approached without abusing
  this "feature".

My suggestion is: do not allow duplicating callbacks in one callback
call, like it is not allowed in separate callbacks call.
2012-12-20 11:06:45 +02:00
Carlos Antonio da Silva
42b555dcf3 Fix Action Mailer changelog indenation to match other changelogs
Also some minor improvements to other changelogs. [ci skip]
2012-12-19 23:09:04 -02:00
Brett Carter
8f8397e0a4 Remove unicode character encoding from ActiveSupport::JSON.encode
The encoding scheme (e.g. ☠ -> "\u2620") was broken for characters
not in the Basic Multilingual Plane.  It is possible to escape them
for json using the weird encoding scheme of a twelve-character
sequence representing the UTF-16 surrogate pair (e.g. '𠜎' ->
"\u270e\u263a") but this wasn't properly handled in the escaping code.
Since raw UTF-8 is allowed in json, it was decided to simply pass
through the raw bytes rather than attempt to escape them.
2012-12-14 18:54:32 -05:00
Carlos Antonio da Silva
df9f9b7f3e Convert changelogs to 1.9 hash style and fix some formatting [ci skip] 2012-12-14 20:25:22 -02:00
Andrew White
48583f8bf7 Deprecate obsolete Time to DateTime fallback methods
The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time
methods were added to handle the limitations of Ruby's native Time
implementation. Those limitations no longer apply so we are deprecating
them in 4.0 and they will be removed in 4.1.
2012-12-11 13:57:05 +00:00
Andrew White
224d82ee59 Deprecate Date#to_time_in_current_zone
The to_time_in_current_zone method doesn't match the naming of the methods
for converting to ActiveSupport::TimeWithZone on Time and DateTime. Since
DateTime inherits from Date that has led to confusion with some users
using the to_time_in_current_zone method with DateTime instances and having
the time part dropped and the UTC offset lost.

This commit fixes this by deprecating the old method and adding a new
in_time_zone method which matches the naming for DateTime and Time. This
should prevent accidently dropping times and UTC offsets when converting
DateTime instances to ActiveSupport::TimeWithZone.
2012-12-11 07:06:34 +00:00
Andrew White
331a82a1c8 Add String#in_time_zone method
This commit adds a convenience method for converting a string to an
ActiveSupport::TimeWithZone instance using the configured Time.zone or
another passed as an argument.
2012-12-11 06:32:28 +00:00
Francesco Rodriguez
6ee03a40bb Rename ActiveSupport::BasicObject to ActiveSupport::ProxyObject
AS::BasicObject is used for proxy classes. Let's give it a less concerning
name. Also, it avoids the confusion with Ruby's Basic Object.
2012-12-07 14:13:56 -05:00
Uriel Katz
9ee0ffb360 Patched Marshal#load to work with constant autoloading (active_support/dependecies.rb) (issue #8167) 2012-12-01 14:00:16 +02:00
Andrew White
005d910624 Make Time.zone.parse to work with JavaScript date strings
Chrome, Safari and Firefox serialize Date objects to strings such
as 'Mon May 28 2012 00:00:00 GMT-0700 (PDT)'. When these strings
are parsed the zone is interpreted as 'GMT-0700' which doesn't
exist in the TzInfo list of timezones.

By taking advantage of the improved date/time handling in 1.9.3
we can use `Date._parse` and the `:offset` value which is parsed
correctly.

Three tests were amended to make them pass:

1.  test_parse_with_old_date

    This needed changing to a different value because the original
    value was before EST was adopted so was being changed to a
    LMT (Local Mean Time) value after the change. It didn't before
    because `DateTime` just has offsets from UTC not timezones.

2.  test_parse_should_not_black_out_system_timezone_dst_jump

    Changed the implementation of this test as the stubs were
    dependent on internal implementation details of the test.
    Confirmed that the modified test still failed when the
    implementation of `parse` was restored to pre-#5571.

3.  test_parse_should_black_out_app_timezone_dst_jump

    Ditto.

Closes #5770.
2012-12-01 11:34:21 +00:00
Olek Janiszewski
ce73055139 Add #seconds_until_end_of_day to DateTime and Time 2012-11-29 06:39:32 +01:00
Steve Klabnik
bd852603a1 Simplify String#mb_chars and stop proxying #class
This behavior mattered under Ruby 1.8, but that doesn't matter now
that we don't support it.

In addition, we don't want to proxy the #class method. A test was added
to prevent against regressions.
2012-11-28 13:58:51 -08:00