diff options
| -rw-r--r-- | app/models/import.rb | 3 | ||||
| -rw-r--r-- | config/locales/imports.en.yml | 6 | ||||
| -rw-r--r-- | config/locales/imports.fr.yml | 6 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 2 |
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) } |
