You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to get my specs working. I have a model Attachment which has a file attribute attachment. Now I want to provide a mocked attachment through my factory (I use FactoryGirl). I use Ruby (2.1.3) on Rails (4.0.2). I Upload the files to amazon s3.
What I tried so far is:
# config/initializers/carrierwave.rb
if (Rails.env.test?)
Fog.mock!
end
CarrierWave.configure do |config|
config.fog_credentials = {
provider: "AWS",
aws_access_key_id: s3['access_key_id'],
aws_secret_access_key: s3['secret_access_key'],
region: s3['region']
}
config.fog_directory = s3['bucket']
config.max_file_size = 500.megabytes
end
# factories/models/attachments.rb
include CarrierWaveDirect::Test::Helpers
FactoryGirl.define do
factory :attachment do
...
attachment { sample_key(AttachmentUploader.new, filename: "#{SecureRandom.hex}file.pdf") }
end
end
This seems to work somehow, at least I get a valid attachment entry with some properties set:
Hi there,
I try to get my specs working. I have a model
Attachment
which has a file attributeattachment
. Now I want to provide a mocked attachment through my factory (I useFactoryGirl
). I use Ruby (2.1.3) on Rails (4.0.2). I Upload the files to amazon s3.What I tried so far is:
This seems to work somehow, at least I get a valid attachment entry with some properties set:
But when I try to check if the attachment is present or not every location is nil:
Any ideas how I can fix this and how it is done correctly?
Thanks a lot!
The text was updated successfully, but these errors were encountered: