aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-10-31 09:45:25 +0100
committerLuc Donnet2017-10-31 09:45:51 +0100
commitae402d2a632e9033851c4701b5b6a41767595aa9 (patch)
treecf91da73eea5ef650391a2982e579d8427df04ca
parent718d9ab7f8d5b1cd125ee341bd098c41615a0cbd (diff)
downloadchouette-core-ae402d2a632e9033851c4701b5b6a41767595aa9.tar.bz2
Fix locales problem for wrong file extension in import Refs #4816
-rw-r--r--app/models/import.rb3
-rw-r--r--config/locales/imports.en.yml6
-rw-r--r--config/locales/imports.fr.yml6
-rw-r--r--spec/models/import_spec.rb2
4 files changed, 11 insertions, 6 deletions
diff --git a/app/models/import.rb b/app/models/import.rb
index e0aae6ef1..20e7f2d8a 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -16,9 +16,10 @@ class Import < ActiveRecord::Base
extend Enumerize
enumerize :status, in: %i(new pending successful warning failed running aborted canceled), scope: true, default: :new
+ validates :name, presence: true
validates :file, presence: true
validates_presence_of :workbench, :creator
- validates_format_of :file, with: %r{\.zip\z}i, message: I18n.t('activerecord.errors.models.imports.wrong_file_extension')
+ validates_format_of :file, with: %r{\.zip\z}i, message: I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')
before_create :initialize_fields
diff --git a/config/locales/imports.en.yml b/config/locales/imports.en.yml
index f3bcad9e9..10434dd19 100644
--- a/config/locales/imports.en.yml
+++ b/config/locales/imports.en.yml
@@ -55,8 +55,10 @@ en:
other: "imports"
errors:
models:
- imports:
- wrong_file_extension: "The imported file must be a zip file"
+ import:
+ attributes:
+ file:
+ wrong_file_extension: "The imported file must be a zip file"
attributes:
import:
resources: "File to import"
diff --git a/config/locales/imports.fr.yml b/config/locales/imports.fr.yml
index 6e74fa33c..099488a6b 100644
--- a/config/locales/imports.fr.yml
+++ b/config/locales/imports.fr.yml
@@ -55,8 +55,10 @@ fr:
other: "imports"
errors:
models:
- imports:
- wrong_file_extension: "Le fichier importé doit être au format zip"
+ import:
+ attributes:
+ file:
+ wrong_file_extension: "Le fichier importé doit être au format zip"
attributes:
import:
resources: "Fichier à importer"
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb
index c06d05dab..7be05908a 100644
--- a/spec/models/import_spec.rb
+++ b/spec/models/import_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Import, type: :model do
it { should validate_presence_of(:workbench) }
it { should validate_presence_of(:creator) }
- it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.imports.wrong_file_extension')) }
+ it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')) }
it { should_not allow_values('file.json', 'file.png', 'file.pdf').for(:file) }
let(:workbench_import) { build_stubbed(:workbench_import) }