fix warnings, stop using global variables

This commit is contained in:
Aaron Patterson 2010-11-30 18:46:56 -08:00
parent 10b1887a71
commit 542cb5c327
3 changed files with 8 additions and 7 deletions

View File

@ -243,12 +243,10 @@ module ActiveRecord
end
def build_joins(relation, joins)
association_joins = []
joins = joins.map {|j| j.respond_to?(:strip) ? j.strip : j}.uniq
joins.each do |join|
association_joins << join if [Hash, Array, Symbol].include?(join.class) && !array_of_strings?(join)
association_joins = joins.find_all do |join|
[Hash, Array, Symbol].include?(join.class) && !array_of_strings?(join)
end
stashed_association_joins = joins.grep(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)

View File

@ -848,13 +848,12 @@ class TestNestedAttributesWithNonStandardPrimaryKeys < ActiveRecord::TestCase
def test_attr_accessor_of_child_should_be_value_provided_during_update_attributes
@owner = owners(:ashley)
@pet1 = pets(:chew)
assert_equal nil, $current_user
attributes = {:pets_attributes => { "1"=> { :id => @pet1.id,
:name => "Foo2",
:current_user => "John",
:_destroy=>true }}}
@owner.update_attributes(attributes)
assert_equal 'John', $after_destroy_callback_output
assert_equal 'John', Pet.after_destroy_output
end
end

View File

@ -6,8 +6,12 @@ class Pet < ActiveRecord::Base
belongs_to :owner, :touch => true
has_many :toys
class << self
attr_accessor :after_destroy_output
end
after_destroy do |record|
$after_destroy_callback_output = record.current_user
Pet.after_destroy_output = record.current_user
end
end