permission_present_spec.rb 1004 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Sequencer::Unit::Freshdesk::PermissionPresent, sequencer: :unit do
  4. context 'when checking the permission to Freshdesk' do
  5. let(:params) do
  6. {
  7. dry_run: false,
  8. import_job: instance_double(ImportJob),
  9. field_map: {},
  10. id_map: {},
  11. }
  12. end
  13. let(:response_ok) { Net::HTTPOK.new(1.0, '200', 'OK') }
  14. let(:response_forbidden) { Net::HTTPForbidden.new(1.0, '403', 'Forbidden') }
  15. it 'check for correct permission' do
  16. allow(described_class).to receive(:perform_request).with(any_args).and_return(response_ok)
  17. expect(process(params)).to eq({ permission_present: true })
  18. end
  19. it 'check for forbidden permission' do
  20. allow(described_class).to receive(:perform_request).with(any_args).and_return(response_forbidden)
  21. expect(process(params)).to eq({ permission_present: false })
  22. end
  23. end
  24. end