Skip to content

How to: Test Fog based uploaders

EmmaB edited this page Dec 14, 2017 · 6 revisions

If you are using Fog as your storage mechanism, you can tell Fog to mock out calls to the cloud storage provider. Put the following in a file in spec/support or features/support:

Fog.mock!
Fog.credentials_path = Rails.root.join('config/fog_credentials.yml')
connection = Fog::Storage.new(:provider => 'AWS')
connection.directories.create(:key => 'my_bucket')

Contents of fog_credentials.yml for AWS:

default:
  aws_access_key_id: 'xxx'     # required
  aws_secret_access_key: 'yyy' # required
  region: 'us-east-1'          # optional, defaults to 'us-east-1'

See How to: migrate to the new fog storage provider for other Fog storage provider settings.

This can be done instead of switching to :file based storage as outlined in the README. You will still need to turn off processing as outlined in the README but you will not have to worry about the storage systems being different in different environments.

Clone this wiki locally