sla_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. require 'rails_helper'
  2. RSpec.describe 'SLAs', type: :request do
  3. let(:admin) do
  4. create(:admin)
  5. end
  6. describe 'request handling' do
  7. it 'does index sla with nobody' do
  8. get '/api/v1/slas', as: :json
  9. expect(response).to have_http_status(:forbidden)
  10. expect(json_response).to be_a_kind_of(Hash)
  11. expect(json_response['error']).to eq('Authentication required')
  12. end
  13. it 'does index sla with admin' do
  14. authenticated_as(admin)
  15. get '/api/v1/slas', as: :json
  16. expect(response).to have_http_status(:ok)
  17. expect(json_response).to be_a_kind_of(Array)
  18. expect(json_response).to be_truthy
  19. expect(json_response.count).to eq(0)
  20. get '/api/v1/slas?expand=true', as: :json
  21. expect(response).to have_http_status(:ok)
  22. expect(json_response).to be_a_kind_of(Array)
  23. expect(json_response).to be_truthy
  24. expect(json_response.count).to eq(0)
  25. get '/api/v1/slas?full=true', as: :json
  26. expect(response).to have_http_status(:ok)
  27. expect(json_response).to be_a_kind_of(Hash)
  28. expect(json_response).to be_truthy
  29. expect(json_response['record_ids']).to be_truthy
  30. expect(json_response['record_ids']).to be_blank
  31. expect(json_response['assets']).to be_truthy
  32. expect(json_response['assets']['Calendar']).to be_present
  33. expect(json_response['assets']).to be_present
  34. end
  35. end
  36. end