42 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
232c855c54 Fix tests with Rails main
Rails main / 7.1.0.alpha introduced a change to improve typography by
default, by converting all apostrophes to be single quotation marks.
https://github.com/rails/rails/pull/45463

The change caused all our text based matching to fail, this updates the
tests to ensure compatibility.

Model tests were changed to test against the error type & information
rather than the translated string, which I think is an improvement
overall that should make them a little less brittle. I thought of using
[of_kind?] but that isn't available on all Rails versions we currently
support, while `added?` is. The drawback is that `added?` require full
details like the `:confirmation` example which requires the related
attribute that is being confirmed, but that's a small price to pay.

Integration tests were changed to match on a regexp that accepts both
quotes. I could've used a simple `.` to match anything there, but
thought I'd just keep it specific for clarity on what it is really
expected to match there. Plus, since it's integration testing against a
rendered response body, it's better to match the actual text rather than
resort on other ways. (like using I18n directly, etc.)

[of_kind?] https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-of_kind-3F
2023-03-17 10:59:55 -03:00
tabakazu
8acbdd6d93 Replace matcher refute to assert_not 2023-03-02 18:38:04 -03:00
Carlos Antonio da Silva
ee8f0f8e83 Fix frozen string in validatable, use multiline string instead. (#5563)
Expand tests to check for the actual validatable exception message

This was raising a `FrozenError` on Ruby < 3 where interpolated strings
were considered frozen. This [changed in Ruby 3], since such strings are
dynamic there's no point in freezing them by default.

The test wasn't catching this because `FrozenError` actually inherits
from `RuntimeError`:

>> FrozenError.ancestors
=> [FrozenError, RuntimeError, StandardError, Exception, Object ...]

So the exception check passed. Now we're also checking for the error
message to ensure it raised the exception we really expected there.

Closes #5465

[changed in Ruby 3] https://bugs.ruby-lang.org/issues/17104

Co-authored-by: Martin <martin@edv-beratung-meier.de>
2023-03-01 19:56:25 -03:00
Carlos Antonio da Silva
e39b9b9134 Fix order of arguments for assert_equal on tests
Use `assert_equal expected, actual` for proper error messages in case of
failures.
2020-08-27 18:24:17 -03:00
Pat Allan
f39c6fd927 Add the frozen_string_literal pragma comment to all Ruby files. (#4725) 2017-12-21 15:36:29 -02:00
Pat Allan
4e9860d268 Ensure string literals can be frozen. 2017-06-21 09:22:49 +10:00
Lucas Mazza
536279b05b Replace homemade assert_not matcher in favor of refute. 2016-05-03 13:57:10 -03:00
kimgb
830d3e86ee updated email_regexp and added test cases (#4001)
Add a more permissive default e-mail regex.
2016-04-26 11:13:07 -03:00
Thomas Walpole
2024fca4df Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1 2015-12-11 09:47:30 -08:00
Logan Leger
c7cc91cb65 Update password length validation to 72 characters max
BCrypt has a limit of 72 characters for the password. Anything beyond 72
characters is truncated. This commit updates the validation to limit
passwords to less than 72 characters, keeping within the limitation.
2014-11-18 23:10:01 -06:00
alexsoble
039b75ba83 Incorporated edits from @lucasmazza, wrote integration tests for password reminder feature 2014-08-06 11:04:46 -04:00
Anshul Sharma
dc1b399a8b Updated ruby 1.9 hash syntax 2014-02-25 22:12:55 +05:30
Carlos Antonio da Silva
eb0ad1c21a Merge branch 'master' into rails4 2013-05-07 13:01:34 -03:00
Carlos Antonio da Silva
69f79ad446 Let Devise play with both Rails 3.2 and Rails 4 for now 2013-05-05 19:55:06 -03:00
Vipul A M
2e6457006e Remove unused variables and fix typos 2013-04-18 10:24:38 +05:30
Carlos Antonio da Silva
3c885e043d Fix changed error messages from confirmation validation 2013-02-25 22:12:06 -03:00
José Valim
bdf0bc7b1e Revert "Revert "New password default minimum length is now 8""
This reverts commit b1f490a2f8.
Actually, the implementation was good!
2012-07-24 23:41:17 +02:00
José Valim
b1f490a2f8 Revert "New password default minimum length is now 8"
This reverts commit 2950434ed3.
It is backwards incompatible, we need a better migration plan.
2012-07-24 22:41:13 +02:00
Rodrigo Flores
2950434ed3 New password default minimum length is now 8 2012-07-06 13:41:28 -03:00
Carlos Galdino
c179cef365 Change the minimum password length to 8 2012-07-06 11:46:46 -03:00
Rodrigo Flores
6d5bccc050 Added required fields to validatable 2012-02-24 20:57:58 -02:00
Rodrigo Flores
18aef6ac33 Some refactor 2012-02-22 13:55:03 -02:00
George Guimarães
b190fa38c7 typo 2012-02-17 19:15:46 -02:00
José Valim
7b1418be3b Improve the regexp a bit more. 2011-08-29 14:55:56 +02:00
José Valim
a8d9695324 Simplify regexp and ensure it runs against UTF8 chars, closes #1235 2011-08-29 13:15:40 +02:00
Benjamin Quorning
a3bff7d6a2 Fix usage of "its" / "it's" in documentation 2011-08-16 22:15:25 +02:00
Gabe da Silveira
3488066031 Spelling correction 2011-07-29 14:17:31 -07:00
Thibaut
92c9ed2d6c Don't validate email format and uniqueness unless it's changed. 2011-05-07 19:02:44 +02:00
José Valim
a59410a254 password_required? should not affect length validation, closes #1037. 2011-04-29 08:33:33 +02:00
Rodrigo Flores
a229627a54 Removed failing test cases on e-mail validations 2011-04-19 20:16:20 +08:00
Matias Korhonen
8db00eedea Bump the password maximum length to 128 characters. 2011-04-15 16:39:01 +08:00
José Valim
c5999c8f61 Tests green on mongoid as well. 2010-07-26 20:25:02 +02:00
José Valim
7774accb6c Remove data_mapper support.
Devise 1.1.0 will be released soon. This new version will support activerecord and mongoid as default ORMs. From now on, Devise will prefer ORM extensions as gems since this is the best way to handle dependencies.

For example, to allow Devise to work with Datamapper, it requires at least activemodel, dm-rails and dm-timestamps. If the ORM support comes from Devise gem, we cannot add dm-rails and dm-timestamps as dependencies, relying on the developer and documentation to find these out and install them.

Other ORMs may still be added to Devise, as long as they are supported by the community, extend Devise test suite to have all tests passing and they necessarily use ActiveModel::Validations.
2010-07-04 17:22:57 +02:00
Jacques Crocker
e127463ac8 Adding Mongoid 2.0 Support, Removing MongoMapper for now 2010-03-26 13:37:38 -07:00
José Valim
ca4e09390e Compatibility with Ruby 1.9.1 and 1.9.2. 2010-03-26 11:27:19 +01:00
José Valim
b3e11c5aca Got another bunch of tests passing on Rails 3. 369 tests, 731 assertions, 33 failures, 53 errors. 2010-02-16 14:57:10 +01:00
Jonas Grimfelt
0c7c762c16 Fixed some Ruby 1.9 issues/bugs. 2010-01-21 16:06:19 +08:00
José Valim
78303cd5c5 Got another bunch of tests passing with MongoMapper. 2009-12-21 19:57:17 +01:00
José Valim
52885725a9 Assert validations API inside validatable module. 2009-11-24 13:56:54 -02:00
Carlos A. da Silva
198167d978 Removing default mapping and Updating tests at all 2009-10-10 18:07:25 -03:00
Carlos A. da Silva
ba7e74e1a1 Refactoring confirmable and recoverable to use the same default find method by perishable token. 2009-10-09 07:36:12 -03:00
Carlos A. da Silva
3655fe9096 Restructuring directories for models and mailers. 2009-09-20 10:35:26 -03:00