ActiveStorage with service_name testing on Rspec, is this broken?

Having just upgraded to 6.1 and utilising the option of having multiple services for active storage on models I have run into what seems like an issue.

Previously when testing ActiveStorage on my models as the default service when using ActiveStorage during test is :test there were no issues in attaching items during tests.

However I have now given specific :service_name to my models using ActiveStorage in testing it seems to ignore the default of :test and revert to trying to call the actual service (which in test will not work for my setup).

My workaround is this:

has_many_attached :pdfs, service: Rails.env.test? ? :test : :s3_finalized_receipts

I don’t particularly like this and guess I am missing something here, any advice would be appreciated

I think you’ll need to use configs per environment config/storage/[env].yml instead of just config/storage.yml such as it’s explained here Active Storage Overview — Ruby on Rails Guides

1 Like

Ah thanks! I knew I must’ve missed something