diff options
Diffstat (limited to 'spec/workers')
| -rw-r--r-- | spec/workers/stop_area_referential_sync_worker_spec.rb | 1 | ||||
| -rw-r--r-- | spec/workers/workbench_import_worker_spec.rb | 25 | 
2 files changed, 25 insertions, 1 deletions
| diff --git a/spec/workers/stop_area_referential_sync_worker_spec.rb b/spec/workers/stop_area_referential_sync_worker_spec.rb index 48b64e55e..50c7cf45f 100644 --- a/spec/workers/stop_area_referential_sync_worker_spec.rb +++ b/spec/workers/stop_area_referential_sync_worker_spec.rb @@ -1,4 +1,3 @@ -require 'rails_helper'  RSpec.describe StopAreaReferentialSyncWorker, type: :worker do    let!(:stop_area_referential_sync) { create :stop_area_referential_sync } diff --git a/spec/workers/workbench_import_worker_spec.rb b/spec/workers/workbench_import_worker_spec.rb new file mode 100644 index 000000000..bfe631fc4 --- /dev/null +++ b/spec/workers/workbench_import_worker_spec.rb @@ -0,0 +1,25 @@ +RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do + +  let( :worker ) { described_class.new } +  let( :import ){ build_stubbed :import } +  let( :workbench ){ import.workbench } +  let( :referential ){ import.referential } +  let( :api_key ){ build_stubbed :api_key, referential: referential } + +  let( :path ){ download_workbench_import_path(workbench, import) } +  let( :result ){ import.file.read } + +  before do +    # That should be `build_stubbed's` job, no? +    allow(Import).to receive(:find).with(import.id).and_return(import) +  end +  it 'downloads a zip file' do +    # /workbenches/:workbench_id/imports/:id/download +    stub_request(:get, path) +      .with(headers: authorization_token_header(api_key)) +      .to_return(body: result) +    # WTH was I trying to test ;) Ah yeah HTTP into download +    worker.perform import.id +    expect( worker.downloaded ).to eq( result ) +  end +end | 
