From 30a3bc29d26b128cf8aec357a2cb0231dae7c465 Mon Sep 17 00:00:00 2001
From: Arturo Herrero <arturo.herrero@gmail.com>
Date: Tue, 25 Feb 2025 17:06:20 +0100
Subject: [PATCH] Fix Rubocop offense for elastic shared examples

EE: true
---
 .rubocop_todo/rspec/receive_messages.yml       |  1 -
 .../elastic/migration_shared_examples.rb       | 18 ++++++------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/.rubocop_todo/rspec/receive_messages.yml b/.rubocop_todo/rspec/receive_messages.yml
index cfbbb490307c9..2eeb197f8c0ee 100644
--- a/.rubocop_todo/rspec/receive_messages.yml
+++ b/.rubocop_todo/rspec/receive_messages.yml
@@ -169,7 +169,6 @@ RSpec/ReceiveMessages:
     - 'ee/spec/support/shared_contexts/requests/api/graphql/security_orchestration/policies_shared_contexts.rb'
     - 'ee/spec/support/shared_contexts/secrets_check_shared_contexts.rb'
     - 'ee/spec/support/shared_examples/controllers/namespace_storage_limit_alert_shared_examples.rb'
-    - 'ee/spec/support/shared_examples/elastic/migration_shared_examples.rb'
     - 'ee/spec/support/shared_examples/graphql/mutations/work_items/update_status_widget_shared_examples.rb'
     - 'ee/spec/support/shared_examples/graphql/mutations/work_items/update_weight_widget_shared_examples.rb'
     - 'ee/spec/support/shared_examples/graphql/resolvers/security_orchestration/resolves_orchestration_policy_shared_examples.rb'
diff --git a/ee/spec/support/shared_examples/elastic/migration_shared_examples.rb b/ee/spec/support/shared_examples/elastic/migration_shared_examples.rb
index a9fe136368f67..77dfc03be6478 100644
--- a/ee/spec/support/shared_examples/elastic/migration_shared_examples.rb
+++ b/ee/spec/support/shared_examples/elastic/migration_shared_examples.rb
@@ -71,8 +71,7 @@
       end
 
       it 'processes in batches', :aggregate_failures do
-        allow(migration).to receive(:batch_size).and_return(2)
-        allow(migration).to receive(:update_batch_size).and_return(1)
+        allow(migration).to receive_messages(batch_size: 2, update_batch_size: 1)
 
         expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).exactly(3).times.and_call_original
 
@@ -272,8 +271,7 @@ def update_by_query(objects, script)
       end
 
       it 'processes in batches', :aggregate_failures do
-        allow(migration).to receive(:batch_size).and_return(2)
-        allow(migration).to receive(:update_batch_size).and_return(1)
+        allow(migration).to receive_messages(batch_size: 2, update_batch_size: 1)
 
         expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).exactly(3).times.and_call_original
 
@@ -434,8 +432,7 @@ def assert_objects_have_new_schema_version(objects, schema_version = described_c
     describe 'reindexing_cleanup!' do
       context 'when the index already exists' do
         before do
-          allow(helper).to receive(:index_exists?).and_return(true)
-          allow(helper).to receive(:create_standalone_indices).and_return(true)
+          allow(helper).to receive_messages(index_exists?: true, create_standalone_indices: true)
         end
 
         it 'deletes the index' do
@@ -594,8 +591,7 @@ def assert_objects_have_new_schema_version(objects, schema_version = described_c
       end
 
       it 'processes in batches', :aggregate_failures do
-        allow(migration).to receive(:batch_size).and_return(1)
-        allow(migration).to receive(:limit_per_iteration).and_return(1)
+        allow(migration).to receive_messages(batch_size: 1, limit_per_iteration: 1)
 
         expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!)
           .exactly(objects.size).times.and_call_original
@@ -646,8 +642,7 @@ def assert_objects_have_new_schema_version(objects, schema_version = described_c
   before do
     stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
     set_elasticsearch_migration_to(version, including: false)
-    allow(migration).to receive(:helper).and_return(helper)
-    allow(migration).to receive(:client).and_return(client)
+    allow(migration).to receive_messages(helper: helper, client: client)
 
     # ensure objects are indexed
     objects
@@ -720,8 +715,7 @@ def assert_objects_have_new_schema_version(objects, schema_version = described_c
 
       context 'when task in progress' do
         before do
-          allow(migration).to receive(:completed?).and_return(false)
-          allow(migration).to receive(:client).and_return(client)
+          allow(migration).to receive_messages(completed?: false, client: client)
           allow(helper).to receive(:task_status).and_return('completed' => false)
           migration.set_migration_state(task_id: 'task_1')
         end
-- 
GitLab