CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

remove anonymous function

Open pxpm opened this issue 3 years ago • 2 comments

WHY

BEFORE - What was wrong? What was happening before this PR?

Using the anonymous class to extend the request class was leading to problems when parallel testing. https://github.com/Laravel-Backpack/CRUD/issues/4389 I always thought that this anonymous class solution was either genious or stupid, guess what I found out ? 🤡

AFTER - What is happening after this PR?

I found out a better solution to merge the rules/messages in the request and validate it.

HOW

How did you achieve that, in technical terms?

Looked at it with a fresh perspective! 🙄

Is it a breaking change?

no

How can we test the before & after?

everything should keep working/validating when using this 👍

pxpm avatar Jul 18 '22 14:07 pxpm

Haha that's some great copy there @pxpm 😅 I'll let @promatik review and test this first, since it needs extensive testing. We gotta be sure nothing breaks.

tabacitu avatar Jul 19 '22 07:07 tabacitu

@promatik I refactored as per our comments.

I think this cover all the cases, can you give this a new go and let me know if you found any inconsistency ?

Cheers

pxpm avatar Jul 25 '22 10:07 pxpm

@pxpm let's please add unit tests for this. A bunch of them - covering all combinations of the types of validations we have... in all possible orders:

  • FormRequest
  • Array
  • Field

tabacitu avatar Oct 24 '22 15:10 tabacitu

Hello @tabacitu I've just finished writing the tests for the validation class and I merged them here.

image

I assigned @jorgetwgroup to review the PR, but I think we are done here and can merge this as it is.

Cheers

pxpm avatar Dec 08 '22 12:12 pxpm

OMG SO MUCH GREEN! I LOVE IT!

dancing-gif

This being an important part of the form... let's let @jorgetwgroup give this a quick manual test anyway, to make sure nothing's breaking. If we have GREEN LIGHT from him too (🤭), free to merge @pxpm

tabacitu avatar Dec 08 '22 13:12 tabacitu

hi @pxpm

First you know im not expert on test files, but always when i run this test i get this error.

Screenshot 2022-12-19 at 18 13 07

I have this branches: CRUD: refactor-request-anonymous-function (this) PRO: main Demo: main

Let me know if i miss something.

Cheers.

jcastroa87 avatar Dec 19 '22 21:12 jcastroa87

Hey @jorgetwgroup so sorry, my bad! 😞

addFields() should be an array of arrays, not an array of fields. Dumb mistake!

I fixed it, and took the opportunity to better write a test that I was not 100% confortable with. Now I am 👍

If you think this is ready after my last commit, let's do this 💪

pxpm avatar Dec 20 '22 13:12 pxpm

Hello @pxpm as we check everything is working now.

Screenshot 2022-12-20 at 12 13 57

Look ready to merge.

Thanks.

jcastroa87 avatar Dec 20 '22 15:12 jcastroa87

The inspection completed: 12 new issues, 15 updated code elements

scrutinizer-notifier avatar Dec 20 '22 15:12 scrutinizer-notifier