From 542cb5c327f92d3f6ae6159a54e86949441f095e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 30 Nov 2010 18:46:56 -0800 Subject: fix warnings, stop using global variables --- activerecord/lib/active_record/relation/query_methods.rb | 6 ++---- activerecord/test/cases/nested_attributes_test.rb | 3 +-- activerecord/test/models/pet.rb | 6 +++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 30cd4f4477..0483950db7 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -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) diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index fb6a239545..ffcc7a081a 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -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 diff --git a/activerecord/test/models/pet.rb b/activerecord/test/models/pet.rb index 570db4c8d5..113826756a 100644 --- a/activerecord/test/models/pet.rb +++ b/activerecord/test/models/pet.rb @@ -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 -- cgit v1.2.3