diff options
| author | Robert | 2017-10-23 13:30:57 +0200 | 
|---|---|---|
| committer | Robert | 2017-10-24 15:28:45 +0200 | 
| commit | f88df773cb31c9967430af0c3cd7bd9df46e46e0 (patch) | |
| tree | 41865abc47ae4fd254447a83cd998afcf33a128d | |
| parent | ddd885d2acec8a39a82dfb34e7810b52c8f01c94 (diff) | |
| download | chouette-core-f88df773cb31c9967430af0c3cd7bd9df46e46e0.tar.bz2 | |
Fixes: #4633@0.5h; Implenting correct message for inconsistent zip file
| -rw-r--r-- | app/workers/workbench_import_worker.rb | 11 | ||||
| -rw-r--r-- | config/locales/import_messages.en.yml | 1 | ||||
| -rw-r--r-- | spec/workers/workbench_import/workbench_import_worker_spec.rb | 7 | 
3 files changed, 14 insertions, 5 deletions
| diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index b28e96acc..80f458e1c 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -50,12 +50,17 @@ class WorkbenchImportWorker    def update_object_state entry, count      @workbench_import.update( current_step: count ) -    # TODO: Determine the other attributes of the message, especially how to add the names -    # of the spurious dirs entry.spurious      unless entry.spurious.empty? -      @workbench_import.messages.create(criticity: :warning, message_key: 'xxx')  +      @workbench_import.messages.create( +        criticity: :warning, +        message_key: 'inconsistent_zip_file', +        message_attributes: { +          'import_name' => @workbench_import.name, +          'spurious_dirs' => entry.spurious.inspect +        })       end    end +    def upload_entry_group entry, element_count      update_object_state entry, element_count.succ      # status = retry_service.execute(&upload_entry_group_proc(entry)) diff --git a/config/locales/import_messages.en.yml b/config/locales/import_messages.en.yml index a1a133527..528ab3477 100644 --- a/config/locales/import_messages.en.yml +++ b/config/locales/import_messages.en.yml @@ -2,6 +2,7 @@ en:    import_messages:      compliance_check_messages:        corrupt_zip_file: "The zip file of WorkbenchImport %{import_name} is corrupted and cannot be read" +      inconsistent_zip_file: "The zip file of WorkbenchImport %{import_name} contains the following spurious directories %{spurious_dirs}, which are ignored"        referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les même périodes et lignes"        1_netexstif_2: "Le fichier %{source_filename} ne respecte pas la syntaxe XML ou la XSD NeTEx : erreur '%{error_value}' rencontré"        1_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a une date de mise à jour dans le futur" diff --git a/spec/workers/workbench_import/workbench_import_worker_spec.rb b/spec/workers/workbench_import/workbench_import_worker_spec.rb index 17cb7e16b..9f860a6b3 100644 --- a/spec/workers/workbench_import/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import/workbench_import_worker_spec.rb @@ -114,6 +114,9 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do      let( :spurious2 ){ [random_string, random_string] }      let( :spurious ){ [spurious1, spurious2] }      let( :messages ){ double('messages') } +    let( :message_attributes ){{criticity: :warning, message_key: 'inconsistent_zip_file'}} +    let( :message1_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious1.inspect}) } +    let( :message2_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious2.inspect}) }      before do        allow(import).to receive(:messages).and_return(messages) @@ -131,9 +134,9 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do        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( messages ).to receive(:create).with(message1_attributes)        expect( import ).to receive(:update).with(current_step: 2) -      expect( messages ).to receive(:create).with(criticity: :warning, message_key: 'xxx') +      expect( messages ).to receive(:create).with(message2_attributes)        expect( import ).to receive(:update).with(ended_at: Time.now)        worker.perform import.id | 
