aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Pradi <tchandy@gmail.com>2010-07-25 21:38:15 -0300
committerJosé Valim <jose.valim@gmail.com>2010-07-26 17:13:52 +0200
commitf70c0b348d2f703d763a8136df7837567f7cb691 (patch)
treed5dd4ed065bb93d3eda8037b5a665ae11efb016b
parent0e969bdaf8ff2e3384350687aa0b583f94d6dfbc (diff)
downloadrails-f70c0b348d2f703d763a8136df7837567f7cb691.tar.gz
rails-f70c0b348d2f703d763a8136df7837567f7cb691.tar.bz2
rails-f70c0b348d2f703d763a8136df7837567f7cb691.zip
Removing unnecessary code [#5192 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r--activerecord/lib/active_record/autosave_association.rb4
-rw-r--r--activerecord/test/cases/autosave_association_test.rb8
2 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 7517896235..062b010436 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -377,10 +377,6 @@ module ActiveRecord
if association.updated?
association_id = association.send(reflection.options[:primary_key] || :id)
self[reflection.primary_key_name] = association_id
- # TODO: Removing this code doesn't seem to matter...
- if reflection.options[:polymorphic]
- self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s
- end
end
saved if autosave
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 3b89c12a3f..08694526af 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -171,7 +171,7 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas
end
class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
- fixtures :companies
+ fixtures :companies, :posts, :tags, :taggings
def test_should_save_parent_but_not_invalid_child
client = Client.new(:name => 'Joe (the Plumber)')
@@ -312,6 +312,12 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test
assert_equal num_orders +1, Order.count
assert_equal num_customers +2, Customer.count
end
+
+ def test_store_association_with_a_polymorphic_relationship
+ num_tagging = Tagging.count
+ tags(:misc).create_tagging(:taggable => posts(:thinking))
+ assert_equal num_tagging +1, Tagging.count
+ end
end
class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase