From e4fcc58529c9659b5d0d35479a9a6acf8edb9e36 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sat, 24 Sep 2016 08:56:31 +0930 Subject: Only search fixture_path for files that can't be found directly When passed an already-valid file name, prepending the path is likely to create problems. This is particularly relevant for #26384, which adds fixture_path handling to test classes that previously didn't have it: any existing caller must have been manually locating the file, and we don't want to break them. --- actionpack/test/controller/test_case_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 696794a3eb..738d8bab6d 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -962,6 +962,13 @@ XML end end + def test_fixture_file_upload_ignores_fixture_path_given_full_path + TestCaseTest.stub :fixture_path, File.dirname(__FILE__) do + uploaded_file = fixture_file_upload("#{FILES_DIR}/mona_lisa.jpg", "image/jpg") + assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read + end + end + def test_fixture_file_upload_ignores_nil_fixture_path uploaded_file = fixture_file_upload("#{FILES_DIR}/mona_lisa.jpg", "image/jpg") assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read -- cgit v1.2.3