英文:
Rails DirectUpload works fine locally but getting 'Invalid URL' error during GitHub Actions unit testing - why?
问题
在本地环境中,直接上传的单元测试可以正常工作。但在 GitHub CI 中则不行。
以下是错误信息:
1) Users::PutAvatar 当 signed_blob_id 存在时返回成功
Failure/Error: user.avatar.attach(blob)
ArgumentError:
无效的 URL: ""
# ./app/services/users/put_avatar.rb:14:in `call'
# ./spec/services/users/put_avatar_spec.rb:6:in `block (2 levels) in <main>'
# ./spec/services/users/put_avatar_spec.rb:29:in `block (3 levels) in <main>'
我还尝试添加以下内容:
config.hostname = URI(ENV.fetch('HOST_URL', 'http://localhost:3000')).hostname
routes.default_url_options[:host] = ENV.fetch('HOST_URL', 'http://localhost:3000')
但是,这也不起作用。
英文:
Locally, the unit test for direct upload works. But in GitHub CI it doesn't.
Here is the error:
1) Users::PutAvatar when signed_blob_id exist return sucess
Failure/Error: user.avatar.attach(blob)
ArgumentError:
Invalid URL: ""
# ./app/services/users/put_avatar.rb:14:in `call'
# ./spec/services/users/put_avatar_spec.rb:6:in `block (2 levels) in <main>'
# ./spec/services/users/put_avatar_spec.rb:29:in `block (3 levels) in <main>'
I also tried to add:
config.hostname = URI(ENV.fetch('HOST_URL', 'http://localhost:3000')).hostname
routes.default_url_options[:host] = ENV.fetch('HOST_URL', 'http://localhost:3000')
But, it doesn't work either.
答案1
得分: 0
在 test.rb
中的 config.active_job.queue_adapter = :test
被修改为 config.active_job.queue_adapter = :sidekiq
。
英文:
config.active_job.queue_adapter = :test
in test.rb
was
config.active_job.queue_adapter = :sidekiq
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论