[Rails 3.2.5] Rails: unit test fixture_path : fixture_file_upload cannot find the file

I am trying to perform a test unit, using FactoryGirl

include ActionDispatch::TestProcess
FactoryGirl.define do
factory :article do

photo { fixture_file_upload ‘/files/test.jpg’, ‘image/jpg’ }
end
end

IN mt test_helper.rb I defined the fixture_path

def fixture_path
File.dirname(FILE) + “/fixtures/” # “…/myapp/test/
fixtures/”
end

and I have my test.jpg in “…/myapp/test/fixtures/files/
test.jpg”

but running the unit test, article = FactoryGirl.build(:article,
title: nil), I get an error :
RuntimeError: files/test.jpg file does not exist

where should I put the file for ‘fixture_file_upload’ can find it ?

thanks for feedback

I looked into : actionpack/lib/action_dispatch/testing/
test_process.rb

def fixture_file_upload(path, mime_type = nil, binary = false)
  fixture_path = self.class.fixture_path if self.class.respond_to?

(:fixture_path)
Rack::Test::UploadedFile.new("#{fixture_path}#{path}",
mime_type, binary)
end

it’s trying to get the fixturePath from self.class ( Article in this
case) which doesn’t respond to fixture_path
however the correct path is given by
ActionController::TestCase.fixture_path

so using the trick:
photo { fixture_file_upload
“#{ActionController::TestCase.fixture_path}files/test.jpg”, ‘image/
jpg’ }
runs well… but I guess it’s just a trick, the ‘truth’ is somewhere
else … ?
how can I relate the fixture_path with the self.class

thanks for your feedback