How to sign_in for Devise to Test Controller with Minitest

前端 未结 2 1289
慢半拍i
慢半拍i 2021-01-05 16:54

I\'m newbie to Rails Testing.

After following some tutorial online, I could able to setup and run testing for Model.

But when trying to test for Cont

2条回答
  •  生来不讨喜
    2021-01-05 17:42

    From integration_helpers.rb, for example:

    class PostsTest < ActionDispatch::IntegrationTest
      include Devise::Test::IntegrationHelpers
    
      test 'authenticated users can see posts' do
        sign_in users(:bob)
    
        get '/posts'
        assert_response :success
      end
    end
    

提交回复
热议问题