diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-27 13:06:04 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-27 13:06:04 -0800 |
commit | 5aade8245a0fe10e80e60fd0d01427406b53e753 (patch) | |
tree | 19d48fbede8e5f468f23bed4170d35cb8e87bfb6 /actionpack/lib/action_dispatch/testing | |
parent | 6c0ea8875fa888f1f20b31e9ef67b73966078b14 (diff) | |
parent | 8b104e2f0cb6e92604185f7a4934acad80142f2a (diff) | |
download | rails-5aade8245a0fe10e80e60fd0d01427406b53e753.tar.gz rails-5aade8245a0fe10e80e60fd0d01427406b53e753.tar.bz2 rails-5aade8245a0fe10e80e60fd0d01427406b53e753.zip |
Merge pull request #8318 from Empact/fixture-file
Use File.join to better integrate fixture_path in fixture_file_upload.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_process.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 9ad5a1bc1d..e657283cec 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -26,17 +26,19 @@ module ActionDispatch @response.redirect_url end - # Shortcut for <tt>Rack::Test::UploadedFile.new(ActionController::TestCase.fixture_path + path, type)</tt>: + # Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, path), type)</tt>: # - # post :change_avatar, avatar: fixture_file_upload('/files/spongebob.png', 'image/png') + # post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png') # # To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter. # This will not affect other platforms: # - # post :change_avatar, avatar: fixture_file_upload('/files/spongebob.png', 'image/png', :binary) + # post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) 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) + if self.class.respond_to?(:fixture_path) && self.class.fixture_path + path = File.join(self.class.fixture_path, path) + end + Rack::Test::UploadedFile.new(path, mime_type, binary) end end end |