mirror of
https://github.com/github/rails.git
synced 2026-01-13 08:38:05 -05:00
Compare commits
13 Commits
v3.2.19.gi
...
3-2-github
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fc14b1f71 | ||
|
|
7c89fc489d | ||
|
|
7a559d389c | ||
|
|
726e996306 | ||
|
|
eadedf7189 | ||
|
|
c831f67d8b | ||
|
|
b6f150c40c | ||
|
|
76ad4030e5 | ||
|
|
0a3c7ba903 | ||
|
|
d69e65ab34 | ||
|
|
56d2614309 | ||
|
|
0afd326c36 | ||
|
|
c957f5f609 |
@@ -1 +1 @@
|
||||
3.2.19.github4
|
||||
3.2.19.github9
|
||||
|
||||
@@ -2,7 +2,6 @@ require 'mail'
|
||||
require 'action_mailer/collector'
|
||||
require 'active_support/core_ext/array/wrap'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/proc'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_support/core_ext/hash/except'
|
||||
require 'active_support/core_ext/module/anonymous'
|
||||
@@ -627,7 +626,7 @@ module ActionMailer #:nodoc:
|
||||
|
||||
# Call all the procs (if any)
|
||||
default_values = self.class.default.merge(self.class.default) do |k,v|
|
||||
v.respond_to?(:call) ? v.bind(self).call : v
|
||||
v.respond_to?(:call) ? instance_eval(&v) : v
|
||||
end
|
||||
|
||||
# Handle defaults
|
||||
|
||||
@@ -2,11 +2,11 @@ module ActionView
|
||||
# = Action View Cache Helper
|
||||
module Helpers
|
||||
module CacheHelper
|
||||
# This helper exposes a method for caching fragments of a view
|
||||
# This helper exposes a method for caching fragments of a view
|
||||
# rather than an entire action or page. This technique is useful
|
||||
# caching pieces like menus, lists of newstopics, static HTML
|
||||
# fragments, and so on. This method takes a block that contains
|
||||
# the content you wish to cache.
|
||||
# the content you wish to cache.
|
||||
#
|
||||
# See ActionController::Caching::Fragments for usage instructions.
|
||||
#
|
||||
@@ -23,7 +23,7 @@ module ActionView
|
||||
# <p>Hello users! Welcome to our website!</p>
|
||||
# <% end %>
|
||||
#
|
||||
# Static content with embedded ruby content can be cached as
|
||||
# Static content with embedded ruby content can be cached as
|
||||
# well:
|
||||
#
|
||||
# <% cache do %>
|
||||
@@ -49,10 +49,11 @@ module ActionView
|
||||
else
|
||||
# VIEW TODO: Make #capture usable outside of ERB
|
||||
# This dance is needed because Builder can't use capture
|
||||
pos = output_buffer.length
|
||||
pos = output_buffer.bytesize
|
||||
yield
|
||||
output_safe = output_buffer.html_safe?
|
||||
fragment = output_buffer.slice!(pos..-1)
|
||||
fragment = output_buffer.byteslice(pos..-1)
|
||||
self.output_buffer = output_buffer.byteslice(0...pos)
|
||||
if output_safe
|
||||
self.output_buffer = output_buffer.class.new(output_buffer)
|
||||
end
|
||||
|
||||
@@ -371,7 +371,7 @@ module ActiveRecord
|
||||
begin
|
||||
record.committed!
|
||||
rescue Exception => e
|
||||
record.logger.error(e) if record.respond_to?(:logger) && record.logger
|
||||
handle_commit_exceptions(record, e)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -385,6 +385,11 @@ module ActiveRecord
|
||||
row = result.rows.first
|
||||
row && row.first
|
||||
end
|
||||
|
||||
# Handle any exceptions caught trying to send the commit message to a record
|
||||
def handle_commit_exceptions(record, e)
|
||||
record.logger.error(e) if record.respond_to?(:logger) && record.logger
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -278,7 +278,7 @@ module ActiveRecord
|
||||
|
||||
# Call the after_commit callbacks
|
||||
def committed! #:nodoc:
|
||||
run_callbacks :commit
|
||||
run_callbacks :commit if destroyed? || persisted?
|
||||
ensure
|
||||
@_start_transaction_state.clear
|
||||
end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
require "active_support/core_ext/kernel/singleton_class"
|
||||
|
||||
class Proc #:nodoc:
|
||||
def bind(object)
|
||||
block, time = self, Time.now
|
||||
object.class_eval do
|
||||
method_name = "__bind_#{time.to_i}_#{time.usec}"
|
||||
define_method(method_name, &block)
|
||||
method = instance_method(method_name)
|
||||
remove_method(method_name)
|
||||
method
|
||||
end.bind(object)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
require 'active_support/concern'
|
||||
require 'active_support/core_ext/class/attribute'
|
||||
require 'active_support/core_ext/proc'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_support/core_ext/array/extract_options'
|
||||
|
||||
@@ -108,7 +107,11 @@ module ActiveSupport
|
||||
when Symbol
|
||||
method(rescuer)
|
||||
when Proc
|
||||
rescuer.bind(self)
|
||||
if rescuer.arity == 0
|
||||
Proc.new { instance_exec(&rescuer) }
|
||||
else
|
||||
Proc.new { |_exception| instance_exec(_exception, &rescuer) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -338,7 +338,7 @@ module ActiveSupport
|
||||
# so transfer time values to a utc constructor if necessary
|
||||
@time = transfer_time_values_to_utc_constructor(@time) unless @time.utc?
|
||||
begin
|
||||
@time_zone.period_for_local(@time)
|
||||
@time_zone.period_for_local(@time) { |periods| periods.first }
|
||||
rescue ::TZInfo::PeriodNotFound
|
||||
# time is in the "spring forward" hour gap, so we're moving the time forward one hour and trying again
|
||||
@time += 1.hour
|
||||
|
||||
@@ -309,8 +309,8 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
# Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance.
|
||||
def local_to_utc(time, dst=true)
|
||||
tzinfo.local_to_utc(time, dst)
|
||||
def local_to_utc(time, dst=true, &block)
|
||||
tzinfo.local_to_utc(time, dst, &block)
|
||||
end
|
||||
|
||||
# Available so that TimeZone instances respond like TZInfo::Timezone instances
|
||||
@@ -319,8 +319,8 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
# Available so that TimeZone instances respond like TZInfo::Timezone instances
|
||||
def period_for_local(time, dst=true)
|
||||
tzinfo.period_for_local(time, dst)
|
||||
def period_for_local(time, dst=true, &block)
|
||||
tzinfo.period_for_local(time, dst, &block)
|
||||
end
|
||||
|
||||
def self.find_tzinfo(name)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/proc'
|
||||
|
||||
class ProcTests < Test::Unit::TestCase
|
||||
def test_bind_returns_method_with_changed_self
|
||||
block = Proc.new { self }
|
||||
assert_equal self, block.call
|
||||
bound_block = block.bind("hello")
|
||||
assert_not_equal block, bound_block
|
||||
assert_equal "hello", bound_block.call
|
||||
end
|
||||
end
|
||||
@@ -136,6 +136,17 @@ class TimeZoneTest < Test::Unit::TestCase
|
||||
assert_equal 'EDT', twz.zone
|
||||
end
|
||||
|
||||
def test_local_handles_non_dst_clock_set_back
|
||||
# If the clocks are set back during a transition from one non-DST observance
|
||||
# to another, the time of the transition will be ambiguous. The earlier
|
||||
# observance will be selected to mirror behaviour of DST to non-DST transitions.
|
||||
# Such a transition occurred at 02:00 local time in Moscow on 26 October 2014.
|
||||
zone = ActiveSupport::TimeZone['Moscow']
|
||||
twz = zone.local(2014,10,26,1)
|
||||
assert_equal Time.utc(2014,10,26,1), twz.time
|
||||
assert_equal Time.utc(2014,10,25,21), twz.utc
|
||||
end
|
||||
|
||||
def test_at
|
||||
zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
|
||||
secs = 946684800.0
|
||||
|
||||
Reference in New Issue
Block a user