aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-08-08 21:51:33 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-08-08 21:51:33 +0100
commit761283ffdb5750f8a38e2ed67891d2b2b9152d7f (patch)
tree4df91ec28ab7d403174468a437c3fe28d7ff3925 /activerecord/test/cases
parent00544c778f53b034bf4560548479a20a06d5c22d (diff)
downloadrails-761283ffdb5750f8a38e2ed67891d2b2b9152d7f.tar.gz
rails-761283ffdb5750f8a38e2ed67891d2b2b9152d7f.tar.bz2
rails-761283ffdb5750f8a38e2ed67891d2b2b9152d7f.zip
Ensure hm:t#create/create! throws ActiveRecord::RecordNotSaved when the owner is new
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 8529ff0285..f6b4a42377 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -169,6 +169,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_equal peeps + 1, posts(:thinking).people.count
end
+ def test_create_on_new_record
+ p = Post.new
+
+ assert_raises(ActiveRecord::RecordNotSaved) { p.people.create(:first_name => "mew") }
+ assert_raises(ActiveRecord::RecordNotSaved) { p.people.create!(:first_name => "snow") }
+ end
+
def test_clear_associations
assert_queries(2) { posts(:welcome);posts(:welcome).people(true) }