Monday, 12 August 2013

Image attribute not saving in test with FactoryGirl

Image attribute not saving in test with FactoryGirl

App
I have a column bg_image in a table User that uses a carrierwave uploader
mount_uploader :bg_image, UserLogoUploader
It gets set in an activeadmin/formtastic form like below:
f.input :bg_image, :label => "Background Image", :as => :file
Tests (where the problem is)
I have a factory for User to make the basic version with all the required
fields (which works in other tests), but then when i try to add bg_image
it doesn't get saved.
factory:
FactoryGirl.define do
factory :user do
stuff "set in factory"
end
end
test file:
let!(:user) { create(:user, :something => "that works", :bg_image =>
"doesntWork.png") }
it "inspects the element" do
puts user.inspect
end
prints out
#<User id: 1, stuff: "set in factory", something: "that works", bg_image:
nil>
I just can't seem to figure out why it doesn't save!
I tried a few things like setting it to File object but that won't work
because it needs to be a string

No comments:

Post a Comment