mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
Co-authored-by: Benjamin Scharf <bs@zammad.com> Co-authored-by: Dominik Klein <dk@zammad.com> Co-authored-by: Dusan Vuckovic <dv@zammad.com> Co-authored-by: Florian Liebe <fl@zammad.com> Co-authored-by: Mantas Masalskis <mm@zammad.com> Co-authored-by: Martin Gruner <mg@zammad.com> Co-authored-by: Tobias Schäfer <ts@zammad.com>
55 lines
1.6 KiB
Ruby
55 lines
1.6 KiB
Ruby
# Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe MicrosoftGraph::ApiError do
|
|
subject(:instance) { described_class.new(error_hash) }
|
|
|
|
let(:error_hash) do
|
|
{
|
|
code: 'badRequest',
|
|
message: 'Uploaded fragment overlaps with existing data.',
|
|
innerError: {
|
|
code: 'invalidRange',
|
|
'request-id': 'request-id',
|
|
date: 'date-time'
|
|
}
|
|
}
|
|
end
|
|
|
|
describe '#message' do
|
|
context 'with full error hash' do
|
|
it 'generates correct message' do
|
|
expect(instance.message).to eq("Uploaded fragment overlaps with existing data. (badRequest)\nMicrosoft Graph API Request ID: request-id")
|
|
end
|
|
end
|
|
|
|
context 'with incomplete error hash' do
|
|
let(:error_hash) do
|
|
{
|
|
message: 'Uploaded fragment overlaps with existing data.',
|
|
}
|
|
end
|
|
|
|
it 'generates correct message' do
|
|
expect(instance.message).to eq('Uploaded fragment overlaps with existing data. (no error code present)')
|
|
end
|
|
end
|
|
|
|
context 'without error hash' do
|
|
let(:error_hash) { {} }
|
|
|
|
it 'generates correct message' do
|
|
expect(instance.message).to eq('An unknown error occurred. (no error code present)')
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#inspect' do
|
|
it 'generates a correct object representation' do
|
|
expect(instance.inspect).to eq('#<MicrosoftGraph::ApiError: "Uploaded fragment overlaps with existing data. (badRequest)\\nMicrosoft Graph API Request ID: request-id">')
|
|
end
|
|
|
|
end
|
|
|
|
end
|