active_storage_validations icon indicating copy to clipboard operation
active_storage_validations copied to clipboard

validate_aspect_ratio_of show wrong number of arguments (given 1, expected 2)

Open sbrocos opened this issue 10 months ago • 2 comments

I have define this in mi model:

  validates :cover, attached: true,
                    content_type: %i[png jpeg],
                    aspect_ratio: :square,
                    dimension: { width: { min: 400, max: 1200 } }

And in the Rspec it { is_expected.to validate_aspect_ratio_of(:cover).allowing(:square) }

and obtain this the execute the test: Captura de pantalla 2024-04-03 a las 16 33 14

I show the code, and I don't understand what it's the problem with this validation.

Thanks for your work

sbrocos avatar Apr 03 '24 14:04 sbrocos

@sbrocos there's an issue with the initialization of the matcher class ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher. As a workaround you can do this:

it { is_expected.to ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher.new(:cover).allowing(:square) }

Hope this helps! o/

osmarluz avatar Apr 04 '24 08:04 osmarluz

Hi @sbrocos, I'll have a look at it, seems like an easy bug to fix.

Mth0158 avatar Apr 04 '24 17:04 Mth0158

Hi @sbrocos & @osmarluz, Thanks for the bug report, it has been corrected, it should be available in the new gem version soon :)

Mth0158 avatar Jul 04 '24 09:07 Mth0158