aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md2
-rw-r--r--activesupport/lib/active_support/base64.rb2
-rw-r--r--activesupport/lib/active_support/callbacks.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb2
-rw-r--r--activesupport/lib/active_support/tagged_logging.rb2
-rw-r--r--activesupport/lib/active_support/version.rb2
-rw-r--r--activesupport/test/callbacks_test.rb65
-rw-r--r--activesupport/test/core_ext/base64_ext_test.rb9
-rw-r--r--activesupport/test/tagged_logging_test.rb6
9 files changed, 82 insertions, 10 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index fe4c64aed0..db0832e741 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Rails 3.2.0 (unreleased) ##
+## Rails 3.2.0 (January 20, 2012) ##
* ActiveSupport::Base64 is deprecated in favor of ::Base64. *Sergey Nartimov*
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb
index bb4c955eea..61a4af1a87 100644
--- a/activesupport/lib/active_support/base64.rb
+++ b/activesupport/lib/active_support/base64.rb
@@ -40,7 +40,7 @@ module ActiveSupport
def self.decode64(value)
ActiveSupport::Deprecation.warn "ActiveSupport::Base64.decode64 " \
"is deprecated. Use Base64.decode64 instead", caller
- ::Base64.encode64(value)
+ ::Base64.decode64(value)
end
def self.encode64s(value)
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 0495741c15..f5fd86bf74 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -396,7 +396,7 @@ module ActiveSupport
def __run_callback(key, kind, object, &blk) #:nodoc:
name = __callback_runner_name(key, kind)
unless object.respond_to?(name)
- str = send("_#{kind}_callbacks").compile(key, object)
+ str = object.send("_#{kind}_callbacks").compile(key, object)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{name}() #{str} end
protected :#{name}
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
index 48cf1a435d..6f3fd416c1 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -4,7 +4,7 @@ class DateTime
class << self
# DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone
def local_offset
- ::Time.local(2007).utc_offset.to_r / 86400
+ ::Time.local(2012).utc_offset.to_r / 86400
end
# Returns <tt>Time.zone.now.to_datetime</tt> when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise returns <tt>Time.now.to_datetime</tt>.
diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb
index 2fad91495d..d71215b447 100644
--- a/activesupport/lib/active_support/tagged_logging.rb
+++ b/activesupport/lib/active_support/tagged_logging.rb
@@ -27,7 +27,7 @@ module ActiveSupport
new_tags.size.times { tags.pop }
end
- def silence(temporary_level = ERROR, &block)
+ def silence(temporary_level = Logger::ERROR, &block)
@logger.silence(temporary_level, &block)
end
deprecate :silence
diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb
index 7a9037ee32..0fee9e5c31 100644
--- a/activesupport/lib/active_support/version.rb
+++ b/activesupport/lib/active_support/version.rb
@@ -3,7 +3,7 @@ module ActiveSupport
MAJOR = 3
MINOR = 2
TINY = 0
- PRE = "rc2"
+ PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index e723121bb4..c88e7550be 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -298,7 +298,7 @@ module CallbacksTest
end
end
end
-
+
class AroundPersonResult < MySuper
attr_reader :result
@@ -309,7 +309,7 @@ module CallbacksTest
def tweedle_dum
@result = yield
end
-
+
def tweedle_1
:tweedle_1
end
@@ -317,7 +317,7 @@ module CallbacksTest
def tweedle_2
:tweedle_2
end
-
+
def save
run_callbacks :save do
:running
@@ -345,6 +345,55 @@ module CallbacksTest
end
end
+
+ module ExtendModule
+ def self.extended(base)
+ base.class_eval do
+ set_callback :save, :before, :record3
+ end
+ end
+ def record3
+ @recorder << 3
+ end
+ end
+
+ module IncludeModule
+ def self.included(base)
+ base.class_eval do
+ set_callback :save, :before, :record2
+ end
+ end
+ def record2
+ @recorder << 2
+ end
+ end
+
+ class ExtendCallbacks
+
+ include ActiveSupport::Callbacks
+
+ define_callbacks :save
+ set_callback :save, :before, :record1
+
+ include IncludeModule
+
+ def save
+ run_callbacks :save
+ end
+
+ attr_reader :recorder
+
+ def initialize
+ @recorder = []
+ end
+
+ private
+
+ def record1
+ @recorder << 1
+ end
+ end
+
class AroundCallbacksTest < Test::Unit::TestCase
def test_save_around
around = AroundPerson.new
@@ -363,7 +412,7 @@ module CallbacksTest
], around.history
end
end
-
+
class AroundCallbackResultTest < Test::Unit::TestCase
def test_save_around
around = AroundPersonResult.new
@@ -646,4 +695,12 @@ module CallbacksTest
end
end
+ class ExtendCallbacksTest < Test::Unit::TestCase
+ def test_save
+ model = ExtendCallbacks.new.extend ExtendModule
+ model.save
+ assert_equal [1, 2, 3], model.recorder
+ end
+ end
+
end
diff --git a/activesupport/test/core_ext/base64_ext_test.rb b/activesupport/test/core_ext/base64_ext_test.rb
index 544c990b3c..07052a366a 100644
--- a/activesupport/test/core_ext/base64_ext_test.rb
+++ b/activesupport/test/core_ext/base64_ext_test.rb
@@ -7,4 +7,13 @@ class Base64Test < Test::Unit::TestCase
assert_no_match(/\n/, ActiveSupport::Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"))
end
end
+
+ def test_encode_and_decode
+ ActiveSupport::Deprecation.silence do
+ string = "foobar"
+ encoded_string = ActiveSupport::Base64.encode64(string)
+ assert_equal "Zm9vYmFy\n", encoded_string
+ assert_equal string, ActiveSupport::Base64.decode64(encoded_string)
+ end
+ end
end
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index 17c4214dfc..7ecab33a9a 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -64,4 +64,10 @@ class TaggedLoggingTest < ActiveSupport::TestCase
assert_equal "[BCX] [Jason] Funky time\n[BCX] Junky time!\n", @output.string
end
+
+ test "silence" do
+ assert_deprecated do
+ assert_nothing_raised { @logger.silence {} }
+ end
+ end
end