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.
pgfqe6ch8/test/mobile/auth_test.rb

25 lines
653 B

require File.expand_path('../../test_helper.rb',__FILE__)
class AuthTest < ActionDispatch::IntegrationTest
def setup
ApiKey.delete_all
end
test "login success when use correct password" do
post('/api/v1/auth/login.json', {login: 'guange', password: '123456'})
o = ActiveSupport::JSON.decode response.body
puts o
puts o["token"]
assert_not_nil o["token"]
end
test "login failure when incorrect password" do
post('/api/v1/auth/login.json', {login: 'guange', password: 'wrongpass'})
o = ActiveSupport::JSON.decode response.body
assert_nil o["token"]
assert_equal o["error"], 'Unauthorized.'
end
end