Note that there are some explanatory texts on larger screens.

plurals
  1. POPaperclip functional test giving NoHandlerError
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/10033425/paperclip-exception-paperclipadapterregistrynohandlererror">Paperclip exception : Paperclip::AdapterRegistry::NoHandlerError</a> </p> </blockquote> <p>**********EDIT**********</p> <p>I have investigated this further and found the issue was down to the way FactoryGirl is passing the attachment. Basically the controller is receiving a string and not the uploaded file object. I have created a new question (<a href="https://stackoverflow.com/questions/11283318/paperclipattachment-passed-as-string-when-using-factorygirl">Paperclip::Attachment passed as string when using FactoryGirl</a>) which includes my workaround for anyone who may have a similar issue. </p> <p>Testing paperclip 3.1.2 on rails 3.2.6 and i am getting the following exception when testing that a model with a file attachment is created:</p> <pre><code>test_should_create_artist(ArtistsControllerTest): Paperclip::AdapterRegistry::NoHandlerError: No handler found for "/system/artists/photos/000/000/001/original/rails.png?1340130452" </code></pre> <p>my model is:</p> <pre><code>class Artist &lt; ActiveRecord::Base has_attached_file :photo, :styles =&gt; {:medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" }, :default_url =&gt; "image_missing.png" attr_accessible :photo, :photo_file_name validates_attachment :photo, :presence =&gt; true, :content_type =&gt; { :content_type =&gt; "image/jpg" }, :size =&gt; { :in =&gt; 0..10000.kilobytes } end </code></pre> <p>my controller is:</p> <pre><code>class ArtistsController &lt; ApplicationController # POST /artists # POST /artists.json def create @artist = Artist.new(params[:artist]) respond_to do |format| if @artist.save format.html { redirect_to @artist, notice: 'Artist was successfully created.' } format.json { render json: @artist, status: :created, location: @artist } else format.html { render action: "new" } format.json { render json: @artist.errors, status: :unprocessable_entity } end end end end </code></pre> <p>And my test is :</p> <pre><code>require 'test_helper' class ArtistsControllerTest &lt; ActionController::TestCase setup do @artist = FactoryGirl.build(:artist) end test "should create artist" do assert_difference('Artist.count') do post :create, :artist =&gt; { biography: @artist.biography, name: @artist.name, website: @artist.website, photo: @artist.photo }, :html =&gt; { :multipart =&gt; true } end assert_redirected_to artist_path(assigns(:artist)) end end </code></pre> <p>As far as i can tell the factory is working but it is:</p> <pre><code>include ActionDispatch::TestProcess FactoryGirl.define do factory :artist do id 1 photo {fixture_file_upload(Rails.root.join('test','fixtures', 'files', 'rails.png'),'image/png')} end end </code></pre> <p>As this is a basic test I'm sure I've just got something horribly wrong. Any help would be greatly appreciated! Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload