How to test after_sign_in_path_for(resource)?

后端 未结 5 988
日久生厌
日久生厌 2020-12-09 10:07

I have devise authentication and registration set up on my Rails app. I\'m using after_sign_in_path_for() to customise the redirect when the user signs in based

5条回答
  •  难免孤独
    2020-12-09 11:06

    For the newcomers, I would recommend doing this way:

    RSpec.describe ApplicationController, type: :controller do
      let(:user) { create :user }
    
      describe "After sing-in" do
        it "redirects to the /yourpath/ home page" do
          expect(subject.after_sign_in_path_for(user)).to eq(yourpath_root_path)
        end
      end
    end
    

提交回复
热议问题