Welcome to mirror list, hosted at ThFree Co, Russian Federation.

entity_failure_spec.rb « bulk_imports « entities « api « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20563bfb685b2d8cf8b1eacf9e0c263677206149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe API::Entities::BulkImports::EntityFailure, feature_category: :importers do
  let_it_be(:failure) { create(:bulk_import_failure) }

  subject { described_class.new(failure).as_json }

  it 'has the correct attributes' do
    expect(subject).to include(
      :relation,
      :exception_message,
      :exception_class,
      :correlation_id_value,
      :source_url,
      :source_title
    )
  end

  describe 'exception message' do
    it 'truncates exception message to 255 characters' do
      failure.update!(exception_message: 'a' * 500)

      expect(subject[:exception_message].length).to eq(255)
    end

    it 'removes paths from the message' do
      failure.update!(exception_message: 'Test /foo/bar')

      expect(subject[:exception_message]).to eq('Test [FILTERED]')
    end

    it 'removes long paths without clipping the message' do
      exception_message = "Test #{'/abc' * 300} #{'a' * 500}"
      failure.update!(exception_message: exception_message)
      filtered_message = "Test [FILTERED] #{'a' * 500}"

      expect(subject[:exception_message]).to eq(filtered_message.truncate(255))
    end
  end
end