README.md in devise-4.6.1 vs README.md in devise-4.6.2

- old
+ new

@@ -54,10 +54,11 @@ - [OmniAuth](#omniauth) - [Configuring multiple models](#configuring-multiple-models) - [ActiveJob Integration](#activejob-integration) - [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs) - [Other ORMs](#other-orms) + - [Rails API mode](#rails-api-mode) - [Additional information](#additional-information) - [Heroku](#heroku) - [Warden](#warden) - [Contributors](#contributors) - [License](#license) @@ -617,11 +618,11 @@ `devise.mapping` `env` value, as the mapping can be inferred by the routes that are executed in your tests. You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki: -* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29 +* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec) ### OmniAuth Devise comes with OmniAuth support out of the box to authenticate with other providers. To use it, simply specify your OmniAuth configuration in `config/initializers/devise.rb`: @@ -691,9 +692,20 @@ ### Other ORMs Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file. + +### Rails API Mode + +Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb: + +```ruby +Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies +Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore +``` + +For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696). ## Additional information ### Heroku