diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-06-12 18:09:09 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-06-12 18:19:21 +0100 |
commit | 14e6bbb149a7045d73d34deed2c8ef4a47e4233f (patch) | |
tree | 807d803443c6c7778f63b3bd720f477d3917542a /activerecord/test/models | |
parent | de01a6410207efd9554e9d1ed901c180e54d632a (diff) | |
download | rails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.tar.gz rails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.tar.bz2 rails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.zip |
Refactor tests to be less brittle
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/company.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index e0b30efd51..c1f7a4171a 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -124,6 +124,18 @@ class Client < Company has_many :accounts, :through => :firm belongs_to :account + class RaisedOnSave < RuntimeError; end + attr_accessor :raise_on_save + before_save do + raise RaisedOnSave if raise_on_save + end + + class RaisedOnDestroy < RuntimeError; end + attr_accessor :raise_on_destroy + before_destroy do + raise RaisedOnDestroy if raise_on_destroy + end + # Record destruction so we can test whether firm.clients.clear has # is calling client.destroy, deleting from the database, or setting # foreign keys to NULL. |