rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.
MIT License
228 stars 92 forks source link

attribute_sanitization_test: avoid random failures #89

Closed terceiro closed 8 years ago

terceiro commented 8 years ago

Because test/test_helper.rb sets the tests to run on random order, that missing call to super will cause tests to crash with the following exception, depending on which order the test classes get loaded.

ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: UNIQUE
constraint failed: people.id: INSERT INTO "people" ("id", "first_name", "gender", "comments", "best_friend_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)

On my tests, this seems to happen more or less 6% of the time (i.e. 3 out of 50 runs). With this change, I was able to make 50 runs without a single failure.

rails-bot commented 8 years ago

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.