diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-02 14:28:53 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 16:24:31 -0800 |
commit | a0be389d39b790e0625339251d2674b8250b16b1 (patch) | |
tree | 256369916a5916d03d2b9e614582b0f7a9c35d74 /activerecord/test/models/company.rb | |
parent | c47f802d0e7b0156512f197887d6e9bda6d0f269 (diff) | |
download | rails-a0be389d39b790e0625339251d2674b8250b16b1.tar.gz rails-a0be389d39b790e0625339251d2674b8250b16b1.tar.bz2 rails-a0be389d39b790e0625339251d2674b8250b16b1.zip |
Allow assignment on has_one :through where the owner is a new record [#5137 state:resolved]
This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct.
Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things.
Phew, long commit message!
Diffstat (limited to 'activerecord/test/models/company.rb')
-rw-r--r-- | activerecord/test/models/company.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index 7af4dfe2c9..d08e593db1 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -124,6 +124,7 @@ class Client < Company belongs_to :firm_with_primary_key, :class_name => "Firm", :primary_key => "name", :foreign_key => "firm_name" belongs_to :firm_with_primary_key_symbols, :class_name => "Firm", :primary_key => :name, :foreign_key => :firm_name belongs_to :readonly_firm, :class_name => "Firm", :foreign_key => "firm_id", :readonly => true + has_many :accounts, :through => :firm # Record destruction so we can test whether firm.clients.clear has # is calling client.destroy, deleting from the database, or setting |