diff --git a/README.md b/README.md index 074d46a9..1ff4a3e1 100755 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Once you have installed the gem, you need to add the gem I18n error messages to ### Using image metadata validators -Optionally, to use the image metadata validators (`dimension`, `aspect_ratio` and `processable_image`), you will have to add one of the corresponding gems: +Optionally, to use the image metadata validators (`dimension`, `aspect_ratio` and `processable_file`), you will have to add one of the corresponding gems: ```ruby gem 'mini_magick', '>= 4.9.5' @@ -69,7 +69,7 @@ Plus, you have to be sure to have the corresponding command-line tool installed ### Using video and audio metadata validators -To use the video and audio metadata validators (`dimension`, `aspect_ratio` and `duration`), you will not need to add any gems. However you will need to have the `ffmpeg` command-line tool installed on your system (once again, be sure to have it installed both on your local and in your CI / production environments). +To use the video and audio metadata validators (`dimension`, `aspect_ratio`, `processable_file` and `duration`), you will not need to add any gems. However you will need to have the `ffmpeg` command-line tool installed on your system (once again, be sure to have it installed both on your local and in your CI / production environments). ## Validators @@ -81,9 +81,8 @@ List of validators: - [Total size](#total-size): validates total file size for several files - [Dimension](#dimension): validates image / video dimensions - [Aspect ratio](#aspect-ratio): validates image / video aspect ratio -- [Processable image](#processable-image): validates if an image can be processed +- [Processable file](#processable-file): validates if a file can be processed 🚧 TODO: Add `duration` validator -🚧 TODO: Update `processable_image` validator to `processable` **Proc usage** @@ -507,13 +506,13 @@ The `aspect_ratio` validator error messages expose 4 values that you can use: --- -### Processable image +### Processable file -Validates if the attached files can be processed by MiniMagick or Vips. +Validates if the attached files can be processed by MiniMagick or Vips (image) or ffmpeg (video/audio). #### Options -The `processable_image` validator has no options. +The `processable_file` validator has no options. #### Examples @@ -522,7 +521,7 @@ Use it like this: class User < ApplicationRecord has_one_attached :avatar - validates :avatar, processable_image: true # restricts the file to be processable by MiniMagick or Vips + validates :avatar, processable_file: true # ensures that the file is processable by MiniMagick or Vips (image) or ffmpeg (video/audio) end ``` @@ -532,10 +531,10 @@ end en: errors: messages: - image_not_processable: "is not a valid image" + file_not_processable: "is not identified as a valid media file" ``` -The `processable_image` validator error messages expose 1 value that you can use: +The `processable_file` validator error messages expose 1 value that you can use: - `filename` containing the current filename in error --- @@ -547,6 +546,7 @@ If you are upgrading from 1.x to 2.x, you will be pleased to note that a lot of Added features: - `dimension` validator now supports videos - `aspect_ratio` validator now supports videos +- `processable_image` validator is now `processable_file` validator and supports image/video/audio - All error messages have been given an upgrade and new variables that you can use But this major version bump also comes with some breaking changes. Below are the main breaking changes you need to be aware of: @@ -556,6 +556,7 @@ But this major version bump also comes with some breaking changes. Below are the - `limit` validator keys have been totally reworked - `dimension` validator keys have been totally reworked - `content_type` validator keys have been totally reworked + - `processable_image` validator keys have been totally reworked - Some keys have been changed: - `image_metadata_missing` has been replaced by `media_metadata_missing` - `aspect_ratio_is_not` has been replaced by `aspect_ratio_not_x_y` @@ -571,6 +572,10 @@ But this major version bump also comes with some breaking changes. Below are the - This might break some cases when you had for example `content_type: ['image/png', 'image/jpg']`, because `image/jpg` is not a valid content type, it should be replaced by `image/jpeg`. - An `ArgumentError` is now raised if `image/jpg` is used to make it easier to fix. You should now only use `image/jpeg`. +- `processable_image` validator + - The validator has been replaced by `processable_file` validator, be sure to replace `processable_image: true` to `processable_file: true` + - The associated matcher has also been updated accordingly, be sure to replace `validate_processable_image_of` to `validate_processable_file_of` + 🚧 TODO: Add more details about the other changes when implemented @@ -624,7 +629,7 @@ en: aspect_ratio_not_landscape: "must be landscape (current file is %{width}x%{height}px)" aspect_ratio_not_x_y: "must be %{authorized_aspect_ratios} (current file is %{width}x%{height}px)" aspect_ratio_invalid: "has an invalid aspect ratio (valid aspect ratios are %{authorized_aspect_ratios})" - image_not_processable: "is not a valid image" + file_not_processable: "is not identified as a valid media file" ``` @@ -662,8 +667,8 @@ describe User do # attached it { is_expected.to validate_attached_of(:avatar) } - # processable_image - it { is_expected.to validate_processable_image_of(:avatar) } + # processable_file + it { is_expected.to validate_processable_file_of(:avatar) } # limit # #min, #max diff --git a/config/locales/da.yml b/config/locales/da.yml index e74f3505..4bb90bc3 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -43,4 +43,4 @@ da: aspect_ratio_not_landscape: "skal være landskab (nuværende fil er %{width}x%{height}px)" aspect_ratio_not_x_y: "skal være %{authorized_aspect_ratios} (nuværende fil er %{width}x%{height}px)" aspect_ratio_invalid: "har et ugyldigt aspektforhold (gyldige aspektforhold er %{authorized_aspect_ratios})" - image_not_processable: "er ikke et gyldigt billede" + file_not_processable: "identificeres ikke som en gyldig mediefil" diff --git a/config/locales/de.yml b/config/locales/de.yml index cb785b57..901add8f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -43,4 +43,4 @@ de: aspect_ratio_not_landscape: "muss landschaftlich sein (aktuelle Datei ist %{width}x%{height}px)" aspect_ratio_not_x_y: "muss %{authorized_aspect_ratios} sein (aktuelle Datei ist %{width}x%{height}px)" aspect_ratio_invalid: "hat ein ungültiges Seitenverhältnis (gültige Seitenverhältnisse sind %{authorized_aspect_ratios})" - image_not_processable: "ist kein gültiges Bild" + file_not_processable: "wird nicht als gültige Mediendatei identifiziert" diff --git a/config/locales/en.yml b/config/locales/en.yml index b7bdbb7f..47a6b991 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -43,4 +43,4 @@ en: aspect_ratio_not_landscape: "must be landscape (current file is %{width}x%{height}px)" aspect_ratio_not_x_y: "must be %{authorized_aspect_ratios} (current file is %{width}x%{height}px)" aspect_ratio_invalid: "has an invalid aspect ratio (valid aspect ratios are %{authorized_aspect_ratios})" - image_not_processable: "is not a valid image" + file_not_processable: "is not identified as a valid media file" diff --git a/config/locales/es.yml b/config/locales/es.yml index e1ed415a..ce701573 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -43,4 +43,4 @@ es: aspect_ratio_not_landscape: "debe ser paisaje (el archivo actual es %{width}x%{height}px)" aspect_ratio_not_x_y: "debe ser %{authorized_aspect_ratios} (el archivo actual es %{width}x%{height}px)" aspect_ratio_invalid: "tiene una relación de aspecto inválida (las relaciones de aspecto válidas son %{authorized_aspect_ratios})" - image_not_processable: "no es una imagen válida" + file_not_processable: "no se identifica como un archivo multimedia válido" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 461d395e..e592e48f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -43,4 +43,4 @@ fr: aspect_ratio_not_landscape: "doit être paysage (le fichier actuel est %{width}x%{height}px)" aspect_ratio_not_x_y: "doit être %{authorized_aspect_ratios} (le fichier actuel est %{width}x%{height}px)" aspect_ratio_invalid: "a un rapport d'aspect invalide (les rapports d'aspect valides sont %{authorized_aspect_ratios})" - image_not_processable: "n'est pas une image valide" + file_not_processable: "n'est pas identifié comme un fichier média valide" diff --git a/config/locales/it.yml b/config/locales/it.yml index 59f3d407..7e2196e4 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -43,4 +43,4 @@ it: aspect_ratio_not_landscape: "deve essere orizzontale (il file corrente è %{width}x%{height}px)" aspect_ratio_not_x_y: "deve essere %{authorized_aspect_ratios} (il file corrente è %{width}x%{height}px)" aspect_ratio_invalid: "ha un formato non valido (i rapporti di aspetto validi sono %{authorized_aspect_ratios})" - image_not_processable: "non è un'immagine valida" + file_not_processable: "non è identificato come file multimediale valido" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 49247311..5a713004 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -43,4 +43,4 @@ ja: aspect_ratio_not_landscape: "は横長である必要があります(現在のファイルは%{width}x%{height})" aspect_ratio_not_x_y: "は%{authorized_aspect_ratios}である必要があります(現在のファイルは%{width}x%{height})" aspect_ratio_invalid: "は無効なアスペクト比です(有効なアスペクト比は%{authorized_aspect_ratios}です)" - image_not_processable: "は不正な画像です" + file_not_processable: "有効なメディアファイルとして識別されない" diff --git a/config/locales/nl.yml b/config/locales/nl.yml index e278ed0b..cf03bec4 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -43,4 +43,4 @@ nl: aspect_ratio_not_landscape: "moet landschap zijn (huidig bestand is %{width}x%{height}px)" aspect_ratio_not_x_y: "moet %{authorized_aspect_ratios} zijn (huidig bestand is %{width}x%{height}px)" aspect_ratio_invalid: "heeft een ongeldige beeldverhouding (geldige beeldverhoudingen zijn %{authorized_aspect_ratios})" - image_not_processable: "is geen geldige afbeelding" + file_not_processable: "wordt niet geïdentificeerd als een geldig mediabestand" diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 2a9a6d96..06b8b003 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -43,5 +43,4 @@ pl: aspect_ratio_not_landscape: "musi być krajobrazem (bieżący plik to %{width}x%{height}px)" aspect_ratio_not_x_y: "musi być %{authorized_aspect_ratios} (bieżący plik to %{width}x%{height}px)" aspect_ratio_invalid: "ma nieprawidłowy współczynnik kształtu (ważne współczynniki kształtu wynoszą %{authorized_aspect_ratios})" - image_not_processable: "nie jest prawidłowym obrazem" - + file_not_processable: "nie jest identyfikowany jako prawidłowy plik multimedialny" diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 32900780..1c2d76af 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -43,4 +43,4 @@ pt-BR: aspect_ratio_not_landscape: "deve ser paisagem (o ficheiro actual é %{width}x%{height}px)" aspect_ratio_not_x_y: "deve ser %{authorized_aspect_ratios} (o ficheiro actual é %{width}x%{height}px)" aspect_ratio_invalid: "tem uma proporção inválida (as proporções válidas são %{authorized_aspect_ratios})" - image_not_processable: "não é uma imagem válida" + file_not_processable: "não é identificado como um arquivo de mídia válido" diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 8f444fa5..ea5d4adf 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -43,4 +43,4 @@ ru: aspect_ratio_not_landscape: "должен быть ландшафт (текущий файл %{width}x%{height} пикселей)" aspect_ratio_not_x_y: "должно быть %{authorized_aspect_ratios} (текущий файл %{width}x%{height} пикселей)" aspect_ratio_invalid: "имеет недействительное соотношение сторон (действительные соотношения сторон %{authorized_aspect_ratios})" - image_not_processable: "не является допустимым изображением" + file_not_processable: "не идентифицируется как действительный медиафайл" diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 35070d25..150c03f6 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -43,4 +43,4 @@ sv: aspect_ratio_not_landscape: "måste vara landskap (nuvarande fil är %{width}x%{height} pixlar)" aspect_ratio_not_x_y: "måste vara% { authorized_aspect_ratios } (nuvarande fil är %{width}x%{height} pixlar)" aspect_ratio_invalid: "har ett ogiltigt bildförhållande (giltiga bildförhållanden är %{förväntat_aspect_ratios})" - image_not_processable: "är inte en giltig bild" + file_not_processable: "identifieras inte som en giltig mediefil" diff --git a/config/locales/tr.yml b/config/locales/tr.yml index d228817e..daee242d 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -43,4 +43,4 @@ tr: aspect_ratio_not_landscape: "yatay olmalıdır (geçerli dosya %{width}x%{height}px)" aspect_ratio_not_x_y: "%{authorized_aspect_ratios} olmalıdır (geçerli dosya %{width}x%{height}px)" aspect_ratio_invalid: "geçersiz bir en boy oranına sahiptir (geçerli en boy oranları %{authorized_aspect_ratios})" - image_not_processable: "geçerli bir imaj değil" + file_not_processable: "geçerli bir medya dosyası olarak tanımlanmadı" diff --git a/config/locales/uk.yml b/config/locales/uk.yml index a9ef415e..d0677609 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -43,4 +43,4 @@ uk: aspect_ratio_not_landscape: "повинен бути пейзажним (поточний файл %{width}x%{height} пікселям)" aspect_ratio_not_x_y: "повинен бути %{authorized_aspect_ratios} (поточний файл становить %{width}x%{height} пікселям)" aspect_ratio_invalid: "має недійсне співвідношення сторін (дійсні співвідношення сторін %{authorized_aspect_ratios})" - image_not_processable: "не є допустимим зображенням" + file_not_processable: "не ідентифікується як дійсний медіа-файл" diff --git a/config/locales/vi.yml b/config/locales/vi.yml index f3cba488..3d6a6799 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -43,5 +43,4 @@ vi: aspect_ratio_not_landscape: "phải là ngang (tệp hiện tại là %{width}x%{height}px)" aspect_ratio_not_x_y: "phải là %{authorized_aspect_ratios} (tệp hiện tại là %{width}x%{height}px)" aspect_ratio_invalid: "có tỷ lệ khung hình không hợp lệ (tỷ lệ khung hình hợp lệ là %{authorized_aspect_ratios})" - image_not_processable: "không phải là ảnh" - + file_not_processable: "không được xác định là tệp phương tiện hợp lệ" diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index fe69c757..015c593a 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -43,4 +43,4 @@ zh-CN: aspect_ratio_not_landscape: "必须是横向(当前文件为 %{width} x%{height} 像素)" expect_ratio_not_x_y: "必须为 %{authorized_aspect_ratios}(当前文件为 %{width} x%{height} 像素)" expect_ratio_not_in_list: "具有无效的长宽比(有效长宽比为 %{authorized_aspect_ratios})" - image_not_processable: "不是有效的图像" + file_not_processable: "未标识为有效的媒体文件" diff --git a/lib/active_storage_validations.rb b/lib/active_storage_validations.rb index eaecaa9b..f83d6dee 100644 --- a/lib/active_storage_validations.rb +++ b/lib/active_storage_validations.rb @@ -18,7 +18,7 @@ require 'active_storage_validations/limit_validator' require 'active_storage_validations/dimension_validator' require 'active_storage_validations/aspect_ratio_validator' -require 'active_storage_validations/processable_image_validator' +require 'active_storage_validations/processable_file_validator' require 'active_storage_validations/size_validator' require 'active_storage_validations/total_size_validator' diff --git a/lib/active_storage_validations/matchers.rb b/lib/active_storage_validations/matchers.rb index 8f236c86..acf959c7 100644 --- a/lib/active_storage_validations/matchers.rb +++ b/lib/active_storage_validations/matchers.rb @@ -2,7 +2,7 @@ require 'active_storage_validations/matchers/aspect_ratio_validator_matcher' require 'active_storage_validations/matchers/attached_validator_matcher' -require 'active_storage_validations/matchers/processable_image_validator_matcher' +require 'active_storage_validations/matchers/processable_file_validator_matcher' require 'active_storage_validations/matchers/limit_validator_matcher' require 'active_storage_validations/matchers/content_type_validator_matcher' require 'active_storage_validations/matchers/dimension_validator_matcher' diff --git a/lib/active_storage_validations/matchers/processable_image_validator_matcher.rb b/lib/active_storage_validations/matchers/processable_file_validator_matcher.rb similarity index 88% rename from lib/active_storage_validations/matchers/processable_image_validator_matcher.rb rename to lib/active_storage_validations/matchers/processable_file_validator_matcher.rb index 81dee4a5..2cd584f1 100644 --- a/lib/active_storage_validations/matchers/processable_image_validator_matcher.rb +++ b/lib/active_storage_validations/matchers/processable_file_validator_matcher.rb @@ -10,11 +10,11 @@ module ActiveStorageValidations module Matchers - def validate_processable_image_of(name) - ProcessableImageValidatorMatcher.new(name) + def validate_processable_file_of(name) + ProcessableFileValidatorMatcher.new(name) end - class ProcessableImageValidatorMatcher + class ProcessableFileValidatorMatcher include ASVActiveStorageable include ASVAllowBlankable include ASVAttachable @@ -46,7 +46,7 @@ def matches?(subject) is_context_valid? && is_custom_message_valid? && is_valid_when_image_processable? && - is_invalid_when_image_not_processable? + is_invalid_when_file_not_processable? end private @@ -58,7 +58,7 @@ def is_valid_when_image_processable? is_valid? end - def is_invalid_when_image_not_processable? + def is_invalid_when_file_not_processable? attach_file(not_processable_image) validate detach_file diff --git a/lib/active_storage_validations/processable_image_validator.rb b/lib/active_storage_validations/processable_file_validator.rb similarity index 86% rename from lib/active_storage_validations/processable_image_validator.rb rename to lib/active_storage_validations/processable_file_validator.rb index f0dc5977..8d181870 100644 --- a/lib/active_storage_validations/processable_image_validator.rb +++ b/lib/active_storage_validations/processable_file_validator.rb @@ -7,7 +7,7 @@ require_relative 'shared/asv_symbolizable' module ActiveStorageValidations - class ProcessableImageValidator < ActiveModel::EachValidator # :nodoc + class ProcessableFileValidator < ActiveModel::EachValidator # :nodoc include ASVActiveStorageable include ASVAnalyzable include ASVAttachable @@ -15,7 +15,7 @@ class ProcessableImageValidator < ActiveModel::EachValidator # :nodoc include ASVSymbolizable ERROR_TYPES = %i[ - image_not_processable + file_not_processable ].freeze def validate_each(record, attribute, _value) diff --git a/test/active_storage_validations_test.rb b/test/active_storage_validations_test.rb index 062b24f0..298fb1c2 100644 --- a/test/active_storage_validations_test.rb +++ b/test/active_storage_validations_test.rb @@ -257,7 +257,7 @@ class ActiveStorageValidations::Test < ActiveSupport::TestCase e.proc_image.attach(image_1920x1080_file) e.another_image.attach(tar_file_with_image_content_type) assert !e.valid? - assert_equal ["Another image is not a valid image"], e.errors.full_messages + assert_equal ["Another image is not identified as a valid media file"], e.errors.full_messages e = OnlyImage.new e.image.attach(image_1920x1080_file) diff --git a/test/dummy/app/models/integration/validator/zero_byte_image.rb b/test/dummy/app/models/integration/validator/zero_byte_image.rb index 09a13a49..8dac7744 100644 --- a/test/dummy/app/models/integration/validator/zero_byte_image.rb +++ b/test/dummy/app/models/integration/validator/zero_byte_image.rb @@ -13,5 +13,5 @@ class Integration::Validator::ZeroByteImage < ApplicationRecord has_one_attached :zero_byte_image validates :zero_byte_image, attached: true, content_type: :png, - processable_image: true + processable_file: true end diff --git a/test/dummy/app/models/only_image.rb b/test/dummy/app/models/only_image.rb index 29bfc6b1..b1c87505 100644 --- a/test/dummy/app/models/only_image.rb +++ b/test/dummy/app/models/only_image.rb @@ -10,6 +10,6 @@ class OnlyImage < ApplicationRecord validates :proc_image, dimension: { width: { min: -> (record) {100}, max: -> (record) {2000} }, height: { min: -> (record) {100}, max: -> (record) {1500} } }, aspect_ratio: -> (record) {:is_16_9}, content_type: -> (record) {['image/png', 'image/jpeg']} - validates :another_image, processable_image: true - validates :any_image, processable_image: false + validates :another_image, processable_file: true + validates :any_image, processable_file: false end diff --git a/test/dummy/app/models/processable_file.rb b/test/dummy/app/models/processable_file.rb new file mode 100644 index 00000000..001d367c --- /dev/null +++ b/test/dummy/app/models/processable_file.rb @@ -0,0 +1,5 @@ +module ProcessableFile + def self.table_name_prefix + 'processable_file_' + end +end diff --git a/test/dummy/app/models/processable_file/matcher.rb b/test/dummy/app/models/processable_file/matcher.rb new file mode 100644 index 00000000..7e54d393 --- /dev/null +++ b/test/dummy/app/models/processable_file/matcher.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +# == Schema Information +# +# Table name: processable_file_matchers +# +# title :string +# id :integer not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# + +class ProcessableFile::Matcher < ApplicationRecord + include Validatable + + has_one_attached :custom_matcher + validates :custom_matcher, processable_file: true + + has_one_attached :processable + validates :processable, processable_file: true + + has_one_attached :with_message + validates :with_message, processable_file: { message: 'Custom message' } + + has_one_attached :with_context_symbol + validates :with_context_symbol, processable_file: true, on: :update + has_one_attached :with_context_array + validates :with_context_array, processable_file: true, on: %i[update custom] + has_one_attached :with_several_validators_and_contexts + validates :with_several_validators_and_contexts, processable_file: true, on: :update + validates :with_several_validators_and_contexts, processable_file: true, on: :custom + + has_one_attached :as_instance + validates :as_instance, processable_file: true + + has_one_attached :validatable_different_error_messages + validates :validatable_different_error_messages, processable_file: { message: 'Custom message 1' }, if: :title_is_quo_vadis? + validates :validatable_different_error_messages, processable_file: { message: 'Custom message 2' }, if: :title_is_american_psycho? + + has_one_attached :failure_message + validates :failure_message, processable_file: true + has_one_attached :failure_message_when_negated + validates :failure_message_when_negated, processable_file: true + + has_one_attached :not_processable +end diff --git a/test/dummy/app/models/processable_image/validator.rb b/test/dummy/app/models/processable_file/validator.rb similarity index 52% rename from test/dummy/app/models/processable_image/validator.rb rename to test/dummy/app/models/processable_file/validator.rb index e5b75217..3b342222 100644 --- a/test/dummy/app/models/processable_image/validator.rb +++ b/test/dummy/app/models/processable_file/validator.rb @@ -1,7 +1,7 @@ -module ProcessableImage +module ProcessableFile module Validator def self.table_name_prefix - 'processable_image_validator_' + 'processable_file_validator_' end end end diff --git a/test/dummy/app/models/processable_image/validator/check.rb b/test/dummy/app/models/processable_file/validator/check.rb similarity index 58% rename from test/dummy/app/models/processable_image/validator/check.rb rename to test/dummy/app/models/processable_file/validator/check.rb index 2cceddd6..8fafd38a 100644 --- a/test/dummy/app/models/processable_image/validator/check.rb +++ b/test/dummy/app/models/processable_file/validator/check.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_checks +# Table name: processable_file_validator_checks # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::Check < ApplicationRecord +class ProcessableFile::Validator::Check < ApplicationRecord has_one_attached :has_to_be_processable - validates :has_to_be_processable, processable_image: true + validates :has_to_be_processable, processable_file: true end diff --git a/test/dummy/app/models/processable_image/validator/check_validity_invalid_check.rb b/test/dummy/app/models/processable_file/validator/check_validity_invalid_check.rb similarity index 51% rename from test/dummy/app/models/processable_image/validator/check_validity_invalid_check.rb rename to test/dummy/app/models/processable_file/validator/check_validity_invalid_check.rb index adb9887a..4c402f63 100644 --- a/test/dummy/app/models/processable_image/validator/check_validity_invalid_check.rb +++ b/test/dummy/app/models/processable_file/validator/check_validity_invalid_check.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_check_validity_invalid_checks +# Table name: processable_file_validator_check_validity_invalid_checks # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::CheckValidityInvalidCheck < ApplicationRecord +class ProcessableFile::Validator::CheckValidityInvalidCheck < ApplicationRecord has_one_attached :invalid - validates :invalid, processable_image: { invalid_check: true } + validates :invalid, processable_file: { invalid_check: true } end diff --git a/test/dummy/app/models/processable_image/validator/check_validity_no_check.rb b/test/dummy/app/models/processable_file/validator/check_validity_no_check.rb similarity index 55% rename from test/dummy/app/models/processable_image/validator/check_validity_no_check.rb rename to test/dummy/app/models/processable_file/validator/check_validity_no_check.rb index 1d46e7d5..18e058c0 100644 --- a/test/dummy/app/models/processable_image/validator/check_validity_no_check.rb +++ b/test/dummy/app/models/processable_file/validator/check_validity_no_check.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_check_validity_no_checks +# Table name: processable_file_validator_check_validity_no_checks # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::CheckValidityNoCheck < ApplicationRecord +class ProcessableFile::Validator::CheckValidityNoCheck < ApplicationRecord has_one_attached :invalid - validates :invalid, processable_image: {} + validates :invalid, processable_file: {} end diff --git a/test/dummy/app/models/processable_image/validator/using_attachable.rb b/test/dummy/app/models/processable_file/validator/using_attachable.rb similarity index 53% rename from test/dummy/app/models/processable_image/validator/using_attachable.rb rename to test/dummy/app/models/processable_file/validator/using_attachable.rb index 655ec8f2..78cba0a1 100644 --- a/test/dummy/app/models/processable_image/validator/using_attachable.rb +++ b/test/dummy/app/models/processable_file/validator/using_attachable.rb @@ -2,16 +2,16 @@ # == Schema Information # -# Table name: processable_image_validator_using_attachables +# Table name: processable_file_validator_using_attachables # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::UsingAttachable < ApplicationRecord +class ProcessableFile::Validator::UsingAttachable < ApplicationRecord has_one_attached :using_attachable has_many_attached :using_attachables - validates :using_attachable, processable_image: true - validates :using_attachables, processable_image: true + validates :using_attachable, processable_file: true + validates :using_attachables, processable_file: true end diff --git a/test/dummy/app/models/processable_image/validator/with_allow_blank.rb b/test/dummy/app/models/processable_file/validator/with_allow_blank.rb similarity index 53% rename from test/dummy/app/models/processable_image/validator/with_allow_blank.rb rename to test/dummy/app/models/processable_file/validator/with_allow_blank.rb index b4f6e3d8..b77594a5 100644 --- a/test/dummy/app/models/processable_image/validator/with_allow_blank.rb +++ b/test/dummy/app/models/processable_file/validator/with_allow_blank.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_with_allow_blanks +# Table name: processable_file_validator_with_allow_blanks # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::WithAllowBlank < ApplicationRecord +class ProcessableFile::Validator::WithAllowBlank < ApplicationRecord has_one_attached :with_allow_blank - validates :with_allow_blank, processable_image: true, allow_blank: true + validates :with_allow_blank, processable_file: true, allow_blank: true end diff --git a/test/dummy/app/models/processable_image/validator/with_allow_nil.rb b/test/dummy/app/models/processable_file/validator/with_allow_nil.rb similarity index 54% rename from test/dummy/app/models/processable_image/validator/with_allow_nil.rb rename to test/dummy/app/models/processable_file/validator/with_allow_nil.rb index ed03c993..6bc6155c 100644 --- a/test/dummy/app/models/processable_image/validator/with_allow_nil.rb +++ b/test/dummy/app/models/processable_file/validator/with_allow_nil.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_with_allow_nils +# Table name: processable_file_validator_with_allow_nils # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::WithAllowNil < ApplicationRecord +class ProcessableFile::Validator::WithAllowNil < ApplicationRecord has_one_attached :with_allow_nil - validates :with_allow_nil, processable_image: true, allow_nil: true + validates :with_allow_nil, processable_file: true, allow_nil: true end diff --git a/test/dummy/app/models/processable_image/validator/with_if.rb b/test/dummy/app/models/processable_file/validator/with_if.rb similarity index 55% rename from test/dummy/app/models/processable_image/validator/with_if.rb rename to test/dummy/app/models/processable_file/validator/with_if.rb index a9706b1c..436831f5 100644 --- a/test/dummy/app/models/processable_image/validator/with_if.rb +++ b/test/dummy/app/models/processable_file/validator/with_if.rb @@ -2,7 +2,7 @@ # == Schema Information # -# Table name: processable_image_validator_with_ifs +# Table name: processable_file_validator_with_ifs # # title :string # id :integer not null, primary key @@ -10,11 +10,11 @@ # updated_at :datetime not null # -class ProcessableImage::Validator::WithIf < ApplicationRecord +class ProcessableFile::Validator::WithIf < ApplicationRecord has_one_attached :with_if has_one_attached :with_if_proc - validates :with_if, processable_image: true, if: :title_is_image? - validates :with_if_proc, processable_image: true, if: -> { self.title == 'Right title' } + validates :with_if, processable_file: true, if: :title_is_image? + validates :with_if_proc, processable_file: true, if: -> { self.title == 'Right title' } def title_is_image? title == 'image' diff --git a/test/dummy/app/models/processable_image/validator/with_message.rb b/test/dummy/app/models/processable_file/validator/with_message.rb similarity index 54% rename from test/dummy/app/models/processable_image/validator/with_message.rb rename to test/dummy/app/models/processable_file/validator/with_message.rb index 4f00d93f..967e709d 100644 --- a/test/dummy/app/models/processable_image/validator/with_message.rb +++ b/test/dummy/app/models/processable_file/validator/with_message.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_with_messages +# Table name: processable_file_validator_with_messages # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::WithMessage < ApplicationRecord +class ProcessableFile::Validator::WithMessage < ApplicationRecord has_one_attached :with_message - validates :with_message, processable_image: { message: 'Custom message' } + validates :with_message, processable_file: { message: 'Custom message' } end diff --git a/test/dummy/app/models/processable_image/validator/with_on.rb b/test/dummy/app/models/processable_file/validator/with_on.rb similarity index 53% rename from test/dummy/app/models/processable_image/validator/with_on.rb rename to test/dummy/app/models/processable_file/validator/with_on.rb index 61e89839..1be2d357 100644 --- a/test/dummy/app/models/processable_image/validator/with_on.rb +++ b/test/dummy/app/models/processable_file/validator/with_on.rb @@ -2,14 +2,14 @@ # == Schema Information # -# Table name: processable_image_validator_with_ons +# Table name: processable_file_validator_with_ons # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::WithOn < ApplicationRecord +class ProcessableFile::Validator::WithOn < ApplicationRecord has_one_attached :with_on - validates :with_on, processable_image: true, on: %i(create update destroy custom) + validates :with_on, processable_file: true, on: %i(create update destroy custom) end diff --git a/test/dummy/app/models/processable_image/validator/with_strict.rb b/test/dummy/app/models/processable_file/validator/with_strict.rb similarity index 58% rename from test/dummy/app/models/processable_image/validator/with_strict.rb rename to test/dummy/app/models/processable_file/validator/with_strict.rb index e2e49148..90b6af03 100644 --- a/test/dummy/app/models/processable_image/validator/with_strict.rb +++ b/test/dummy/app/models/processable_file/validator/with_strict.rb @@ -2,16 +2,16 @@ # == Schema Information # -# Table name: processable_image_validator_with_stricts +# Table name: processable_file_validator_with_stricts # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # -class ProcessableImage::Validator::WithStrict < ApplicationRecord +class ProcessableFile::Validator::WithStrict < ApplicationRecord class StrictException < StandardError; end has_one_attached :with_strict - validates :with_strict, processable_image: true, strict: StrictException + validates :with_strict, processable_file: true, strict: StrictException end diff --git a/test/dummy/app/models/processable_image/validator/with_unless.rb b/test/dummy/app/models/processable_file/validator/with_unless.rb similarity index 54% rename from test/dummy/app/models/processable_image/validator/with_unless.rb rename to test/dummy/app/models/processable_file/validator/with_unless.rb index 9ac77538..98f662d6 100644 --- a/test/dummy/app/models/processable_image/validator/with_unless.rb +++ b/test/dummy/app/models/processable_file/validator/with_unless.rb @@ -2,7 +2,7 @@ # == Schema Information # -# Table name: processable_image_validator_with_unlesses +# Table name: processable_file_validator_with_unlesses # # rating :integer # id :integer not null, primary key @@ -10,11 +10,11 @@ # updated_at :datetime not null # -class ProcessableImage::Validator::WithUnless < ApplicationRecord +class ProcessableFile::Validator::WithUnless < ApplicationRecord has_one_attached :with_unless has_one_attached :with_unless_proc - validates :with_unless, processable_image: true, unless: :rating_is_good? - validates :with_unless_proc, processable_image: true, unless: -> { self.rating == 0 } + validates :with_unless, processable_file: true, unless: :rating_is_good? + validates :with_unless_proc, processable_file: true, unless: -> { self.rating == 0 } def rating_is_good? rating >= 4 diff --git a/test/dummy/app/models/processable_image.rb b/test/dummy/app/models/processable_image.rb deleted file mode 100644 index b0837417..00000000 --- a/test/dummy/app/models/processable_image.rb +++ /dev/null @@ -1,5 +0,0 @@ -module ProcessableImage - def self.table_name_prefix - 'processable_image_' - end -end diff --git a/test/dummy/app/models/processable_image/matcher.rb b/test/dummy/app/models/processable_image/matcher.rb deleted file mode 100644 index c8a8067a..00000000 --- a/test/dummy/app/models/processable_image/matcher.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: processable_image_matchers -# -# title :string -# id :integer not null, primary key -# created_at :datetime not null -# updated_at :datetime not null -# - -class ProcessableImage::Matcher < ApplicationRecord - include Validatable - - has_one_attached :custom_matcher - validates :custom_matcher, processable_image: true - - has_one_attached :processable - validates :processable, processable_image: true - - has_one_attached :with_message - validates :with_message, processable_image: { message: 'Custom message' } - - has_one_attached :with_context_symbol - validates :with_context_symbol, processable_image: true, on: :update - has_one_attached :with_context_array - validates :with_context_array, processable_image: true, on: %i[update custom] - has_one_attached :with_several_validators_and_contexts - validates :with_several_validators_and_contexts, processable_image: true, on: :update - validates :with_several_validators_and_contexts, processable_image: true, on: :custom - - has_one_attached :as_instance - validates :as_instance, processable_image: true - - has_one_attached :validatable_different_error_messages - validates :validatable_different_error_messages, processable_image: { message: 'Custom message 1' }, if: :title_is_quo_vadis? - validates :validatable_different_error_messages, processable_image: { message: 'Custom message 2' }, if: :title_is_american_psycho? - - has_one_attached :failure_message - validates :failure_message, processable_image: true - has_one_attached :failure_message_when_negated - validates :failure_message_when_negated, processable_image: true - - has_one_attached :not_processable -end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 4119de38..82e5e6a1 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -43,7 +43,7 @@ content_type dimension limit - processable_image + processable_file size total_size ).each do |validator| @@ -86,7 +86,7 @@ aspect_ratio content_type dimension - processable_image + processable_file ).each do |validator| create_table :"#{validator}_validator_using_attachables", force: :cascade do |t| t.datetime :created_at, null: false diff --git a/test/matchers/processable_image_validator_matcher_test.rb b/test/matchers/processable_file_validator_matcher_test.rb similarity index 84% rename from test/matchers/processable_image_validator_matcher_test.rb rename to test/matchers/processable_file_validator_matcher_test.rb index 15328894..436a448a 100644 --- a/test/matchers/processable_image_validator_matcher_test.rb +++ b/test/matchers/processable_file_validator_matcher_test.rb @@ -9,7 +9,7 @@ require 'matchers/shared_examples/works_with_context' require 'matchers/shared_examples/works_with_custom_message' -describe ActiveStorageValidations::Matchers::ProcessableImageValidatorMatcher do +describe ActiveStorageValidations::Matchers::ProcessableFileValidatorMatcher do include MatcherHelpers include ChecksIfIsAValidActiveStorageAttribute @@ -18,10 +18,10 @@ include HasValidRspecMessageMethods include WorksWithBothInstanceAndClass - let(:matcher) { ActiveStorageValidations::Matchers::ProcessableImageValidatorMatcher.new(model_attribute) } - let(:klass) { ProcessableImage::Matcher } + let(:matcher) { ActiveStorageValidations::Matchers::ProcessableFileValidatorMatcher.new(model_attribute) } + let(:klass) { ProcessableFile::Matcher } - describe "#validate_processable_image_of" do + describe "#validate_processable_file_of" do include HasCustomMatcher end diff --git a/test/matchers/shared_examples/checks_if_is_valid.rb b/test/matchers/shared_examples/checks_if_is_valid.rb index e0a0a150..60bc7b81 100644 --- a/test/matchers/shared_examples/checks_if_is_valid.rb +++ b/test/matchers/shared_examples/checks_if_is_valid.rb @@ -10,7 +10,7 @@ module ChecksIfIsValid when :aspect_ratio then matcher.allowing(:square) when :attached then matcher when :content_type then matcher.rejecting('image/jpg') - when :processable_image then matcher + when :processable_file then matcher when :limit then matcher.min(1) when :dimension then matcher.width(150) when :size then matcher.less_than(10.megabytes) diff --git a/test/matchers/shared_examples/has_custom_matcher.rb b/test/matchers/shared_examples/has_custom_matcher.rb index 64321de1..055cc504 100644 --- a/test/matchers/shared_examples/has_custom_matcher.rb +++ b/test/matchers/shared_examples/has_custom_matcher.rb @@ -13,7 +13,7 @@ class ActiveSupport::TestCase case validator_sym when :aspect_ratio then custom_matcher_builder.validate_aspect_ratio_of(model_attribute).allowing(:square) when :attached then custom_matcher_builder.validate_attached_of(model_attribute) - when :processable_image then custom_matcher_builder.validate_processable_image_of(model_attribute) + when :processable_file then custom_matcher_builder.validate_processable_file_of(model_attribute) when :limit then custom_matcher_builder.validate_limits_of(model_attribute).min(1).max(5) when :content_type then custom_matcher_builder.validate_content_type_of(model_attribute).allowing('image/png') when :dimension then custom_matcher_builder.validate_dimensions_of(model_attribute).width(150).height(150) diff --git a/test/matchers/shared_examples/has_valid_rspec_message_methods.rb b/test/matchers/shared_examples/has_valid_rspec_message_methods.rb index ed633812..3affc1d0 100644 --- a/test/matchers/shared_examples/has_valid_rspec_message_methods.rb +++ b/test/matchers/shared_examples/has_valid_rspec_message_methods.rb @@ -7,7 +7,7 @@ module HasValidRspecMessageMethods case validator_sym when :aspect_ratio then matcher.rejecting(:square) when :attached then matcher - when :processable_image then matcher + when :processable_file then matcher when :limit then matcher.min(0).max(6) when :content_type then matcher.rejecting('image/png') when :dimension then matcher.width(75).height(75) @@ -29,7 +29,7 @@ module HasValidRspecMessageMethods <<~FAILURE_MESSAGE is expected to validate attachment of :#{model_attribute} FAILURE_MESSAGE - when :processable_image + when :processable_file <<~FAILURE_MESSAGE is expected to validate the processable image of :#{model_attribute} FAILURE_MESSAGE @@ -80,7 +80,7 @@ module HasValidRspecMessageMethods case validator_sym when :aspect_ratio then matcher.allowing(:square) when :attached then matcher - when :processable_image then matcher + when :processable_file then matcher when :limit then matcher.min(1).max(5) when :content_type then matcher.allowing('image/png') when :dimension then matcher.width(150).height(150) @@ -102,7 +102,7 @@ module HasValidRspecMessageMethods <<~FAILURE_MESSAGE is expected not to validate attachment of :#{model_attribute} FAILURE_MESSAGE - when :processable_image + when :processable_file <<~FAILURE_MESSAGE is expected not to validate the processable image of :#{model_attribute} FAILURE_MESSAGE diff --git a/test/matchers/shared_examples/works_with_both_instance_and_class.rb b/test/matchers/shared_examples/works_with_both_instance_and_class.rb index f5c32338..5e07143d 100644 --- a/test/matchers/shared_examples/works_with_both_instance_and_class.rb +++ b/test/matchers/shared_examples/works_with_both_instance_and_class.rb @@ -7,7 +7,7 @@ module WorksWithBothInstanceAndClass case validator_sym when :aspect_ratio then matcher.allowing(:square) when :attached then nil - when :processable_image then nil + when :processable_file then nil when :limit then matcher.min(1).max(5) when :content_type then matcher.allowing('image/png') when :dimension then matcher.width(150).height(150) diff --git a/test/matchers/shared_examples/works_with_custom_message.rb b/test/matchers/shared_examples/works_with_custom_message.rb index 9f22b9b2..d55cd21a 100644 --- a/test/matchers/shared_examples/works_with_custom_message.rb +++ b/test/matchers/shared_examples/works_with_custom_message.rb @@ -9,7 +9,7 @@ module WorksWithCustomMessage case validator_sym when :aspect_ratio then matcher.allowing(:square) when :attached then nil - when :processable_image then nil + when :processable_file then nil when :limit then matcher.min(1).max(5) when :content_type then matcher.allowing('image/png') when :dimension then matcher.width(150).height(150) diff --git a/test/support/files.rb b/test/support/files.rb index 906e8b58..be2fe6c1 100644 --- a/test/support/files.rb +++ b/test/support/files.rb @@ -201,6 +201,14 @@ def not_identifiable_io_file } end +def audio_file + { + io: File.open(Rails.root.join('public', 'audio.mp3')), + filename: 'audio', + content_type: 'audio/mp3' + } +end + def video_file { io: File.open(Rails.root.join('public', 'video.mp4')), diff --git a/test/validators/integration/integration_test.rb b/test/validators/integration/integration_test.rb index 175bb8e1..a1770622 100644 --- a/test/validators/integration/integration_test.rb +++ b/test/validators/integration/integration_test.rb @@ -23,8 +23,8 @@ end it { is_expected_not_to_be_valid } - it { is_expected_to_have_error_message("image_not_processable", error_options: error_options, validator: :processable_image) } - it { is_expected_to_have_error_options(error_options, validator: :processable_image) } + it { is_expected_to_have_error_message("file_not_processable", error_options: error_options, validator: :processable_file) } + it { is_expected_to_have_error_options(error_options, validator: :processable_file) } end end diff --git a/test/validators/processable_image_validator_test.rb b/test/validators/processable_file_validator_test.rb similarity index 50% rename from test/validators/processable_image_validator_test.rb rename to test/validators/processable_file_validator_test.rb index b22584b8..63f27c52 100644 --- a/test/validators/processable_image_validator_test.rb +++ b/test/validators/processable_file_validator_test.rb @@ -4,10 +4,10 @@ require 'validators/shared_examples/works_fine_with_attachables' require 'validators/shared_examples/works_with_all_rails_common_validation_options' -describe ActiveStorageValidations::ProcessableImageValidator do +describe ActiveStorageValidations::ProcessableFileValidator do include ValidatorHelpers - let(:validator_test_class) { ProcessableImage::Validator } + let(:validator_test_class) { ProcessableFile::Validator } let(:params) { {} } describe 'Validator checks' do @@ -15,15 +15,25 @@ let(:model) { validator_test_class::Check.new(params) } - describe 'when provided with an image that is processable' do - # validates :has_to_be_processable, processable_image: true - subject { model.has_to_be_processable.attach(image_1920x1080_file) and model } + %w(image video audio).each do |media_type| + describe "when provided with a #{media_type} that is processable" do + # validates :has_to_be_processable, processable_file: true + subject { model.has_to_be_processable.attach(processable_file) and model } - it { is_expected_to_be_valid } + let(:processable_file) do + case media_type + when 'image' then image_1920x1080_file + when 'video' then video_file + when 'audio' then audio_file + end + end + + it { is_expected_to_be_valid } + end end - describe 'when provided with an image that is not processable' do - # validates :has_to_be_processable, processable_image: true + describe 'when provided with a file that is not processable' do + # validates :has_to_be_processable, processable_file: true subject { model.has_to_be_processable.attach(tar_file_with_image_content_type) and model } let(:error_options) do @@ -33,12 +43,12 @@ end it { is_expected_not_to_be_valid } - it { is_expected_to_have_error_message("image_not_processable", error_options: error_options) } + it { is_expected_to_have_error_message("file_not_processable", error_options: error_options) } it { is_expected_to_have_error_options(error_options) } end describe 'when provided with a StringIO that is an image' do - # validates :has_to_be_processable, processable_image: true + # validates :has_to_be_processable, processable_file: true subject { model.has_to_be_processable.attach(image_string_io) and model } it { is_expected_to_be_valid } diff --git a/test/validators/shared_examples/checks_validator_validity.rb b/test/validators/shared_examples/checks_validator_validity.rb index 6239ebfc..72eee0ea 100644 --- a/test/validators/shared_examples/checks_validator_validity.rb +++ b/test/validators/shared_examples/checks_validator_validity.rb @@ -14,7 +14,7 @@ module ChecksValidatorValidity when :content_type then 'You must pass either :with or :in to the validator' when :dimension then 'You must pass either :width, :height, :min or :max to the validator' when :limit then 'You must pass either :max or :min to the validator' - when :processable_image then not_applicable + when :processable_file then not_applicable when :size then 'You must pass either :less_than(_or_equal_to), :greater_than(_or_equal_to), or :between to the validator' when :total_size then 'You must pass either :less_than(_or_equal_to), :greater_than(_or_equal_to), or :between to the validator' end diff --git a/test/validators/shared_examples/works_with_allow_blank_option.rb b/test/validators/shared_examples/works_with_allow_blank_option.rb index 3c0d9cf7..e303f1ba 100644 --- a/test/validators/shared_examples/works_with_allow_blank_option.rb +++ b/test/validators/shared_examples/works_with_allow_blank_option.rb @@ -11,7 +11,7 @@ module WorksWithAllowBlankOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then nil - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithAllowBlankOption when :content_type then html_file when :dimension then image_700x500_file when :limit then file_5ko - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_allow_nil_option.rb b/test/validators/shared_examples/works_with_allow_nil_option.rb index 46486a8c..350b0fb3 100644 --- a/test/validators/shared_examples/works_with_allow_nil_option.rb +++ b/test/validators/shared_examples/works_with_allow_nil_option.rb @@ -11,7 +11,7 @@ module WorksWithAllowNilOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then nil - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithAllowNilOption when :content_type then html_file when :dimension then image_700x500_file when :limit then file_5ko - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_if_option.rb b/test/validators/shared_examples/works_with_if_option.rb index e1b46f61..4f5acbc3 100644 --- a/test/validators/shared_examples/works_with_if_option.rb +++ b/test/validators/shared_examples/works_with_if_option.rb @@ -11,7 +11,7 @@ module WorksWithIfOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then image_150x150_file - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithIfOption when :content_type then html_file when :dimension then image_700x500_file when :limit then nil - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_message_option.rb b/test/validators/shared_examples/works_with_message_option.rb index c4d4e3d5..4211bfb8 100644 --- a/test/validators/shared_examples/works_with_message_option.rb +++ b/test/validators/shared_examples/works_with_message_option.rb @@ -11,7 +11,7 @@ module WorksWithMessageOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then nil - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithMessageOption when :content_type then html_file when :dimension then image_700x500_file when :limit then file_5ko - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_on_option.rb b/test/validators/shared_examples/works_with_on_option.rb index d71036df..80ed012e 100644 --- a/test/validators/shared_examples/works_with_on_option.rb +++ b/test/validators/shared_examples/works_with_on_option.rb @@ -11,7 +11,7 @@ module WorksWithOnOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then image_150x150_file - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithOnOption when :content_type then html_file when :dimension then image_700x500_file when :limit then nil - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_strict_option.rb b/test/validators/shared_examples/works_with_strict_option.rb index debebe9c..1339dfab 100644 --- a/test/validators/shared_examples/works_with_strict_option.rb +++ b/test/validators/shared_examples/works_with_strict_option.rb @@ -11,7 +11,7 @@ module WorksWithStrictOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then image_150x150_file - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithStrictOption when :content_type then html_file when :dimension then image_700x500_file when :limit then nil - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end diff --git a/test/validators/shared_examples/works_with_unless_option.rb b/test/validators/shared_examples/works_with_unless_option.rb index e712a6cf..7e54b08e 100644 --- a/test/validators/shared_examples/works_with_unless_option.rb +++ b/test/validators/shared_examples/works_with_unless_option.rb @@ -11,7 +11,7 @@ module WorksWithUnlessOption when :content_type then webp_file when :dimension then image_150x150_file when :limit then image_150x150_file - when :processable_image then image_150x150_file + when :processable_file then image_150x150_file when :size then file_1ko when :total_size then [blob_file_0_5ko, blob_file_0_5ko] end @@ -23,7 +23,7 @@ module WorksWithUnlessOption when :content_type then html_file when :dimension then image_700x500_file when :limit then nil - when :processable_image then tar_file_with_image_content_type + when :processable_file then tar_file_with_image_content_type when :size then file_5ko when :total_size then [blob_file_5ko, blob_file_5ko] end