Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 11 additions & 18 deletions spec/concepts/school/import_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Loading