1. 14 11月, 2016 5 次提交
  2. 01 11月, 2016 1 次提交
    • A
      Ensure duration parsing is consistent across DST changes · 8931916f
      Andrew White 提交于
      Previously `ActiveSupport::Duration.parse` used `Time.current` and
      `Time#advance` to calculate the number of seconds in the duration
      from an arbitrary collection of parts. However as `advance` tries to
      be consistent across DST boundaries this meant that either the
      duration was shorter or longer depending on the time of year.
      
      This was fixed by using an absolute reference point in UTC which
      isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000
      was chosen for no other reason that it seemed appropriate.
      
      Additionally, duration parsing should now be marginally faster as we
      are no longer creating instances of `ActiveSupport::TimeWithZone`
      every time we parse a duration string.
      
      Fixes #26941.
      8931916f
  3. 23 10月, 2016 1 次提交
  4. 21 10月, 2016 1 次提交
  5. 20 10月, 2016 1 次提交
    • J
      Fix copy_time_to: Copy nsec instead of usec · fc72d681
      Josua Schmid 提交于
      `copy_time_to` is a helper function for date and time calculations.
      It's being used by `prev_week`, `next_week` and `prev_weekday` to keep
      the time fraction when jumping around between days.
      
      Previously the nanoseconds part was lost during the operation. This
      lead to problems in practice if you were using the `end_of_day`
      calculation. Resulting in the time fraction of `end_of_day` not being
      the same as next week's `end_of_day`.
      
      With this fix `copy_time_to` doesn't forget the `nsec` digits.
      fc72d681
  6. 03 10月, 2016 1 次提交
  7. 01 10月, 2016 1 次提交
    • T
      Fix `ActiveSupport::TimeWithZone#localtime` · 607a6c7a
      Thomas Balthazar 提交于
      Previously memoization in `localtime` wasn't taking the `utc_offset`
      parameter into account when returning a cached value. It now caches the
      computed value depending on the `utc_offset` parameter, e.g:
      
          Time.zone = "US/Eastern"
      
          t = Time.zone.local(2016,5,2,11)
          # => Mon, 02 May 2016 11:00:00 EDT -04:00
      
          t.localtime(-7200)
          # => 2016-05-02 13:00:00 -0200
      
          t.localtime(-3600)
          # => 2016-05-02 14:00:00 -0100
      607a6c7a
  8. 24 9月, 2016 1 次提交
    • T
      Fix ActiveSupport::TimeWithZone#in · 76c2553b
      Thomas Balthazar 提交于
      Previously calls to `in` were being sent to the non-DST aware
      method `Time#since` via `method_missing`. It is now aliased to
      the DST aware `ActiveSupport::TimeWithZone#+` which handles
      transitions across DST boundaries, e.g:
      
          Time.zone = "US/Eastern"
      
          t = Time.zone.local(2016,11,6,1)
          # => Sun, 06 Nov 2016 01:00:00 EDT -05:00
      
          t.in(1.hour)
          # => Sun, 06 Nov 2016 01:00:00 EST -05:00
      76c2553b
  9. 10 8月, 2016 1 次提交
  10. 04 8月, 2016 1 次提交
    • W
      Fix `thread_mattr_accessor` share variable superclass with subclass · 3529e58e
      willnet 提交于
      The current implementation of `thread_mattr_accessor` set variable
      sharing superclass with subclass. So the method doesn't work as documented.
      
      Precondition
      
          class Account
            thread_mattr_accessor :user
          end
      
          class Customer < Account
          end
      
          Account.user = "DHH"
          Account.user  #=> "DHH"
          Customer.user = "Rafael"
          Customer.user # => "Rafael"
      
      Documented behavior
      
          Account.user  # => "DHH"
      
      Actual behavior
      
          Account.user  # => "Rafael"
      
      Current implementation set variable statically likes `Thread[:attr_Account_user]`,
      and customer also use it.
      
      Make variable name dynamic to use own thread-local variable.
      3529e58e
  11. 03 8月, 2016 1 次提交
  12. 30 7月, 2016 1 次提交
  13. 22 7月, 2016 4 次提交
  14. 17 7月, 2016 1 次提交
    • G
      Introduce `assert_changes` and `assert_no_changes` · 16f24cd1
      Genadi Samokovarov 提交于
      Those are assertions that I really do miss from the standard
      `ActiveSupport::TestCase`. Think of those as a more general version of
      `assert_difference` and `assert_no_difference` (those can be implemented
      by assert_changes, should this change be accepted).
      
      Why do we need those? They are useful when you want to check a
      side-effect of an operation. `assert_difference` do cover a really
      common case, but we `assert_changes` gives us more control. Having a
      global error flag? You can test it easily with `assert_changes`. In
      fact, you can be really specific about the initial state and the
      terminal one.
      
      ```ruby
      error = Error.new(:bad)
      assert_changes -> { Error.current }, from: nil, to: error do
        expected_bad_operation
      end
      ```
      
      `assert_changes` follows `assert_difference` and a string can be given
      for evaluation as well.
      
      ```ruby
      error = Error.new(:bad)
      assert_changes 'Error.current', from: nil, to: error do
        expected_bad_operation
      end
      ```
      
      Check out the test cases if you wanna see more examples.
      
      🍻
      16f24cd1
  15. 14 7月, 2016 1 次提交
  16. 12 7月, 2016 1 次提交
  17. 03 7月, 2016 1 次提交
    • V
      `travel/travel_to` travel time helpers, now raise on nested calls, · 919e7053
      Vipul A M 提交于
           as this can lead to confusing time stubbing.
      
           Instead of:
      
               travel_to 2.days.from_now do
                 # 2 days from today
                 travel_to 3.days.from_now do
                   # 5 days from today
                 end
               end
      
           preferred way to achieve above is:
      
               travel_to 2.days.from_now
               # 2 days from today
      
               travel_back
               travel_to 5.days.from_now
               # 5 days from today
      
      Closes #24690
      Fixes #24689
      919e7053
  18. 02 7月, 2016 1 次提交
  19. 27 6月, 2016 1 次提交
  20. 23 6月, 2016 1 次提交
  21. 14 6月, 2016 1 次提交
  22. 02 6月, 2016 1 次提交
    • S
      Don't blank pad day of the month when formatting dates · 2c5a8ba6
      Sean Griffin 提交于
      We are currently using `%e` which adds a space before the result if the
      digit is a single number. This leads to strings like `February  2, 2016`
      which is undesireable. I've opted to replace with 0 padding instead of
      removing the padding entirely, to preserve compatibility for those
      relying on the fact that the width is constant, and to be consistent
      with time formatting.
      
      Fixes #25251.
      2c5a8ba6
  23. 16 5月, 2016 1 次提交
    • J
      Action Mailer: Declarative exception handling with `rescue_from`. · e35b98e6
      Jeremy Daer 提交于
      Follows the same pattern as controllers and jobs. Exceptions raised in
      delivery jobs (enqueued by `#deliver_later`) are also delegated to the
      mailer's rescue_from handlers, so you can handle the DeserializationError
      raised by delivery jobs:
      
      ```ruby
      class MyMailer < ApplicationMailer
        rescue_from ActiveJob::DeserializationError do
          …
        end
      ```
      
      ActiveSupport::Rescuable polish:
      * Add the `rescue_with_handler` class method so exceptions may be
        handled at the class level without requiring an instance.
      * Rationalize `exception.cause` handling. If no handler matches the
        exception, fall back to the handler that matches its cause.
      * Handle exceptions raised elsewhere. Pass `object: …` to execute
        the `rescue_from` handler (e.g. a method call or a block to
        instance_exec) against a different object. Defaults to `self`.
      e35b98e6
  24. 10 5月, 2016 1 次提交
  25. 07 5月, 2016 1 次提交
  26. 30 4月, 2016 1 次提交
  27. 28 4月, 2016 3 次提交
  28. 26 4月, 2016 1 次提交
    • A
      Do not cache ActiveSupport::TimeZone#utc_offset · 420730b1
      Alexey Shein 提交于
      This can be an issue when TZInfo::TimeZone#current_period is refreshed
      due to timezone period transition, but it's not reflected in
      ActiveSupport::TimeZone object.
      
      For example, on Sun, 26 Oct 2014 22:00 UTC, Moscow changed its TZ from
      MSK +04:00 to MSK +03:00 (-1 hour). If ActiveSupport::TimeZone['Moscow']
      happens to be initialized just before the timezone transition, it will
      cache its stale utc_offset even after the timezone transition.
      
      This commit removes cache and fixes this issue.
      Signed-off-by: NJeremy Daer <jeremydaer@gmail.com>
      420730b1
  29. 24 4月, 2016 3 次提交
    • V
    • A
      Make getlocal and getutc always return instances of Time · ee5e476a
      Andrew White 提交于
      Previously these methods could return either a DateTime or a Time
      depending on how the ActiveSupport::TimeWithZone instance had
      been constructed. Changing to always return an instance of Time
      eliminates a possible stack level too deep error in to_time where
      it was wrapping a DateTime instance.
      
      As a consequence of this the internal time value is now always an
      instance of Time in the UTC timezone, whether that's as the UTC
      time directly or a representation of the local time in the timezone.
      
      There should be no consequences of this internal change and if
      there are it's a bug due to leaky abstractions.
      ee5e476a
    • A
      Add DateTime#subsec · a424bbb2
      Andrew White 提交于
      Mirrors the Time#subsec method by returning the fraction
      of the second as a Rational.
      a424bbb2