ruby on rails - Image attribute not saving in test with FactoryGirl -


app

i have column bg_image in table user uses carrierwave uploader

mount_uploader :bg_image, userlogouploader 

it gets set in activeadmin/formtastic form below:

f.input :bg_image, :label => "background image", :as => :file 

tests (where problem is)

i have factory user make basic version required fields (which works in other tests), when try add bg_image doesn't saved.

factory:

factorygirl.define   factory :user     stuff "set in factory"   end end 

test file:

let!(:user) { create(:user, :something => "that works", :bg_image => "doesntwork.png") }  "inspects element"   puts user.inspect end 

prints out

#<user id: 1, stuff: "set in factory", something: "that works", bg_image: nil> 

i can't seem figure out why doesn't save!

i tried few things setting file object won't work because needs string

im pretty sure not working because in tests using bg_image string, remember mounted uploader bg_image , need use carrierwave work, check carrierwave documentation info testing, hope helps !

here documentation:

https://github.com/carrierwaveuploader/carrierwave#testing-with-carrierwave


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -