rails test 测试中屏蔽警告信息的办法

作者在 2023-07-22 00:29:31 发布以下内容
如果出现类似信息
DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
`legacy_connection_handling` to `false` in your application.

The new connection handling does not support `connection_handlers`
getter and setter.

Read more about how to migrate at: https://guides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling
在 config/environments/test.rb 加入
config.active_record.legacy_connection_handling = false

作者在 2023-07-22 00:30:37 补充以下内容
如果出现类似信息
DEPRECATION WARNING: Non-URL-safe CSRF tokens are deprecated. Use 6.1 defaults or above. (called from block (3 levels) in <class:Railtie> at /usr/local/lib/ruby/gems/3.2.0/gems/actionpack-7.0.5/lib/action_controller/railtie.rb:80)
在 config/environments/test.rb 加入
config.load_defaults 7.0

作者在 2023-07-22 00:35:12 补充以下内容
这两项配置同样也可以用在 development 和 production 环境
Ruby | 阅读 668 次
文章评论,共0条
游客请输入验证码
浏览2802850次
文章归档