sla_spec.rb 1.4 KB

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