diff options
author | David Chelimsky <dchelimsky@gmail.com> | 2011-06-25 12:41:06 -0500 |
---|---|---|
committer | David Chelimsky <dchelimsky@gmail.com> | 2011-06-25 13:59:49 -0500 |
commit | a7af1e0051c5fae0a851a9c7f84892573639e5c5 (patch) | |
tree | 756b83ca83ef43a9ce712bd3fc8dc9f1ffa7b537 | |
parent | 211fa2d28d0f8a875792e078e1fca3718649de3c (diff) | |
download | rails-a7af1e0051c5fae0a851a9c7f84892573639e5c5.tar.gz rails-a7af1e0051c5fae0a851a9c7f84892573639e5c5.tar.bz2 rails-a7af1e0051c5fae0a851a9c7f84892573639e5c5.zip |
Get the fixture_path from self.class instead of ActiveSupport::TestCase.
This allows test classes that are not subclasses of
ActiveSupport::TestCase (like those in rspec-rails) to interact with
with this variable without having to reference ActiveSupport::TestCase.
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_process.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 367c295cf5..f668b81b45 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -39,7 +39,7 @@ module ActionDispatch # # 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 diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 6265e78030..043d44500a 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -649,6 +649,13 @@ XML 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}" |