diff options
| author | Robert | 2017-10-19 20:45:50 +0200 | 
|---|---|---|
| committer | Robert | 2017-10-24 15:28:44 +0200 | 
| commit | d351eab8ceea2bc7609e800e62bfb90c000cff5c (patch) | |
| tree | f386dade385bc18706436b182150b1a9e8958718 /spec/workers | |
| parent | 7f3b2aa1a1c4a2e051e1b2d3d3b57ab646b01a44 (diff) | |
| download | chouette-core-d351eab8ceea2bc7609e800e62bfb90c000cff5c.tar.bz2 | |
Refs: #4633@0.5h; WorkbenchImportWorker implements message creation for spurious directories
  - Speced and implemented
Missing:
  - Exact message parameters (change key from xxx, how to add names of spurious directories)
Diffstat (limited to 'spec/workers')
| -rw-r--r-- | spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb (renamed from spec/workers/workbench_import_with_corrupt_zip_spec.rb) | 0 | ||||
| -rw-r--r-- | spec/workers/workbench_import/workbench_import_worker_spec.rb (renamed from spec/workers/workbench_import_worker_spec.rb) | 37 | 
2 files changed, 36 insertions, 1 deletions
| diff --git a/spec/workers/workbench_import_with_corrupt_zip_spec.rb b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb index 344943ad7..344943ad7 100644 --- a/spec/workers/workbench_import_with_corrupt_zip_spec.rb +++ b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb diff --git a/spec/workers/workbench_import_worker_spec.rb b/spec/workers/workbench_import/workbench_import_worker_spec.rb index 726dd7f8d..17cb7e16b 100644 --- a/spec/workers/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import/workbench_import_worker_spec.rb @@ -17,11 +17,13 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do    let( :upload_path ) { api_v1_netex_imports_path(format: :json) } +  let( :spurious ){ [[], [], []] }    let( :subdirs ) do      entry_count.times.map do |i|        ZipService::Subdir.new(          "subdir #{i}", -        double("subdir #{i}", rewind: 0, read: '') +        double("subdir #{i}", rewind: 0, read: ''), +        spurious[i]        )      end    end @@ -103,8 +105,41 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do        expect( import ).to receive(:update).with(current_step: 3, status: 'failed')        expect { worker.perform import.id }.to raise_error(StopIteration) +    end +  end + +  context 'multireferential zipfile with spurious directories' do  +    let( :entry_count ){ 2 } +    let( :spurious1 ){ [random_string] } +    let( :spurious2 ){ [random_string, random_string] } +    let( :spurious ){ [spurious1, spurious2] } +    let( :messages ){ double('messages') } + +    before do +      allow(import).to receive(:messages).and_return(messages) +    end + +    it 'downloads a zip file, cuts it, and uploads all pieces and adds messages' do + +      expect(HTTPService).to receive(:get_resource) +        .with(host: host, path: path, params: {token: download_token}) +        .and_return( download_zip_response ) + +      subdirs.each do |subdir| +        mock_post subdir, post_response_ok +      end + +      expect( import ).to receive(:update).with(total_steps: 2) +      expect( import ).to receive(:update).with(current_step: 1) +      expect( messages ).to receive(:create).with(criticity: :warning, message_key: 'xxx') +      expect( import ).to receive(:update).with(current_step: 2) +      expect( messages ).to receive(:create).with(criticity: :warning, message_key: 'xxx') +      expect( import ).to receive(:update).with(ended_at: Time.now) + +      worker.perform import.id      end +        end    def mock_post subdir, response | 
