diff options
| author | Teddy Wing | 2017-09-05 13:19:13 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-09-05 13:19:13 +0200 | 
| commit | edbdd5a05fb9b75a6565c31f37d1ce8a501db265 (patch) | |
| tree | 7af244644f2a7d98541de7959e37a0437946e83e /spec/workers | |
| parent | 1c3148a40966f0457117e317bb1144967d39c839 (diff) | |
| download | chouette-core-edbdd5a05fb9b75a6565c31f37d1ce8a501db265.tar.bz2 | |
WorkbenchImportWorker spec: Mock upload params
Was getting this error as a result of the new parameters expected in
`mock_post`:
    2) WorkbenchImportWorker multireferential zipfile with error downloads a zip file, cuts it, and uploads some pieces
       Failure/Error:
         HTTPService.post_resource(
           host: export_host,
           path: export_path,
           params: params(eg_file, eg_name))
         HTTPService received :post_resource with unexpected arguments
           expected: ({:host=>"http://www.example.com", :path=>"/api/v1/netex_imports.json", :params=>{:netex_import=>{:par... @original_filename="subdir 0.zip", @local_path="local.path", @io=#<Double "subdir 0">, @opts={}>}}})
                got: ({:host=>"http://www.example.com", :path=>"/api/v1/netex_imports.json", :params=>{:netex_import=>{:par.../stif-boiv/tmp/imports/WorkbenchImport_subdir 0_38821.zip>, @opts={}>}}})
         Diff:
         @@ -7,5 +7,5 @@
                :workbench_id=>1019,
                :name=>"subdir 0",
                :file=>
         -       #<UploadIO:0x007f9bd144dbe8 @content_type="application/zip", @original_filename="subdir 0.zip", @local_path="local.path", @io=#<Double "subdir 0">, @opts={}>}}}]
         +       #<UploadIO:0x007f9bd14a1450
         @content_type="application/zip", @original_filename="subdir 0.zip", @local_path="/.../stif-boiv/tmp/imports/WorkbenchImport_subdir 0_38821.zip", @io=#<File:/.../stif-boiv/tmp/imports/WorkbenchImport_subdir 0_38821.zip>, @opts={}>}}}]
       # ./app/workers/workbench_import_worker.rb:29:in `execute_post'
       # ./app/workers/workbench_import_worker.rb:59:in `upload_entry_group'
       # ./app/workers/workbench_import_worker.rb:38:in `each'
       # ./app/workers/workbench_import_worker.rb:38:in `each_with_index'
       # ./app/workers/workbench_import_worker.rb:38:in `upload'
       # ./app/workers/workbench_import_worker.rb:15:in `perform'
       # ./spec/workers/workbench_import_worker_spec.rb:105:in `block (3 levels) in <top (required)>'
       # -e:1:in `<main>'
To get around this, decided to just mock the `HTTPService#upload` method
because I don't really care about these attributes.
Diffstat (limited to 'spec/workers')
| -rw-r--r-- | spec/workers/workbench_import_worker_spec.rb | 1 | 
1 files changed, 1 insertions, 0 deletions
| diff --git a/spec/workers/workbench_import_worker_spec.rb b/spec/workers/workbench_import_worker_spec.rb index 9f7f61471..14c4239b7 100644 --- a/spec/workers/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import_worker_spec.rb @@ -108,6 +108,7 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do    end    def mock_post subdir, response +    allow(HTTPService).to receive(:upload)      expect( HTTPService ).to receive(:post_resource)        .with(          host: host, | 
