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

Merge pull request #43186 from aried3r/ar/dont_show_file_fixture_path_deprecation_if_same_path

Don't show deprecation warning for equal paths
This commit is contained in:
Guillermo Iguaran 2021-09-12 16:16:41 -07:00 committed by GitHub
commit c0e17d4520
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View file

@ -30,13 +30,16 @@ module ActionDispatch
EOM
elsif path.exist?
non_deprecated_path = Pathname(File.absolute_path(path)).relative_path_from(Pathname(File.absolute_path(self.class.file_fixture_path)))
ActiveSupport::Deprecation.warn(<<~EOM)
Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
In Rails 7.0, 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}")`.
EOM
if Pathname(original_path) != non_deprecated_path
ActiveSupport::Deprecation.warn(<<~EOM)
Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
In Rails 7.0, 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}")`.
EOM
end
else
path = file_fixture(original_path)
end

View file

@ -973,6 +973,16 @@ XML
end
end
def test_fixture_file_upload_fixture_path_same_as_file_fixture_path
TestCaseTest.stub :fixture_path, File.expand_path("../fixtures/multipart", __dir__) do
TestCaseTest.stub :file_fixture_path, File.expand_path("../fixtures/multipart", __dir__) do
assert_not_deprecated do
fixture_file_upload("ruby_on_rails.jpg", "image/jpg")
end
end
end
end
def test_fixture_file_upload_ignores_fixture_path_given_full_path
TestCaseTest.stub :fixture_path, __dir__ do
uploaded_file = fixture_file_upload("#{FILES_DIR}/ruby_on_rails.jpg", "image/jpeg")