Permalink
Browse files

cleaning up some test warnings

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent d1eed89 commit 115230e6195115d6200047eb0c3247d3aad82ee7 @tenderlove tenderlove committed with wycats Mar 14, 2010
@@ -111,8 +111,11 @@ def clear_association_cache #:nodoc:
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.
@@ -1041,6 +1041,7 @@ def instantiate(record)
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)
@@ -154,6 +154,11 @@ def klass
@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 @@ def polymorphic_inverse_of(associated_class)
# 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
@@ -14,6 +14,11 @@ class Relation
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

0 comments on commit 115230e

Please sign in to comment.