Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack::Test::UploadedFile should expose :tempfile accessor to be API-compatible with new ActionDispatch::Http::UploadedFile #30

Closed
wolframarnold opened this issue Feb 8, 2011 · 4 comments

Comments

@wolframarnold
Copy link

Aaron Patterson's (@tenderlove) rewrite of ActionDispatch::Http::UploadedFile exposes tempfile as an attr_accessor.

Rack::Test::Uploaded file should do the same.

See: rails/rails@c52e2cf
http://marklunds.com/articles/one/433

@scotttam
Copy link

This broke for me as well when I upgraded our Rails app from 3.0.0 to 3.0.4.

@brynary
Copy link
Collaborator

brynary commented Jul 27, 2011

Scott -- Is the breakage you're referring to is rooted in the Rails change or Rack-Test?

Wolfram -- Can you provide a specific example of how this change would be helpful to you? Rack-Test does not aim to be API compatible with Rails generally.

@scotttam
Copy link

Hey Bryan,

What I was seeing was:

NoMethodError:
undefined method `tempfile' for #Tempfile:0x0000010eb8cd88

How I got around it was by reopening the Rack::Test::UploadedFile class and exposed tempfile:

module Rack
  module Test
    class UploadedFile
      def tempfile
        @tempfile
      end
    end
  end
end

Hope it helps.

Thanks,

Scott

@brynary
Copy link
Collaborator

brynary commented Jan 24, 2012

Hey all,

Since this thread has been open and stale for a long time, I'm going to close this out. It's not clear there is a Rack-Test bug here, and Rack-Test does not aim to be API-compatible with Rails. As a general rule, Rack-Test is lower level than ActionPack.

If there's a specific bug that can be described in a failing test, please reopen and I can definitely assist. Also, if there's a request for an additional API method to make things easier, please open a separate ticket outlining the desire for the feature.

Thanks,
-Bryan

@brynary brynary closed this as completed Jan 24, 2012
sgerrand pushed a commit to sgerrand/rails that referenced this issue Nov 2, 2013
To test uploading a file without using fixture_file_upload, a posted
ActionDispatch::Http::UploadedFile should not be paramified (just like
Rack::Test::UploadedFile).
(Rack::Test::UploadedFile and ActionDispatch::Http::UploadedFile don't
share the same API, tempfile is not accessible on
Rack::Test::UploadedFile as discussed in
rack/rack-test#30)
rtyley pushed a commit to bfg-repo-cleaner-demos/rails-with-all-non-head-files-deleted that referenced this issue Sep 11, 2023
To test uploading a file without using fixture_file_upload, a posted
ActionDispatch::Http::UploadedFile should not be paramified (just like
Rack::Test::UploadedFile).
(Rack::Test::UploadedFile and ActionDispatch::Http::UploadedFile don't
share the same API, tempfile is not accessible on
Rack::Test::UploadedFile as discussed in
rack/rack-test#30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants