Setup tokens controller
This commit is contained in:
parent
f8aae15cdc
commit
2753b9f6c8
6 changed files with 58 additions and 1 deletions
20
test/controllers/api/v1/tokens_controller_test.rb
Normal file
20
test/controllers/api/v1/tokens_controller_test.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require "test_helper"
|
||||
|
||||
class Api::V1::TokensControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:one)
|
||||
end
|
||||
|
||||
test 'should get JWT token' do
|
||||
post api_v1_tokens_url, params: { user: { email: @user.email, password: 'g00d_pa$$' } }, as: :json
|
||||
assert_response :success
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
assert_not_nil json_response['token']
|
||||
end
|
||||
|
||||
test 'should not get JWT token' do
|
||||
post api_v1_tokens_url, params: { user: { email: @user.email, password: 'b@d_pa$$' } }, as: :json
|
||||
assert_response :unauthorized
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue