I am trying to use paperclip with factory_girl gem but getting a "no handler found error" message.
test_should_update_category(CategoriesControllerTest): Paperclip::AdapterRegistry::NoHandlerError: No handler found for "/system/categories/images/000/000/001/original/tel1.JPG?1354197869"
Factory girl file:
FactoryGirl.define do
factory :category do
name "MyString"
description "MyText"
image { File.new(File.join(Rails.root, 'test','tel1.JPG')) }
end
end
category migration ::---------------
class CreateCategories < ActiveRecord::Migration
def up
create_table :categories do |t|
t.string :name
t.text :description
t.string :image
t.timestamps
end
add_attachment :categories, :image
end
model:
class Category < ActiveRecord::Base
attr_accessible :description, :image, :name
has_attached_file :image, :styles => { :thumb => "100x100>" }
end
category controller test file:
require 'test_helper'
class CategoriesControllerTest < ActionController::TestCase
setup do
@category = FactoryGirl.create(:category)
end
I make it to work with the following code in my app / factory:
FactoryGirl.define do
factory :upload do
permalink "unique"
upload Rack::Test::UploadedFile.new(Rails.root + 'spec/files/uploads/unique.jpg', 'image/jpg')
end
end
So in your app you should change your factory of category to something like this:
FactoryGirl.define do
factory :category do
name "MyString"
description "MyText"
image Rack::Test::UploadedFile.new(Rails.root +'test/tel1.JPG', 'image/jpg')
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With