diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-27 18:06:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-27 18:06:55 +0300 |
commit | 0847321aeec58e8885c18b64abd6732581ec33a4 (patch) | |
tree | 28a518bbc4b15f28e3cdd1a26814affd3b13aa57 /spec/rubocop | |
parent | 274a42ccfaa22f6d6bc2d21da0c891bae15d3508 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/search/avoid_checking_finished_on_deprecated_migrations_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/rubocop/cop/search/avoid_checking_finished_on_deprecated_migrations_spec.rb b/spec/rubocop/cop/search/avoid_checking_finished_on_deprecated_migrations_spec.rb new file mode 100644 index 00000000000..9853423e758 --- /dev/null +++ b/spec/rubocop/cop/search/avoid_checking_finished_on_deprecated_migrations_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' +require_relative '../../../../rubocop/cop/search/avoid_checking_finished_on_deprecated_migrations' + +RSpec.describe RuboCop::Cop::Search::AvoidCheckingFinishedOnDeprecatedMigrations, feature_category: :global_search do + context 'when a deprecated class is used with migration_has_finished?' do + it 'flags it as an offense' do + expect_offense <<~SOURCE + return if Elastic::DataMigrationService.migration_has_finished?(:backfill_project_permissions_in_blobs_using_permutations) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Migration is deprecated and can not be used with `migration_has_finished?`. + SOURCE + end + end + + context 'when a non deprecated class is used with migration_has_finished?' do + it 'does not flag it as an offense' do + expect_no_offenses <<~SOURCE + return if Elastic::DataMigrationService.migration_has_finished?(:backfill_project_permissions_in_blobs) + SOURCE + end + end + + context 'when migration_has_finished? method is called on another class' do + it 'does not flag it as an offense' do + expect_no_offenses <<~SOURCE + return if Klass.migration_has_finished?(:backfill_project_permissions_in_blobs_using_permutations) + SOURCE + end + end +end |