aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-10-02 08:14:43 -0400
committerSean Griffin <sean@seantheprogrammer.com>2015-10-02 08:14:43 -0400
commit1a693c79c32cba070256fdb7bd1990c3d07d554f (patch)
tree75f5b6459c1cdc7510469f28be5f6a6c000fe046 /activerecord
parent07723c23a7dc570beae73c074ad37227e3e8a06e (diff)
downloadrails-1a693c79c32cba070256fdb7bd1990c3d07d554f.tar.gz
rails-1a693c79c32cba070256fdb7bd1990c3d07d554f.tar.bz2
rails-1a693c79c32cba070256fdb7bd1990c3d07d554f.zip
Fix test failures on MySQL
There were a few places where I missed a `create` vs `new` before_type_cast check, and the semantics of `reload` became wrong.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb4
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb2
-rw-r--r--activerecord/test/cases/integration_test.rb4
3 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index a2e4e0ac31..17ec4c2252 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -35,7 +35,9 @@ module ActiveRecord
# <tt>reload</tt> the record and clears changed attributes.
def reload(*)
super.tap do
- clear_changes_information
+ @mutation_tracker = AttributeMutationTracker.new(@attributes)
+ @previous_mutation_tracker = nil
+ @changed_attributes = HashWithIndifferentAccess.new
end
end
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 8e5723c8e5..9a0f0f8ada 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -177,7 +177,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
def test_read_attributes_before_type_cast_on_boolean
- bool = Boolean.create({ "value" => false })
+ bool = Boolean.new({ "value" => false })
if RUBY_PLATFORM =~ /java/
# JRuby will return the value before typecast as string
assert_equal "0", bool.reload.attributes_before_type_cast["value"]
diff --git a/activerecord/test/cases/integration_test.rb b/activerecord/test/cases/integration_test.rb
index 80d17b8114..9169207b0a 100644
--- a/activerecord/test/cases/integration_test.rb
+++ b/activerecord/test/cases/integration_test.rb
@@ -96,7 +96,9 @@ class IntegrationTest < ActiveRecord::TestCase
owner.update_column :updated_at, Time.current
key = owner.cache_key
- assert pet.touch
+ travel(1.second) do
+ assert pet.touch
+ end
assert_not_equal key, owner.reload.cache_key
end