This project is archived and is in readonly mode.
Validates_acceptance_of is not respecting database field
-
Santiago Pastorino
Can you provide at least a test case?.
Thanks. -
Si
Sure!
I wasn't set up for tests in the activemodel area before, primarily due to a MySQL dependency. Here's a patch to use database backing for the terms_of_service field used in acceptance validation. The Eula test continues to test a non db-backed-field.
-
Ryan Bigg
- State changed from new to needs-more-info
-
James Sadler
Si,
The diff you attached is not sufficient by itself to constitute a test case. All it does is add a column to the schema definition but makes no assertions, about what the expected behaviour should be. If you could provide a fragment of code that demonstrates the breakage and/or explain the issue in more detail, that'd be great.
James.
-
Si
Hi James,
I'm not a fan of the style employed by AcceptanceValidationTest. The tests are named according to attribute tested (e.g. test_eula), instead of explicitly stating what is being tested. It requires poking around in the model and schema to discover exactly what terms_of_service and eula are. The expected behaviour remains exactly the same however (test terms_of_service acceptance for example), and yet breaks for me when that field is a regular db attribute.
So my diff is merely going along with the voodoo right now. With that patch in place, everything should continue to work, with better code coverage, but it doesn't. I certainly think the test methods should be renamed, bringing some clarity about the nature of the underlying attribute, and some tests should be duplicated too for better coverage, but sadly I'm not in the position to right now. I'm seeing some very funky setup / test / teardown interplay, and changing method names throws everything. Being an RSpec user, perhaps I'm missing something obvious.
Anyway, thanks for looking into this.
-
Santiago Pastorino
- Milestone cleared.
- State changed from needs-more-info to verified
- Assigned user set to Santiago Pastorino
We have all the needed info, i'm fixing this i have a failing test now here.
http://github.com/spastorino/rails/commit/d2e24a242c91161ec4cb9e7f6... -
Repository
- State changed from verified to committed
(from [ce48b3103acd2f58931aa42b93073592b291114e]) Makes validates_acceptance_of to not override database fields [#4460 Validates_acceptance_of is not respecting database field state:committed]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/ce48b3103acd2f58931aa42b930735... -
Si
I can verify that this patch resolves my issue. Thanks Santiago!
-
Santiago Pastorino
You're welcome Si ;)
