提交 542cb5c3 编写于 作者: A Aaron Patterson

fix warnings, stop using global variables

上级 10b1887a
......@@ -243,12 +243,10 @@ def build_where(opts, other = [])
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)
......
......@@ -848,13 +848,12 @@ def test_should_update_existing_records_with_non_standard_primary_key
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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册