使用delete_all和make时,rails 3中的mysql超时错误!在步骤定义中
我在黄瓜步骤定义中使用以下构造。
Given "I have following stuff" do
Model.delete_all
list.each { |i| Model.make!(:name => i) }
end
(make!来自机械师2)。
上述步骤因 INSERT 语句超时而失败。当我打开测试环境控制台时,我可以毫无问题地执行每个语句。另外,如果我禁用事务功能,超时就会消失。
谁能帮我解决这个问题吗? (这在 Rails 2.x 上运行没有问题)
(数据库 MySQL)
I'm using following construct in a cucumber step definition.
Given "I have following stuff" do
Model.delete_all
list.each { |i| Model.make!(:name => i) }
end
(make! is from machinist 2).
Above step fails with INSERT statement timeout. When I open up a console for test, environment, I can execute each statement without an issue. Also, if I disable transactional features timeout goes away.
Can anyone please help me fix this? (This ran without an issue with rails 2.x)
(Database MySQL)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明这是我使用的机械师测试版的问题。我不能 100% 确定出了什么问题,但是当我使用纯 ActiveRecord 代码而不是 make! 来创建对象时!它起作用了。
然后我切换到 Factory_Girl 而不是机械师,现在它工作正常。
This turned out be an issue with machinist beta version I was using. I'm not 100% sure what was wrong, but when I used pure ActiveRecord code to create the objects, instead of make! it worked.
Then I switched to Factory_Girl instead of machinist, and now it works fine.