-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate loaded_#{association}? collecting @changed_attributes to avo…
…id SystemStackError: stack level too deep for mutual delegation beetween models
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper') | ||
|
||
describe DelegatesAttributesTo, 'with mutual delegation' do | ||
|
||
before :all do | ||
UserNoDefault.has_one :profile, :foreign_key => 'user_id' | ||
UserNoDefault.delegates_attributes_to :profile | ||
|
||
Profile.belongs_to :user, :class_name => 'UserNoDefault', :foreign_key => 'user_id' | ||
Profile.delegates_attributes_to :user | ||
end | ||
|
||
before :each do | ||
@user = UserDefault.new | ||
@user.about = "I'm Bob" | ||
@user.profile.username = "bob" | ||
@user.save! | ||
end | ||
|
||
describe "#save" do | ||
it "should save and do not raise SystemStackError: stack level too deep" do | ||
@user = UserDefault.find(@user.id) | ||
@user.should_not be_changed | ||
@user.profile.should_not be_changed | ||
@user.save | ||
end | ||
end | ||
end |