diff --git a/Gemfile.lock b/Gemfile.lock index b74f4e1fa..8539a9170 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -327,7 +327,7 @@ GEM paper_trail (17.0.0) activerecord (>= 7.1) request_store (~> 1.4) - parallel (2.2.0) + parallel (2.3.0) parser (3.3.12.0) ast (~> 2.4.1) racc @@ -421,7 +421,7 @@ GEM prism (>= 1.6.0) rbs (>= 4.0.0) tsort - regexp_parser (2.13.0) + regexp_parser (2.13.1) reline (0.7.0) io-console (~> 0.5) request_store (1.7.0) @@ -487,9 +487,9 @@ GEM lint_roller (~> 1.1) regexp_parser (>= 2.0) rubocop (~> 1.86, >= 1.86.2) - rubocop-rspec_rails (2.32.0) + rubocop-rspec_rails (2.33.0) lint_roller (~> 1.1) - rubocop (~> 1.72, >= 1.72.1) + rubocop (~> 1.89) rubocop-rspec (~> 3.5) ruby-lsp (0.26.11) language_server-protocol (~> 3.17.0) diff --git a/spec/concepts/school/import_batch_spec.rb b/spec/concepts/school/import_batch_spec.rb index 759c4d18f..63234238d 100644 --- a/spec/concepts/school/import_batch_spec.rb +++ b/spec/concepts/school/import_batch_spec.rb @@ -14,34 +14,27 @@ end let(:csv_file) { StringIO.new(csv_content) } - before do - allow(SchoolImportJob).to receive(:perform_later).and_return( - instance_double(SchoolImportJob, job_id: 'test-job-id') - ) - end - context 'with valid CSV' do it 'returns success response with job_id' do result = described_class.call(csv_file: csv_file, current_user: current_user) expect(result.success?).to be true - expect(result[:job_id]).to eq('test-job-id') + expect(result[:job_id]).to be_present expect(result[:total_schools]).to eq(2) end it 'enqueues SchoolImportJob' do - described_class.call(csv_file: csv_file, current_user: current_user) - - expect(SchoolImportJob).to have_received(:perform_later).with( - hash_including( - schools_data: array_including( - hash_including(name: 'Test School 1'), - hash_including(name: 'Test School 2') - ), - user_id: current_user.id, - token: current_user.token + expect { described_class.call(csv_file: csv_file, current_user: current_user) } + .to have_enqueued_job(SchoolImportJob).with( + hash_including( + schools_data: array_including( + hash_including(name: 'Test School 1'), + hash_including(name: 'Test School 2') + ), + user_id: current_user.id, + token: current_user.token + ) ) - ) end end diff --git a/spec/requests/github_webhooks/github_webhooks_controller_push_spec.rb b/spec/requests/github_webhooks/github_webhooks_controller_push_spec.rb index fc41fd7a0..298ba6872 100644 --- a/spec/requests/github_webhooks/github_webhooks_controller_push_spec.rb +++ b/spec/requests/github_webhooks/github_webhooks_controller_push_spec.rb @@ -24,14 +24,11 @@ } end - before do - allow(UploadJob).to receive(:perform_later) - post '/github_webhooks', env: { RAW_POST_DATA: params.to_json }, headers: - end + let(:post_webhook) { post '/github_webhooks', env: { RAW_POST_DATA: params.to_json }, headers: } shared_examples 'upload job' do it 'schedules the job' do - expect(UploadJob).to have_received(:perform_later).with(params) + expect { post_webhook }.to have_enqueued_job(UploadJob).with(params) end end @@ -60,7 +57,7 @@ let(:commits) { [{ added: ['en/step2.md'], modified: ['en/step1.md'], removed: ['en/step0.md'] }] } it 'does not schedule the upload job' do - expect(UploadJob).not_to have_received(:perform_later) + expect { post_webhook }.not_to have_enqueued_job(UploadJob) end end end @@ -70,7 +67,7 @@ let(:commits) { [{ added: [], modified: ['en/code/project1/main.py'], removed: [] }] } it 'does not schedule the upload job' do - expect(UploadJob).not_to have_received(:perform_later) + expect { post_webhook }.not_to have_enqueued_job(UploadJob) end end end