【发布时间】:2011-03-12 05:41:19
【问题描述】:
我正在使用 ActionController::TestCase (下面的代码) 测试 BranchController 的创建方法。我检查对象是否是通过调用 find_by_name 方法创建的(假设名称在这里是唯一的)。 测试成功运行,但是当我在 mysql db 中检查相同的记录时,它不存在。
class Security::BranchControllerTest < ActionController::TestCase
test "the create" do
post(:create, :branch => {:name => "test branch", :details=> "test branch details"})
#replace find with where searching with all of fields
assert_not_nil Company::Branch.find_by_name("test branch")
end
end
【问题讨论】:
标签: ruby-on-rails database testing controller persistence