diff options
| -rw-r--r-- | app/services/http_service.rb | 4 | ||||
| -rw-r--r-- | app/workers/workbench_import_worker.rb | 2 | ||||
| -rw-r--r-- | spec/fixtures/multiple_references_import.zip (renamed from spec/fixtures/multiref.zip) | bin | 1086 -> 1086 bytes | |||
| -rw-r--r-- | spec/fixtures/single_reference_import.zip (renamed from spec/fixtures/singleref.zip) | bin | 220 -> 220 bytes | |||
| -rw-r--r-- | spec/requests/api/v1/netex_import_spec.rb | 2 | ||||
| -rw-r--r-- | spec/services/zip_service/zip_entry_data_spec.rb | 17 | ||||
| -rw-r--r-- | spec/services/zip_service/zip_entry_dirs_spec.rb | 4 | ||||
| -rw-r--r-- | spec/services/zip_service/zip_output_streams_spec.rb | 2 | ||||
| -rw-r--r-- | spec/workers/workbench_import_worker_spec.rb | 8 | 
9 files changed, 18 insertions, 21 deletions
| diff --git a/app/services/http_service.rb b/app/services/http_service.rb index 694026c4f..bdd4ca8d5 100644 --- a/app/services/http_service.rb +++ b/app/services/http_service.rb @@ -12,8 +12,8 @@ module HTTPService extend self    end    def get_json_resource(host:, path:, token: nil, params: {}) -    # Stupid Ruby!!! -    resp = get_resource(host: host, path: path, token: token, params: {})  +    # Stupid Ruby!!! (I mean I just **need** Pattern Matching, maybe I need to write it myself :O) +    resp = get_resource(host: host, path: path, token: token, params: params)       if resp.status == 200        return JSON.parse(resp.body)      else diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index 488fbfc0b..4f9a53c14 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -9,7 +9,7 @@ class WorkbenchImportWorker    # =======    def perform(import_id) -    @import     = Import.find(import_id) +    @import     = WorkbenchImport.find(import_id)      @response   = nil      @import.update_attributes(status: 'running')      downloaded  = download diff --git a/spec/fixtures/multiref.zip b/spec/fixtures/multiple_references_import.zipBinary files differ index 28ddff198..28ddff198 100644 --- a/spec/fixtures/multiref.zip +++ b/spec/fixtures/multiple_references_import.zip diff --git a/spec/fixtures/singleref.zip b/spec/fixtures/single_reference_import.zipBinary files differ index 4aee23614..4aee23614 100644 --- a/spec/fixtures/singleref.zip +++ b/spec/fixtures/single_reference_import.zip diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb index 1c34d5544..ab1e7f6ae 100644 --- a/spec/requests/api/v1/netex_import_spec.rb +++ b/spec/requests/api/v1/netex_import_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "NetexImport", type: :request do      let( :referential ){ create :referential } -    let( :file_path ){ fixtures_path 'singleref.zip' } +    let( :file_path ){ fixtures_path 'single_reference_import.zip' }      let( :file ){ fixture_file_upload( file_path ) }      let( :post_request ) do diff --git a/spec/services/zip_service/zip_entry_data_spec.rb b/spec/services/zip_service/zip_entry_data_spec.rb index 6bfaa8cc4..2a7226eb4 100644 --- a/spec/services/zip_service/zip_entry_data_spec.rb +++ b/spec/services/zip_service/zip_entry_data_spec.rb @@ -1,18 +1,15 @@  RSpec.describe ZipService do -  subject{ described_class.new(read_fixture('multiref.zip')) } - -  let( :ref1_zipdata ){ read_fixture('ref1.zip') } -  let( :ref2_zipdata ){ read_fixture('ref2.zip') } +  subject{ described_class.new(read_fixture('multiple_references_import.zip')) }    it 'can group all entries' do      expect( subject.entry_groups.keys ).to eq(%w{ref1 ref2})    end    context 'creates correct zip data for each subdir' do -    it 'e.g. ref1' do -      ref1_stream = subject.entry_group_streams['ref1'] -      control_stream = Zip::InputStream.open( ref1_stream ) +    it 'e.g. reference1' do +      reference1_stream = subject.entry_group_streams['ref1'] +      control_stream = Zip::InputStream.open( reference1_stream )        control_entries = described_class.entries(control_stream)        expect( control_entries.map{ |e| [e.name, e.get_input_stream.read]}.force ).to eq([          ["multiref/ref1/", ""], @@ -20,9 +17,9 @@ RSpec.describe ZipService do          ["multiref/ref1/datum-2", "multi-ref1-datum2\n"]        ])      end -    it 'e.g. ref2' do -      ref2_stream = subject.entry_group_streams['ref2'] -      control_stream = Zip::InputStream.open( ref2_stream ) +    it 'e.g. reference2' do +      reference2_stream = subject.entry_group_streams['ref2'] +      control_stream = Zip::InputStream.open( reference2_stream )        control_entries = described_class.entries(control_stream)        expect( control_entries.map{ |e| [e.name, e.get_input_stream.read]}.force ).to eq([          ["multiref/ref2/", ""], diff --git a/spec/services/zip_service/zip_entry_dirs_spec.rb b/spec/services/zip_service/zip_entry_dirs_spec.rb index cf927855f..8ca1b0f1a 100644 --- a/spec/services/zip_service/zip_entry_dirs_spec.rb +++ b/spec/services/zip_service/zip_entry_dirs_spec.rb @@ -11,14 +11,14 @@ RSpec.describe ZipService do    end    context 'single entry' do -    let( :zip_file ){ fixtures_path 'multiref.zip' } +    let( :zip_file ){ fixtures_path 'multiple_references_import.zip' }      let( :expected ){ %w{ref1 ref2} }      it_behaves_like 'a correct zip entry reader'    end    context 'more entries' do -    let( :zip_file ){ fixtures_path 'singleref.zip' } +    let( :zip_file ){ fixtures_path 'single_reference_import.zip' }      let( :expected ){ %w{ref} }      it_behaves_like 'a correct zip entry reader' diff --git a/spec/services/zip_service/zip_output_streams_spec.rb b/spec/services/zip_service/zip_output_streams_spec.rb index d2452bfd8..fbc60ae92 100644 --- a/spec/services/zip_service/zip_output_streams_spec.rb +++ b/spec/services/zip_service/zip_output_streams_spec.rb @@ -1,6 +1,6 @@  RSpec.describe ZipService do -  subject{ described_class.new(read_fixture('multiref.zip')) } +  subject{ described_class.new(read_fixture('multiple_references_import.zip')) }    it 'can write itself to a file' do diff --git a/spec/workers/workbench_import_worker_spec.rb b/spec/workers/workbench_import_worker_spec.rb index 3ed5833dc..4706595ce 100644 --- a/spec/workers/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import_worker_spec.rb @@ -33,9 +33,9 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do    end    let( :zip_service ){ double("zip service") } -  let( :zip_file ){ open_fixture('multiref.zip') } +  let( :zip_file ){ open_fixture('multiple_references_import.zip') } -  let( :post_response_ok ){ response(status: 201, boody: "{}") } +  let( :post_response_ok ){ response(status: 201, body: "{}") }    before do      # Silence Logger @@ -76,7 +76,7 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do    context 'multireferential zipfile with error' do      let( :entry_count ){ 3 } -    let( :post_response_failure ){ response(status: 406, boody: {error: 'What was you thinking'}) } +    let( :post_response_failure ){ response(status: 406, body: {error: 'What was you thinking'}) }      it 'downloads a zip file, cuts it, and uploads some pieces' do        expect(HTTPService).to receive(:get_resource) @@ -117,6 +117,6 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do        .and_return(response)    end    def response(**opts) -    OpenStruct.new(opts) +    double(**opts)    end  end | 
