1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix fixture_file_upload bug

In beb7fba, I forgot to add a branch in the case where an application uses AR (and thus it responds to `fixture_path`) to return a path relative to `file_fixture_path`.

Closes #39278.
This commit is contained in:
Edouard Chin 2020-05-17 06:16:07 +02:00 committed by GitHub
parent 03e82e2f0d
commit 683d9d586e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -35,6 +35,8 @@ module ActionDispatch
Please modify the call from
`fixture_file_upload(#{original_path})` to `fixture_file_upload(#{non_deprecated_path})`.
EOM
else
path = file_fixture(original_path)
end
elsif self.class.file_fixture_path && !File.exist?(path)
path = file_fixture(path)

View file

@ -930,6 +930,14 @@ XML
end
end
def test_fixture_file_upload_does_not_output_deprecation_when_file_fixture_path_is_set
TestCaseTest.stub :fixture_path, File.expand_path("../fixtures", __dir__) do
assert_not_deprecated do
fixture_file_upload("ruby_on_rails.jpg", "image/jpg")
end
end
end
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)`"