Class: AuthTokenableTest
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- AuthTokenableTest
- Includes:
- Rack::Test::Methods
- Defined in:
- lib/tests/controllers/auth_tokenable_test.rb
Instance Method Summary collapse
- #app ⇒ Object
- #setup ⇒ Object
- #test_test_controller_auth_tokenable ⇒ Object
- #test_test_controller_authenticated_custom_model ⇒ Object
- #test_test_controller_included_auth_tokenable_unauthenticated_custom_model ⇒ Object
- #test_test_controller_tokenable_authenticated ⇒ Object
Instance Method Details
#app ⇒ Object
54 55 56 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 54 def app Rubee::Application.instance end |
#setup ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 58 def setup Rubee::Autoload.call Rubee::Router.draw do |route| route.post('/test/login', to: 'test#login') route.post('/test/logout', to: 'test#logout') route.get('/test/show', to: 'test#show') route.post('/testtwo/login', to: 'testtwo#login') route.post('/testtwo/logout', to: 'testtwo#logout') route.get('/testtwo/show', to: 'testtwo#show') end User.create(email: '9oU8S@example.com', password: '123456') Client.create(name: '9o@example.com', digest_password: '123456') end |
#test_test_controller_auth_tokenable ⇒ Object
72 73 74 75 76 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 72 def test_test_controller_auth_tokenable get('/test/show') assert_equal(last_response.status, 401) end |
#test_test_controller_authenticated_custom_model ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 92 def test_test_controller_authenticated_custom_model post('/testtwo/login', { name: '9o@example.com', digest_password: '123456' }) rack_mock_session.["jwt"] = last_response.["jwt"].value.last get('/testtwo/show') assert_equal(last_response.status, 200) end |
#test_test_controller_included_auth_tokenable_unauthenticated_custom_model ⇒ Object
86 87 88 89 90 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 86 def test_test_controller_included_auth_tokenable_unauthenticated_custom_model get('/testtwo/show') assert_equal(last_response.status, 401) end |
#test_test_controller_tokenable_authenticated ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/tests/controllers/auth_tokenable_test.rb', line 78 def test_test_controller_tokenable_authenticated post('/test/login', { email: '9oU8S@example.com', password: '123456' }) rack_mock_session.["jwt"] = last_response.["jwt"].value.last get('/test/show') assert_equal(last_response.status, 200) end |