aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-05-01 14:32:50 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-05-01 14:32:50 -0500
commite2af713d1c71b4f319e5435a63011a7bc23f77c3 (patch)
tree0397b4aea75e5c77eb6b288996769fbe24f65b60 /activerecord/test/cases/base_test.rb
parent9c20391bbe6ec1c56f8c8ed4aefb31a93576f76a (diff)
parent74436d2203eba186baebc1ddc82ff2202d0fc005 (diff)
downloadrails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.tar.gz
rails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.tar.bz2
rails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rwxr-xr-xactiverecord/test/cases/base_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 93719c710a..e07ec50c46 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -251,6 +251,27 @@ class BasicsTest < ActiveRecord::TestCase
topic = Topic.create("title" => "New Topic")
topicReloaded = Topic.find(topic.id)
assert_equal(topic, topicReloaded)
+ end
+
+ def test_create_through_factory_with_block
+ topic = Topic.create("title" => "New Topic") do |t|
+ t.author_name = "David"
+ end
+ topicReloaded = Topic.find(topic.id)
+ assert_equal("New Topic", topic.title)
+ assert_equal("David", topic.author_name)
+ end
+
+ def test_create_many_through_factory_with_block
+ topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) do |t|
+ t.author_name = "David"
+ end
+ assert_equal 2, topics.size
+ topic1, topic2 = Topic.find(topics[0].id), Topic.find(topics[1].id)
+ assert_equal "first", topic1.title
+ assert_equal "David", topic1.author_name
+ assert_equal "second", topic2.title
+ assert_equal "David", topic2.author_name
end
def test_update