Commit 102e6582 authored by James Lopez's avatar James Lopez

Merge branch 'provide-persisted-models-for-bulk-insert-specs' into 'master'

Provide persisted models for bulk insert specs to support parent strategy

See merge request gitlab-org/gitlab!41766
parents a4fe586d 217919fe
......@@ -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