aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-07-16 11:32:42 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-07-16 11:32:42 -0700
commita00f547d2b83f95d169050a2b25afa196d0a9205 (patch)
treebf62ac28f3c36c901d55bc5a96702a34aac0e7e3 /activerecord
parentd4df7ce7b356835208141e6ac8e5ffb09ece8401 (diff)
parentdd1ec62578db6f7a03d1c07546b00a008a0c629d (diff)
downloadrails-a00f547d2b83f95d169050a2b25afa196d0a9205.tar.gz
rails-a00f547d2b83f95d169050a2b25afa196d0a9205.tar.bz2
rails-a00f547d2b83f95d169050a2b25afa196d0a9205.zip
Merge pull request #15718 from chancancode/regression_from_15694
Fixed a regression introduced in 84cf156
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/core.rb5
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb6
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index b11c4f804f..d22806fbdf 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -107,6 +107,11 @@ module ActiveRecord
end
module ClassMethods
+ def allocate
+ define_attribute_methods
+ super
+ end
+
def initialize_find_by_cache
self.find_by_statement_cache = {}.extend(Mutex_m)
end
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 2048e0d5ad..ab67cf4085 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -143,7 +143,11 @@ class AttributeMethodsTest < ActiveRecord::TestCase
# Syck calls respond_to? before actually calling initialize
def test_respond_to_with_allocated_object
- topic = Topic.allocate
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = 'topics'
+ end
+
+ topic = klass.allocate
assert !topic.respond_to?("nothingness")
assert !topic.respond_to?(:nothingness)
assert_respond_to topic, "title"