我遇到了一个错误,我认为可以通过在运行测试时禁用acts_as_audited 来解决,或者至少在审计清扫器中存根current_user。错误如下。你觉得我应该怎么做?
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:
在 spec/models/order_spec.rb 中,我尝试将 AuditSweeper.current_user、template.current_user 和 controller.current_user 存根以返回模拟用户模型。没有工作。
任何帮助表示赞赏。谢谢!