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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
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?
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
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.
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
This topic is locked and can not be replied to.