AaronLasseigne / active_interaction

:briefcase: Manage application specific business logic.
MIT License
2.06k stars 136 forks source link

Interactions stay valid after changing filter values directly #523

Closed tomasdundacek closed 2 years ago

tomasdundacek commented 2 years ago

Hi, I have encountered the following "bug", I'm rather asking for the intentions behind the commit below or if there possibly is a bug indeed:

Summary The commit https://github.com/AaronLasseigne/active_interaction/commit/abb5de10da0f2048ef600e9a50cb00de6b136fba (in version 4.0.2) has broken the cooperation between ActiveInteraction and shoulda-matchers, since interaction filter instance variables are now separated from original inputs.

Example app The app has one rspec test:

Sidenote: the app uses rails 6, since rails 7 was not supported when AI 4.0.2 was released

Solution I'm not sure, why the commit mentioned above was introduced, so I am not sure what the solution to this issue is. I am also aware, that calling .new on an interaction is not an intended way of using this gem, but it really helps while testing validations :)

Thanks!

AaronLasseigne commented 2 years ago

I didn't realize the "should" matchers were still supported by RSpec.

AaronLasseigne commented 2 years ago

I am also aware, that calling .new on an interaction is not an intended way of using this gem, but it really helps while testing validations :)

Calling .new is fine and is and intended use.

AaronLasseigne commented 2 years ago

interaction filter instance variables are now separated from original inputs

I'm not sure what you mean by that.

Ultimately, I surprised this ever worked. It was probably a bug that it did work. The gem doesn't use presence of validation. It has it's own check and adds the same error but it's not actually using validates :foo, presence: true in the code.