diff options
Diffstat (limited to 'spec/support')
3 files changed, 30 insertions, 3 deletions
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index 55aaadce97c..5e19043639d 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -9328,8 +9328,6 @@ - './spec/views/layouts/devise.html.haml_spec.rb' - './spec/views/layouts/_flash.html.haml_spec.rb' - './spec/views/layouts/fullscreen.html.haml_spec.rb' -- './spec/views/layouts/header/_gitlab_version.html.haml_spec.rb' -- './spec/views/layouts/header/_new_dropdown.haml_spec.rb' - './spec/views/layouts/_head.html.haml_spec.rb' - './spec/views/layouts/profile.html.haml_spec.rb' - './spec/views/layouts/_published_experiments.html.haml_spec.rb' diff --git a/spec/support/shared_contexts/services/service_ping/stubbed_service_ping_metrics_definitions_shared_context.rb b/spec/support/shared_contexts/services/service_ping/stubbed_service_ping_metrics_definitions_shared_context.rb index 24f0d22da47..b51c68f4958 100644 --- a/spec/support/shared_contexts/services/service_ping/stubbed_service_ping_metrics_definitions_shared_context.rb +++ b/spec/support/shared_contexts/services/service_ping/stubbed_service_ping_metrics_definitions_shared_context.rb @@ -50,7 +50,8 @@ RSpec.shared_context 'stubbed service ping metrics definitions' do 'value_type' => value_type, 'status' => status, 'instrumentation_class' => instrumentation_class, - 'time_frame' => 'all' + 'time_frame' => 'all', + 'data_source' => 'redis_hll' } end end diff --git a/spec/support/shared_examples/models/disable_sti_shared_examples.rb b/spec/support/shared_examples/models/disable_sti_shared_examples.rb new file mode 100644 index 00000000000..090592827d1 --- /dev/null +++ b/spec/support/shared_examples/models/disable_sti_shared_examples.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Checks whether STI is disabled in +models+. +# +# Parameter: +# - models: List of model classes +RSpec.shared_examples 'Model disables STI' do + skip_sti_check = Gitlab::Utils.to_boolean(ENV['SKIP_STI_CHECK'], default: false) + + it 'does not allow STI', :aggregate_failures, unless: skip_sti_check do + models.each do |model| + next unless model + next unless model < ApplicationRecord + next if model == model.base_class + next if model.allow_legacy_sti_class + + expect(model).not_to have_attribute(model.inheritance_column), + "Do not use Single Table Inheritance (`#{model.name}` inherits `#{model.base_class.name}`). " \ + "See https://docs.gitlab.com/ee/development/database/single_table_inheritance.html" + end + end +end + +RSpec.shared_examples 'STI disabled', type: :model do # rubocop:disable RSpec/SharedGroupsMetadata -- Shared example is run within every spec tagged `type: :model` + include_examples 'Model disables STI' do + let(:models) { [described_class] } + end +end |