Skip to content
This repository
Browse code

Merge pull request #1861 from dchelimsky/fixture_path

Get the fixture_path from self.class instead of ActiveSupport::TestCase.
  • Loading branch information...
commit 095f0466c880e802c287e899e4ed645e44453484 2 parents 211fa2d + a7af1e0
Santiago Pastorino spastorino authored
2  actionpack/lib/action_dispatch/testing/test_process.rb
@@ -39,7 +39,7 @@ def redirect_to_url
39 39 #
40 40 # post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png', :binary)
41 41 def fixture_file_upload(path, mime_type = nil, binary = false)
42   - fixture_path = ActionController::TestCase.send(:fixture_path) if ActionController::TestCase.respond_to?(:fixture_path)
  42 + fixture_path = self.class.fixture_path if self.class.respond_to?(:fixture_path)
43 43 Rack::Test::UploadedFile.new("#{fixture_path}#{path}", mime_type, binary)
44 44 end
45 45 end
7 actionpack/test/controller/test_test.rb
@@ -649,6 +649,13 @@ def test_test_uploaded_file
649 649
650 650 end
651 651
  652 + def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case
  653 + TestTest.stubs(:fixture_path).returns(FILES_DIR)
  654 +
  655 + uploaded_file = fixture_file_upload('/mona_lisa.jpg', 'image/png')
  656 + assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read
  657 + end
  658 +
652 659 def test_test_uploaded_file_with_binary
653 660 filename = 'mona_lisa.jpg'
654 661 path = "#{FILES_DIR}/#{filename}"

0 comments on commit 095f046

Please sign in to comment.
Something went wrong with that request. Please try again.