API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526
  1. class MockController
  2. include Authenticable
  3. attr_accessor :request
  4. def initialize
  5. mock_request = Struct.new(:headers)
  6. self.request = mock_request.new({})
  7. end
  8. end
  9. class AuthenticableTest < ActionDispatch::IntegrationTest
  10. setup do
  11. @user = users(:one)
  12. @authentication = MockController.new
  13. end
  14. test 'should get user from Authorization token' do
  15. @authentication.request.headers['Authorization'] = JsonWebToken.encode(user_id: @user.id)
  16. assert_equal @user.id, @authentication.current_user.id
  17. end
  18. test 'should not get user from empty Authorization token' do
  19. @authentication.request.headers['Authorization'] = nil
  20. assert_nil @authentication.current_user
  21. end
  22. end