Search code examples
ruby-on-railsgithub-actionsrails-activestorage

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


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.


Solution

  • config.active_job.queue_adapter = :test in test.rb was config.active_job.queue_adapter = :sidekiq