debian-mirror-gitlab/spec/lib/gitlab/import/database_helpers_spec.rb

30 lines
691 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Import::DatabaseHelpers do
2018-11-20 20:47:30 +05:30
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) }
2019-10-12 21:52:04 +05:30
it 'returns the ID returned by the query' do
expect(Gitlab::Database)
.to receive(:bulk_insert)
.with(Issue.table_name, [attributes], return_ids: true)
.and_return([10])
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
id = subject.insert_and_return_id(attributes, project.issues)
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
expect(id).to eq(10)
2018-11-20 20:47:30 +05:30
end
end
end