ruby - Rails double render error for multithreading -
I want to test sign_in in train from different places at the same time, then I use multi threading in rspec Do:
Reference 'When multiple APIs were made at the same time' do this 'successfully sign_in' request.env ["devise.mapping"] = Devise.mappings [: user] Formula = thread [] 10.times & lt; & Lt; Thread.new post: Create, user: {email: user.email, password: user.password} end-end threads.each do | T | End end end t.join and above is the double error submission code:
AbstractController :: DoubleRenderError: submitted and / or redirected Many times, in this operation, please note that you can only call the render or redirect, and take action once per maximum. Also keep in mind that the execution of the operation does not end or be redirected, so if you want to exit any action after the redirect, then you have to do something like "redirect_to (...) and return" / Code> My Controller Code:
Creating DIF Resources = warden.authenticate (: scope => RESOURCE_NAME)! Return sign_in_and_redirect (RESOURCE_NAME, resource) end DEF sign_in_and_redirect (resource_or_scope, resource = zero) scope = will: :: Mapping.find_scope! (Resource_or_scope) resource || = Resource_or_scope sign_in (scope, resource) until warden.user (scope) == resources if user_signed_in? & Amp; & Amp; (Can not: see, my_app) sign_out render_ current render: position = & gt; 401 ,: JSON = & gt; {: Error = & gt; "Access denied." } And render: json = & gt; Current_user ,: location = & gt; After_sign_in_path_for (resource) end-end Tip 1. Works well for the timing Any idea why it complains about double render error for multithreading? Thank you.
the post test method does not use the full rack stack, this bus It is essential that what is required and the method calls on a controller example. For this kind of full-stack integration test - you probably want something like Karku - which runs the request in a separate thread from the web server (and to ensure that you have multiple server threads at one time You want a parallel test setup of some kind.) He said - I think that you are testing libraries and trains in this situation - none of them were the code written by you. Eding is likely to present the issues, so long as you do not have reason to believe that will Divi under such circumstances and rail have failed, so I'm not sure that test is really necessary.
Comments
Post a Comment