mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 00:11:22 +08:00
Add unit tests for status/health API endpoints
Closes [SCI-2746].
This commit is contained in:
parent
a857af6c38
commit
1c08aa6a8b
1 changed files with 25 additions and 6 deletions
|
|
@ -14,11 +14,30 @@ describe Api::ApiController, type: :controller do
|
||||||
it 'Response with correct JSON status structure' do
|
it 'Response with correct JSON status structure' do
|
||||||
hash_body = nil
|
hash_body = nil
|
||||||
expect{hash_body = json}.not_to raise_exception
|
expect{hash_body = json}.not_to raise_exception
|
||||||
expect(hash_body).to match(
|
expect(hash_body).to include(:message => I18n.t('api.core.status_ok'))
|
||||||
'message' => I18n.t('api.core.status_ok'),
|
expect(hash_body).to include('versions')
|
||||||
'versions' => [{ 'version' => 'v1',
|
|
||||||
'baseUrl' => '/api/v1/' }]
|
Extends::API_VERSIONS.each_with_index do |ver, index|
|
||||||
|
expect(hash_body['versions']).to include(
|
||||||
|
{ 'version' => ver,
|
||||||
|
'baseUrl' => "/api/#{ver}/" }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
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')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue