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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/concerns/ci/partitionable/switch_spec.rb')
-rw-r--r--spec/models/concerns/ci/partitionable/switch_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/concerns/ci/partitionable/switch_spec.rb b/spec/models/concerns/ci/partitionable/switch_spec.rb
index 551ae111fa4..4aaf69bb585 100644
--- a/spec/models/concerns/ci/partitionable/switch_spec.rb
+++ b/spec/models/concerns/ci/partitionable/switch_spec.rb
@@ -38,6 +38,7 @@ RSpec.describe Ci::Partitionable::Switch, :aggregate_failures do
id serial NOT NULL PRIMARY KEY,
job_id int,
partition_id int NOT NULL DEFAULT 1,
+ type text,
expanded_environment_name text);
CREATE TABLE _test_p_ci_jobs_metadata (
@@ -89,6 +90,25 @@ RSpec.describe Ci::Partitionable::Switch, :aggregate_failures do
it { expect(partitioned_model.sequence_name).to eq('_test_ci_jobs_metadata_id_seq') }
+ context 'with singe table inheritance' do
+ let(:child_model) do
+ Class.new(model) do
+ def self.name
+ 'TestSwitchJobMetadataChild'
+ end
+ end
+ end
+
+ it 'adds a Partitioned model for each descendant' do
+ expect(model::Partitioned).not_to eq(child_model::Partitioned)
+ end
+
+ it 'uses the parent name in STI queries' do
+ recorder = ActiveRecord::QueryRecorder.new { child_model.all.load }
+ expect(recorder.log).to include(/"type" = 'TestSwitchJobMetadataChild'/)
+ end
+ end
+
context 'when switching the tables' do
before do
stub_feature_flags(table_rollout_flag => false)