shoulda-matchers v3.1.1 Release Notes

Release Date: 2016-01-28 // about 8 years ago
  • ๐Ÿ› Bug fixes

    • ๐Ÿ‘ Some matchers make use of ActiveSupport's in? method, but do not include the file where this is defined in ActiveSupport. This causes problems with projects using shoulda-matchers that do not include all of ActiveSupport by default. To fix this, replace in? with Ruby's builtin include?. (#879)

    • validate_uniqueness_of works by creating a record if it doesn't exist, and then testing against a new record with various attributes set that are equal to (or different than) corresponding attributes in the existing record. In 3.1.0 a change was made whereby when the uniqueness matcher is given a new record and creates an existing record out of it, it ensures that the record is valid before continuing on. This created a problem because if the subject, before it was saved, was empty and therefore in an invalid state, it could not effectively be saved. While ideally this should be enforced, doing so would be a backward-incompatible change, so this behavior has been rolled back. (#880, #884, #885, 45de869)

    • Fix an issue with validate_uniqueness_of + scoped_to when used against a model where the attribute has multiple uniqueness validations and each validation has a different set of scopes. In this case, a test written for the first validation (and its scopes) would pass, but tests for the other validations (and their scopes) would not, as the matcher only considered the first set of scopes as the actual set of scopes. (#830, 28bd9a1)

    ๐Ÿ‘Œ Improvements

    • Update validate_uniqueness_of so that if an existing record fails to be created because a column is non-nullable and was not filled in, raise an ExistingRecordInvalid exception with details on how to fix the test. (78ccfc5)