Rails DirectUpload works fine locally but getting 'Invalid URL' error during GitHub Actions unit testing – why?

huangapple go评论55阅读模式
英文:

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: &quot;&quot;
     # ./app/services/users/put_avatar.rb:14:in `call&#39;
     # ./spec/services/users/put_avatar_spec.rb:6:in `block (2 levels) in &lt;main&gt;&#39;
     # ./spec/services/users/put_avatar_spec.rb:29:in `block (3 levels) in &lt;main&gt;&#39;

I also tried to add:

config.hostname = URI(ENV.fetch(&#39;HOST_URL&#39;, &#39;http://localhost:3000&#39;)).hostname
routes.default_url_options[:host] = ENV.fetch(&#39;HOST_URL&#39;, &#39;http://localhost:3000&#39;)

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

huangapple
  • 本文由 发表于 2023年6月2日 05:04:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385698.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定