How to write controller tests when you override devise registration controller?

The problem is that Devise is unable to map routes from the test back to the original controller. That means that while your app actually works fine if you open it in the browser, your controller tests will still fail.

The solution is to add the devise mapping to the request before each test like so:

before :each do
  request.env['devise.mapping'] = Devise.mappings[:user]
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)