The following error came out when I planned and spun the test as a mini test in Rail.
Minitest::UnexpectedError: AbstractController::DoubleRenderError: Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".
How should I resolve and test the above errors?
What I wanted to test was a simple alternator test as below.
class UsersControllerTest < ActionController::TestCase
test 'You can bring your self-introduction' do
get :info, format: :js
assert_response :success
end
end
Actual controller
class UsersController < ApplicationController
def info
end
end
link_to('information', info_user_url, remote: true)
Put the link in the same way as above and click on the link, info.js.I can see the coffee view well. There is an error only in the test.
ruby-on-rails minitest testing
See http://guides.rubyonrails.org/layouts_and_rendering.html#avoiding-double-render-errors.
I think an error occurs when the view is rendered more than once...
If the error occurs only in the test, refer to the following link. http://stackoverflow.com/questions/4291755/rspec-test-of-custom-devise-session-controller-fails-with-abstractcontrollerac
It was solved using Devise::TestHelpers.
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
include Devise::TestHelpers
test 'You can bring your self-introduction' do
setup_controller_for_warden # This and
request.env["device.mapping"] = Device.mapping[:user] # Add this part
get :info, format: :js
assert_response :success
end
end
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
581 PHP ssh2_scp_send fails to send files as intended
578 Understanding How to Configure Google API Key
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.