info_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Queries::System::Setup::Info, :aggregate_failures, type: :graphql do
  4. context 'when quering system setup' do
  5. let(:query) do
  6. <<~QUERY
  7. query systemSetupInfo {
  8. systemSetupInfo {
  9. status
  10. type
  11. }
  12. }
  13. QUERY
  14. end
  15. context 'with a valid state' do
  16. it 'returns a string' do
  17. gql.execute(query)
  18. expect(gql.result.data['status']).to be_a(String)
  19. expect(gql.result.data['type']).to be_nil
  20. end
  21. end
  22. context 'with an invalid state' do
  23. before do
  24. allow(Service::System::CheckSetup).to receive(:new).and_return(
  25. instance_double(
  26. Service::System::CheckSetup,
  27. execute: nil,
  28. status: 'failed',
  29. type: nil
  30. )
  31. )
  32. end
  33. it 'raises an error' do
  34. gql.execute(query)
  35. expect { gql.result.data }.to raise_error(RuntimeError)
  36. end
  37. end
  38. end
  39. end