我一直在收到一個錯誤,我認爲可以通過 解決,在運行測試時禁用acts_as_audited,或者至少存在 current_user in audit sweeper 。錯誤在下面。你認爲我應該怎麼做 ?Ruby on Rails:RSpec和作爲審計的行爲(在測試時禁用acts_as_audited?)
NoMethodError in 'Order should create a new instance given valid attributes'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.current_user
/home/ramon/rails/app/vendor/plugins/acts_as_audited/lib/acts_as_audited/audit_sweeper.rb:73:in `send'
/home/ramon/rails/app/vendor/plugins/acts_as_audited/lib/acts_as_audited/audit_sweeper.rb:73:in `current_user'
/home/ramon/rails/app/vendor/plugins/acts_as_audited/lib/acts_as_audited/audit_sweeper.rb:61:in `after_create'
./spec/models/order_spec.rb:13:
在規格/型號/ order_spec.rb我試過磕碰AuditSweeper.current_user,template.current_user和controller.current_user返回一個模擬用戶模型。沒有工作。
任何幫助表示讚賞。謝謝!
'spec/models/order_spec.rb:13'發生了什麼? – 2010-01-14 03:33:09