attachment_fu testing in rails 3

前端 未结 3 519
轻奢々
轻奢々 2020-12-09 11:48

I am trying to write specs for a working file upload functionality using attachment_fu. However, the sample code given by the author for testing requires me to require

3条回答
  •  不知归路
    2020-12-09 12:40

    I was able to use fixture_file_upload just fine with Rails3 and rspec.

    I just added include ActionDispatch::TestProcess to the spec_helper.rb, and then passed something like the following as the filedata:

    fixture_file_upload(Rails.root.join("spec/support/test.png"), 'image/png')
    

    EDIT: Something I upgraded changed the behavior of this to always include the fixtures path, so I switched to this instead of fixture_file_upload:

    Rack::Test::UploadedFile.new(Rails.root.join("spec/support/test.png"), 'image/png')
    

提交回复
热议问题