Skip to content

Commit

Permalink
Add a failing test for assigning nil to a polymorphic belongs_to not …
Browse files Browse the repository at this point in the history
…nullifying its _type column
  • Loading branch information
jeremy committed Dec 18, 2013
1 parent b641542 commit c141dfc
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -578,6 +578,19 @@ def test_polymorphic_assignment_with_primary_key_updates_foreign_id_field_for_ne
assert_nil essay.writer_id
end

def test_polymorphic_assignment_with_nil
essay = Essay.new
assert_nil essay.writer_id
assert_nil essay.writer_type

essay.writer_id = 1
essay.writer_type = 'Author'

essay.writer = nil
assert_nil essay.writer_id
assert_nil essay.writer_type
end

def test_belongs_to_proxy_should_not_respond_to_private_methods
assert_raise(NoMethodError) { companies(:first_firm).private_method }
assert_raise(NoMethodError) { companies(:second_client).firm.private_method }
Expand Down

1 comment on commit c141dfc

@jeremy
Copy link
Member Author

@jeremy jeremy commented on c141dfc Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @rafaelfranca - related to association builder / reflection changes?

Please sign in to comment.