thoughtbot--shoulda-matchers/lib/shoulda/matchers/active_record
Elliot Winkler 9f0def1aa9 Remove secure password code from uniqueness matcher
The uniqueness matcher creates an existing version of the model under
test if one doesn't already exist (so that it can compare this existing
version with an unpersisted version which it modifies in various ways as
it steps through all of the various tests). Back in 2014, it would
create this existing version by simply making a new instance of the
model, setting the attribute under test to some value, and then saving
the instance. However, this step would fail if there were other
attributes on the model that were necessary to save the record.
Specifically, if the model had `has_secure_password` on it and
`password_digest` was not set, then [the record would fail on
save][issue-371], because of a `before_create` that got triggered by
`validates_uniqueness_of` to serve as a check. To fix this, then, it was
necessary to [set `password_digest` to some meaningful value][pr-426]
before saving the record.

Since then, [`has_secure_password` has been updated in
Rails][uniq-validation] so that instead of checking to see that
`password_digest` is set in a `before_create`, it runs a confirmation
validation on `password` (but only if `password` is set). So this step
won't fail anymore (unless `password` is somehow present on the model).
What this means is that we don't need to concern ourselves with password
attributes or digestible attributes in general, so we can remove the old
2014 code from the uniqueness matcher entirely.

[issue-371]: https://github.com/thoughtbot/shoulda-matchers/issues/371
[pr-426]: https://github.com/thoughtbot/shoulda-matchers/pull/426
[uniq-validation]: 8ca59237dd
2019-05-31 21:23:11 -06:00
..
association_matchers Improve messaging of .required and .optional 2019-02-14 17:48:26 -07:00
uniqueness Documentation updates 2014-12-25 01:13:30 -05:00
accept_nested_attributes_for_matcher.rb Update RSpec test style across docs 2016-06-15 18:02:07 -06:00
association_matcher.rb Add minimal support for Rails 6 2019-04-22 00:10:18 -04:00
association_matchers.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
define_enum_for_matcher.rb Add with_prefix and with_suffix to define_enum_for 2018-01-28 00:47:56 -06:00
have_db_column_matcher.rb Update RSpec test style across docs 2016-06-15 18:02:07 -06:00
have_db_index_matcher.rb Teach have_db_index about expression indexes 2019-05-31 00:12:10 -06:00
have_readonly_attribute_matcher.rb Update RSpec test style across docs 2016-06-15 18:02:07 -06:00
have_secure_token_matcher.rb Add matcher for has_secure_token 2017-10-15 21:07:58 -04:00
serialize_matcher.rb Update RSpec test style across docs 2016-06-15 18:02:07 -06:00
uniqueness.rb Move uniqueness validation to ActiveRecord module 2014-12-13 17:53:16 -05:00
validate_uniqueness_of_matcher.rb Remove secure password code from uniqueness matcher 2019-05-31 21:23:11 -06:00