Testing question

Hello folks,

I need to write a method that will return a PDF to the user.

Does anyone know of any documentation on how to test
such functionality?

Thanks in advance.

Regards,
Franz

Franz S. wrote:

Hello folks,

I need to write a method that will return a PDF to the user.

Does anyone know of any documentation on how to test
such functionality?

I haven’t needed to do such a thing so I’m of limited help. I suppose
if you’re doing downloads using rails then you’ve probably looked at the
streaming api:
ActionController::Streaming
The send_data/send_file methods allow you to set the content-type and
other headers etc etc.

So in your functional tests for your download controller, you could
probably do something like

def test_1a

get :download , params
assert_equal ‘text/html’,@response.headers[:type]

(Obviously replace ‘text/html’).
You can also access other headers eg content-length and the body
(@response.body).
I don’t know if it’s good form to be using @response.
Integration test api is a little different so might be worth checking
too.

Daniel