Skip to content
Browse files

Merge pull request #1861 from dchelimsky/fixture_path

Get the fixture_path from self.class instead of ActiveSupport::TestCase.
  • Loading branch information...
2 parents 211fa2d + a7af1e0 commit 095f0466c880e802c287e899e4ed645e44453484 @spastorino spastorino committed Jun 25, 2011
View
2 actionpack/lib/action_dispatch/testing/test_process.rb
@@ -39,7 +39,7 @@ def redirect_to_url
#
# post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png', :binary)
def fixture_file_upload(path, mime_type = nil, binary = false)
- fixture_path = ActionController::TestCase.send(:fixture_path) if ActionController::TestCase.respond_to?(:fixture_path)
+ fixture_path = self.class.fixture_path if self.class.respond_to?(:fixture_path)
Rack::Test::UploadedFile.new("#{fixture_path}#{path}", mime_type, binary)
end
end
View
7 actionpack/test/controller/test_test.rb
@@ -649,6 +649,13 @@ def test_test_uploaded_file
end
+ def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case
+ TestTest.stubs(:fixture_path).returns(FILES_DIR)
+
+ uploaded_file = fixture_file_upload('/mona_lisa.jpg', 'image/png')
+ assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read
+ end
+
def test_test_uploaded_file_with_binary
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"

0 comments on commit 095f046

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