diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-03-14 15:46:03 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-03-14 17:28:27 -0600 |
commit | 115230e6195115d6200047eb0c3247d3aad82ee7 (patch) | |
tree | 2622fe981e1764fc6d21c8d0d40822f3644d9a85 /activerecord/lib/active_record | |
parent | d1eed89ac3b72457c0327bf1ff2a2a9cc8842910 (diff) | |
download | rails-115230e6195115d6200047eb0c3247d3aad82ee7.tar.gz rails-115230e6195115d6200047eb0c3247d3aad82ee7.tar.bz2 rails-115230e6195115d6200047eb0c3247d3aad82ee7.zip |
cleaning up some test warnings
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 7 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 5 |
4 files changed, 16 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b69577f8dd..a5179033f2 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -111,8 +111,11 @@ module ActiveRecord private # Gets the specified association instance if it responds to :loaded?, nil otherwise. def association_instance_get(name) - association = instance_variable_get("@#{name}") - association if association.respond_to?(:loaded?) + ivar = "@#{name}" + if instance_variable_defined?(ivar) + association = instance_variable_get(ivar) + association if association.respond_to?(:loaded?) + end end # Set the specified association instance. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 52587ef251..9ec7c1ecaf 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1041,6 +1041,7 @@ module ActiveRecord #:nodoc: object.instance_variable_set(:'@attributes', record) object.instance_variable_set(:'@attributes_cache', {}) + object.instance_variable_set(:@new_record, false) object.send(:_run_find_callbacks) object.send(:_run_initialize_callbacks) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 32b9a2aa87..5e8fc104cb 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -154,6 +154,11 @@ module ActiveRecord @klass ||= active_record.send(:compute_type, class_name) end + def initialize(macro, name, options, active_record) + super + @collection = [:has_many, :has_and_belongs_to_many].include?(macro) + end + # Returns a new, unsaved instance of the associated class. +options+ will # be passed to the class's constructor. def build_association(*options) @@ -256,9 +261,6 @@ module ActiveRecord # association. Returns +true+ if the +macro+ is one of +has_many+ or # +has_and_belongs_to_many+, +false+ otherwise. def collection? - if @collection.nil? - @collection = [:has_many, :has_and_belongs_to_many].include?(macro) - end @collection end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index aca4629dd8..3a7ebce288 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -14,6 +14,11 @@ module ActiveRecord def initialize(klass, table) @klass, @table = klass, table + + @readonly_value = nil + @create_with_value = nil + @implicit_readonly = nil + (ASSOCIATION_METHODS + MULTI_VALUE_METHODS).each {|v| instance_variable_set(:"@#{v}_values", [])} end |