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

database_helpers_spec.rb « import « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05d1c0ae078858139131cc9d13597e5868c22d64 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Import::DatabaseHelpers do
  let(:database_helper) do
    Class.new do
      include Gitlab::Import::DatabaseHelpers
    end
  end

  subject { database_helper.new }

  describe '.insert_and_return_id' do
    let(:attributes) { { iid: 1, title: 'foo' } }
    let(:project) { create(:project) }

    it 'returns the ID returned by the query' do
      expect(ApplicationRecord)
        .to receive(:legacy_bulk_insert)
        .with(Issue.table_name, [attributes], return_ids: true)
        .and_return([10])

      id = subject.insert_and_return_id(attributes, project.issues)

      expect(id).to eq(10)
    end
  end
end