ruby on rails - How to Set the Content Type in a ActionController::TestCase request -


I was trying to get it in my TestCase like this:

  request. Env ['CONTENT_TYPE'] = 'Get App / JS': Index,: application_name = & gt; However, it fails with:  
  ActionView :: missing template: missing template alarm_events / index {handlers = & gt; ; [: Builder ,: Hammal ,: ARB ,: RJS, RAMML] :: Local = & gt; [: N,: n] Regardless of this I have in my controller:  
  response_to: html ,: json def index @ alarm_events ============== ================================================== ============== <[...] respond_with @armarm_events do | Format | Format.json {Render: Jason = & gt; @arm_events.map {| E E.to_portal_representation} .to_json ,: content_type = & gt; 'Application / json'} End End   

How do I fork out the desired request on testcase?

This works fine when I request alarm_events.json in the browser.

thanks

format in the parameter for the action controller test Had to specify:

  get: index, {format: json}    

Comments