diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-30 21:44:29 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-12-31 20:00:44 +0000 |
commit | 2bf31868033c50d71d6d68c1ddad67147908adc4 (patch) | |
tree | e3fb991c062c88de82b2c2cd7c628e47e182da11 /activerecord/test/models/company.rb | |
parent | f7a15d0e03dc173ab5f88773a97a3bf26d7b957e (diff) | |
download | rails-2bf31868033c50d71d6d68c1ddad67147908adc4.tar.gz rails-2bf31868033c50d71d6d68c1ddad67147908adc4.tar.bz2 rails-2bf31868033c50d71d6d68c1ddad67147908adc4.zip |
Verify that when has_many associated objects are destroyed via :dependent => :destroy, when the parent is destroyed, the callbacks are run
Diffstat (limited to 'activerecord/test/models/company.rb')
-rw-r--r-- | activerecord/test/models/company.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index ee5f77b613..7af4dfe2c9 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -38,7 +38,9 @@ end class Firm < Company has_many :clients, :order => "id", :dependent => :destroy, :counter_sql => "SELECT COUNT(*) FROM companies WHERE firm_id = 1 " + - "AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )" + "AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )", + :before_remove => :log_before_remove, + :after_remove => :log_after_remove has_many :unsorted_clients, :class_name => "Client" has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC" has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id" @@ -88,6 +90,19 @@ class Firm < Company has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false has_many :accounts has_many :unautosaved_accounts, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false + + def log + @log ||= [] + end + + private + def log_before_remove(record) + log << "before_remove#{record.id}" + end + + def log_after_remove(record) + log << "after_remove#{record.id}" + end end class DependentFirm < Company |