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 ...@@ -6,7 +6,7 @@ RSpec.describe Geo::ContainerRepositoryRegistry, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::ContainerRepositoryRegistry do 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end end
......
...@@ -6,7 +6,12 @@ RSpec.describe Geo::DesignRegistry, :geo do ...@@ -6,7 +6,12 @@ RSpec.describe Geo::DesignRegistry, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::DesignRegistry do 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end end
......
...@@ -6,7 +6,7 @@ RSpec.describe Geo::PackageFileRegistry, :geo, type: :model do ...@@ -6,7 +6,7 @@ RSpec.describe Geo::PackageFileRegistry, :geo, type: :model do
include ::EE::GeoHelpers include ::EE::GeoHelpers
it_behaves_like 'a BulkInsertSafe model', Geo::PackageFileRegistry do 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end end
......
...@@ -11,7 +11,12 @@ RSpec.describe Geo::ProjectRegistry, :geo do ...@@ -11,7 +11,12 @@ RSpec.describe Geo::ProjectRegistry, :geo do
subject { registry } subject { registry }
it_behaves_like 'a BulkInsertSafe model', Geo::ProjectRegistry do 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end end
......
...@@ -7,7 +7,12 @@ RSpec.describe MergeRequestDiffCommit do ...@@ -7,7 +7,12 @@ RSpec.describe MergeRequestDiffCommit do
let(:project) { merge_request.project } let(:project) { merge_request.project }
it_behaves_like 'a BulkInsertSafe model', MergeRequestDiffCommit do 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end end
......
...@@ -4,7 +4,12 @@ require 'spec_helper' ...@@ -4,7 +4,12 @@ require 'spec_helper'
RSpec.describe MergeRequestDiffFile do RSpec.describe MergeRequestDiffFile do
it_behaves_like 'a BulkInsertSafe model', 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 let(:invalid_items_for_bulk_insertion) { [] } # class does not have any validations defined
end 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