Commit 217919fe authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Eugenia Grieff

Provide persisted models for bulk insert specs

This basically mimics previous behavior where assocations are persisted
when doing a `build`
parent 29ac2713
......@@ -6,7 +6,7 @@ RSpec.describe Geo::ContainerRepositoryRegistry, :geo do
include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::ContainerRepositoryRegistry do
let(:valid_items_for_bulk_insertion) { build_list(:container_repository_registry, 10, created_at: Time.zone.now) }
let(:valid_items_for_bulk_insertion) { build_list(:container_repository_registry, 10, container_repository: create(:container_repository), created_at: Time.zone.now) }
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
......@@ -6,7 +6,12 @@ RSpec.describe Geo::DesignRegistry, :geo do
include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::DesignRegistry do
let(:valid_items_for_bulk_insertion) { build_list(:geo_design_registry, 10, created_at: Time.zone.now) }
let(:valid_items_for_bulk_insertion) do
build_list(:geo_design_registry, 10, created_at: Time.zone.now) do |registry|
registry.project = create(:project)
end
end
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
......@@ -6,7 +6,7 @@ RSpec.describe Geo::PackageFileRegistry, :geo, type: :model do
include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::PackageFileRegistry do
let(:valid_items_for_bulk_insertion) { build_list(:geo_package_file_registry, 10, created_at: Time.zone.now) }
let(:valid_items_for_bulk_insertion) { build_list(:geo_package_file_registry, 10, package_file: create(:package_file, :npm), created_at: Time.zone.now) }
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
......@@ -11,7 +11,12 @@ RSpec.describe Geo::ProjectRegistry, :geo do
subject { registry }
it_behaves_like 'a BulkInsertSafe model', Geo::ProjectRegistry do
let(:valid_items_for_bulk_insertion) { build_list(:geo_project_registry, 10, created_at: Time.zone.now) }
let(:valid_items_for_bulk_insertion) do
build_list(:geo_project_registry, 10, created_at: Time.zone.now) do |registry|
registry.project = create(:project)
end
end
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
......@@ -7,7 +7,12 @@ RSpec.describe MergeRequestDiffCommit do
let(:project) { merge_request.project }
it_behaves_like 'a BulkInsertSafe model', MergeRequestDiffCommit do
let(:valid_items_for_bulk_insertion) { build_list(:merge_request_diff_commit, 10) }
let(:valid_items_for_bulk_insertion) do
build_list(:merge_request_diff_commit, 10) do |mr_diff_commit|
mr_diff_commit.merge_request_diff = create(:merge_request_diff)
end
end
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
......@@ -4,7 +4,12 @@ require 'spec_helper'
RSpec.describe MergeRequestDiffFile do
it_behaves_like 'a BulkInsertSafe model', MergeRequestDiffFile do
let(:valid_items_for_bulk_insertion) { build_list(:merge_request_diff_file, 10) }
let(:valid_items_for_bulk_insertion) do
build_list(:merge_request_diff_file, 10) do |mr_diff_file|
mr_diff_file.merge_request_diff = create(:merge_request_diff)
end
end
let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment