How do I set HTTP_REFERER when testing in Rails?

后端 未结 7 1293
我在风中等你
我在风中等你 2020-12-05 22:12

I\'m trying to test a controller and I got this error. I understand the error, but don\'t know how to fix it.

test: on CREATE to :user with completely invali         


        
7条回答
  •  抹茶落季
    2020-12-05 22:54

    Most straight forward solution to the above problem is to make the request with associated headers. Rails will automatically read this header.

    post '/your-custom-route', {}, {'HTTP_REFERER': 'http://www.your-allowed-domain.com'}
    

提交回复
热议问题