Forum: Ruby on Rails Is it possible to make attachment_fu to use :file_system for storage during tests?

C4906d169db781c14eca72e6bc2f81fc?d=identicon&s=25 Roman Mirk (armanm)
on 2013-03-09 02:54
I'm using Attachment_fu for a model that has 3 attachment fields with s3
for storage.

Unit testing this model is very slow. This made me think if there is a
way to switch between storage types during testing and
development/production?
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse mailing lists (Guest)
on 2013-03-09 05:20
(Received via mailing list)
On Fri, Mar 8, 2013 at 7:54 PM, Arman Mirk <lists@ruby-forum.com> wrote:
> I'm using Attachment_fu for a model that has 3 attachment fields with s3
> for storage.
>
> Unit testing this model is very slow. This made me think if there is a
> way to switch between storage types during testing and
> development/production?

Or just mock them.
C4906d169db781c14eca72e6bc2f81fc?d=identicon&s=25 Roman Mirk (armanm)
on 2013-03-09 05:24
Could you please be more specific or provide an example if possible?

Thanks
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse mailing lists (Guest)
on 2013-03-09 06:10
(Received via mailing list)
On Fri, Mar 8, 2013 at 10:24 PM, Roman Mirk <lists@ruby-forum.com>
wrote:
> Could you please be more specific or provide an example if possible?

Read up on rspec mocks in the RSpec book, and there are several
examples around the net.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2013-03-09 11:47
(Received via mailing list)
On Saturday, March 9, 2013 1:54:38 AM UTC, Ruby-Forum.com User wrote:
>
> I'm using Attachment_fu for a model that has 3 attachment fields with s3
> for storage.
>
> Unit testing this model is very slow. This made me think if there is a
> way to switch between storage types during testing and
> development/production?
>

Attachment_fu is a little old school, but there's no reason you couldn't
do
something like

    has_attachment :storage => (Rails.env.production? ? :s3 :
:file_system)

to use s3 for production and filesystem for everything else

Fred
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.