2018-09-19 13:54:49 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'SLAs', type: :request do
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
let(:admin) do
|
|
|
|
create(:admin)
|
2018-09-19 13:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'request handling' do
|
|
|
|
|
|
|
|
it 'does index sla with nobody' do
|
|
|
|
get '/api/v1/slas', as: :json
|
2021-02-04 08:28:41 +00:00
|
|
|
expect(response).to have_http_status(:forbidden)
|
2018-09-19 13:54:49 +00:00
|
|
|
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
2021-02-04 08:28:41 +00:00
|
|
|
expect(json_response['error']).to eq('Authentication required')
|
2018-09-19 13:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does index sla with admin' do
|
2020-06-19 09:17:18 +00:00
|
|
|
authenticated_as(admin)
|
2018-09-19 13:54:49 +00:00
|
|
|
get '/api/v1/slas', as: :json
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Array)
|
|
|
|
expect(json_response).to be_truthy
|
|
|
|
expect(json_response.count).to eq(0)
|
|
|
|
|
|
|
|
get '/api/v1/slas?expand=true', as: :json
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Array)
|
|
|
|
expect(json_response).to be_truthy
|
|
|
|
expect(json_response.count).to eq(0)
|
|
|
|
|
|
|
|
get '/api/v1/slas?full=true', as: :json
|
2019-04-15 01:41:17 +00:00
|
|
|
expect(response).to have_http_status(:ok)
|
2018-09-19 13:54:49 +00:00
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response).to be_truthy
|
|
|
|
expect(json_response['record_ids']).to be_truthy
|
|
|
|
expect(json_response['record_ids']).to be_blank
|
|
|
|
expect(json_response['assets']).to be_truthy
|
|
|
|
expect(json_response['assets']['Calendar']).to be_present
|
|
|
|
expect(json_response['assets']).to be_present
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|