import_freshdesk_spec.rb 844 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'ImportFreshdesk', authenticated_as: false, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN], set_up: false, type: :request do
  4. let(:action) { nil }
  5. let(:endpoint) { "/api/v1/import/freshdesk/#{action}" }
  6. describe 'POST /api/v1/import/freshdesk/url_check', :use_vcr do
  7. let(:action) { 'url_check' }
  8. it 'check invalid subdomain' do
  9. post endpoint, params: { url: 'https://reallybadexample.freshdesk.com' }, as: :json
  10. expect(json_response['result']).to eq('invalid')
  11. end
  12. it 'check valid subdomain' do
  13. post endpoint, params: { url: "https://#{ENV['IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN']}.freshdesk.com" }, as: :json
  14. expect(json_response['result']).to eq('ok')
  15. end
  16. end
  17. end