start_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Mutations::System::Import::Start, type: :graphql do
  4. context 'when starting system import' do
  5. let(:mutation) do
  6. <<~MUTATION
  7. mutation systemImportStart {
  8. systemImportStart {
  9. success
  10. errors {
  11. message
  12. field
  13. }
  14. }
  15. }
  16. MUTATION
  17. end
  18. context 'with missing configuration' do
  19. it 'raises an error' do
  20. gql.execute(mutation)
  21. expect { gql.result.data }.to raise_error(RuntimeError, %r{Please configure import source before running\.})
  22. end
  23. end
  24. context 'with valid configuration' do
  25. it 'succeeds' do
  26. allow_any_instance_of(Service::System::Import::Run).to receive(:execute).and_return(nil)
  27. Setting.set('import_backend', 'otrs')
  28. gql.execute(mutation)
  29. expect(gql.result.data).to include({ 'success' => true })
  30. end
  31. end
  32. end
  33. end