API de comptabilité horaire.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

tokens_controller_test.rb 666B

12345678910111213141516171819202122
  1. require "test_helper"
  2. class Api::V1::TokensControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @user = users(:one)
  5. end
  6. test 'should get JWT token' do
  7. post api_v1_tokens_url, params: { user: { email: @user.email, password: 'g00d_pa$$' } }, as: :json
  8. assert_response :success
  9. json_response = JSON.parse(response.body)
  10. assert_not_nil json_response['token']
  11. assert_not_nil json_response['email']
  12. assert_not_nil json_response['username']
  13. end
  14. test 'should not get JWT token' do
  15. post api_v1_tokens_url, params: { user: { email: @user.email, password: 'b@d_pa$$' } }, as: :json
  16. assert_response :unauthorized
  17. end
  18. end