2017-08-30 00:49:07 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Api::ApiController, type: :controller do
|
2018-08-17 22:13:21 +08:00
|
|
|
describe 'GET #health' do
|
|
|
|
before do
|
|
|
|
get :health
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Returns HTTP success and with correct text' do
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response.body).to match('RUNNING')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-30 00:49:07 +08:00
|
|
|
describe 'GET #status' do
|
|
|
|
before do
|
|
|
|
get :status
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Returns HTTP success' do
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Response with correct JSON status structure' do
|
|
|
|
hash_body = nil
|
|
|
|
expect { hash_body = json }.not_to raise_exception
|
2018-11-13 00:51:23 +08:00
|
|
|
expect(hash_body).to include(message: I18n.t('api.core.status_ok'))
|
2018-11-13 00:17:22 +08:00
|
|
|
expect(hash_body).to include('versions')
|
|
|
|
|
2018-11-13 00:51:23 +08:00
|
|
|
Extends::API_VERSIONS.each do |ver|
|
2018-11-13 00:17:22 +08:00
|
|
|
expect(hash_body['versions']).to include(
|
2018-11-13 00:51:23 +08:00
|
|
|
'version' => ver,
|
|
|
|
'baseUrl' => "/api/#{ver}/"
|
2018-11-13 00:17:22 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #health' do
|
|
|
|
before do
|
|
|
|
get :health
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Returns HTTP success' do
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'Response with the correct plain text' do
|
|
|
|
expect(response.body).to match('RUNNING')
|
2017-08-30 00:49:07 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|