0
@@ -251,6 +251,27 @@ class BasicsTest < ActiveRecord::TestCase
0
topic = Topic.create("title" => "New Topic")
0
topicReloaded = Topic.find(topic.id)
0
assert_equal(topic, topicReloaded)
0
+ def test_create_through_factory_with_block
0
+ topic = Topic.create("title" => "New Topic") do |t|
0
+ t.author_name = "David"
0
+ topicReloaded = Topic.find(topic.id)
0
+ assert_equal("New Topic", topic.title)
0
+ assert_equal("David", topic.author_name)
0
+ def test_create_many_through_factory_with_block
0
+ topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) do |t|
0
+ t.author_name = "David"
0
+ assert_equal 2, topics.size
0
+ topic1, topic2 = Topic.find(topics[0].id), Topic.find(topics[1].id)
0
+ assert_equal "first", topic1.title
0
+ assert_equal "David", topic1.author_name
0
+ assert_equal "second", topic2.title
0
+ assert_equal "David", topic2.author_name
Comments
No one has commented yet.