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

batch_tracker_spec.rb « bulk_imports « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c7cbc0cb8c4cc133056abe161cca992719f3fcf (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe BulkImports::BatchTracker, type: :model, feature_category: :importers do
  describe 'associations' do
    it { is_expected.to belong_to(:tracker) }
  end

  describe 'validations' do
    subject { build(:bulk_import_batch_tracker) }

    it { is_expected.to validate_presence_of(:batch_number) }
    it { is_expected.to validate_uniqueness_of(:batch_number).scoped_to(:tracker_id) }
  end

  describe 'scopes' do
    describe '.in_progress' do
      it 'returns only batches that are in progress' do
        created = create(:bulk_import_batch_tracker, :created)
        started = create(:bulk_import_batch_tracker, :started)
        create(:bulk_import_batch_tracker, :finished)
        create(:bulk_import_batch_tracker, :timeout)
        create(:bulk_import_batch_tracker, :failed)
        create(:bulk_import_batch_tracker, :skipped)

        expect(described_class.in_progress).to contain_exactly(created, started)
      end
    end
  end
end