diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 69e7cdc8e7..35d2e98eef 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -6,14 +6,16 @@ require "action_dispatch/middleware/flash" module ActionDispatch module TestProcess module FixtureFile - # Shortcut for Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.fixture_path, path), type): + # Shortcut for Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_fixture_path, path), type): # - # post :change_avatar, params: { avatar: fixture_file_upload('files/spongebob.png', 'image/png') } + # post :change_avatar, params: { avatar: fixture_file_upload('spongebob.png', 'image/png') } + # + # Default fixture files location is test/fixtures/files. # # To upload binary files on Windows, pass :binary as the last parameter. # This will not affect other platforms: # - # post :change_avatar, params: { avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) } + # post :change_avatar, params: { avatar: fixture_file_upload('spongebob.png', 'image/png', :binary) } def fixture_file_upload(path, mime_type = nil, binary = false) if self.class.respond_to?(:fixture_path) && self.class.fixture_path && !File.exist?(path) @@ -33,7 +35,7 @@ module ActionDispatch In Rails 6.2, the path needs to be relative to `file_fixture_path`. Please modify the call from - `fixture_file_upload(#{original_path})` to `fixture_file_upload(#{non_deprecated_path})`. + `fixture_file_upload("#{original_path}")` to `fixture_file_upload("#{non_deprecated_path}")`. EOM else path = file_fixture(original_path) diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index d21a3ae829..36a1d550a3 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -874,7 +874,7 @@ XML def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case TestCaseTest.stub :fixture_path, File.expand_path("../fixtures", __dir__) do - expected = "`fixture_file_upload(multipart/ruby_on_rails.jpg)` to `fixture_file_upload(ruby_on_rails.jpg)`" + expected = "`fixture_file_upload(\"multipart/ruby_on_rails.jpg\")` to `fixture_file_upload(\"ruby_on_rails.jpg\")`" assert_deprecated(expected) do uploaded_file = fixture_file_upload("multipart/ruby_on_rails.jpg", "image/png") @@ -940,7 +940,7 @@ XML def test_fixture_file_upload_relative_to_fixture_path TestCaseTest.stub :fixture_path, File.expand_path("../fixtures", __dir__) do - expected = "`fixture_file_upload(multipart/ruby_on_rails.jpg)` to `fixture_file_upload(ruby_on_rails.jpg)`" + expected = "`fixture_file_upload(\"multipart/ruby_on_rails.jpg\")` to `fixture_file_upload(\"ruby_on_rails.jpg\")`" assert_deprecated(expected) do uploaded_file = fixture_file_upload("multipart/ruby_on_rails.jpg", "image/jpg")