discourse/spec/components/validators
Sam a7628c1d74 FIX: use ordered_posts for last post check, not the posts relation
The `posts` relation on `Topic` is not ordered. Using `Topic.posts.first`
is basically the same as asking for a random post, it will depend on DB
order. This breaks on Topic merge and split for example.

Additionally, a huge problem with that is that it forces active record down
a slow path. `Topic.posts.first` is extremely slow on giant topics, since
it has no default ordering it appears AR materializes the entire set prior
to doing `first`.

This commit also illustrates the importance of testing, initially I only
fixed the second instance of the problem in `post_validator.rb` but testing
revealed that the problem was repeated at the top of the file.

Longer term we should consider a larger change of default ordering the posts
relations so people do not fall down this trap anymore.
2019-01-18 13:18:40 +11:00
..
allowed_ip_address_validator_spec.rb Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
email_setting_validator_spec.rb Prepare for separation of RSpec helper files 2015-12-01 20:39:42 +00:00
email_validator_spec.rb SECURITY: email domain whitelist could be bypassed 2018-01-17 21:45:32 +01:00
enable_local_logins_via_email_validator_spec.rb FEATURE: login by a link from email 2018-02-13 16:14:39 +08:00
enable_sso_validator_spec.rb FIX: verify presence of 'sso url' before enabling 'enable sso' 2017-12-23 13:30:49 +05:30
integer_setting_validator_spec.rb correct spec 2017-08-24 10:40:14 -04:00
ip_address_format_validator_spec.rb Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
max_emojis_validator_spec.rb FIX: count emoji shortcuts in topic title 2018-10-22 13:44:05 +05:30
max_username_length_validator_spec.rb UX: Improve error messages for minimum and maximum username lengths. 2018-10-02 13:10:20 +08:00
min_username_length_validator_spec.rb UX: Improve error messages for minimum and maximum username lengths. 2018-10-02 13:10:20 +08:00
password_validator_spec.rb FIX: Password required flag should be cleared whenever clearing the raw password (#5384) 2017-12-01 15:19:24 +11:00
post_validator_spec.rb FIX: use ordered_posts for last post check, not the posts relation 2019-01-18 13:18:40 +11:00
quality_title_validator_spec.rb Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
regex_presence_validator_spec.rb FIX: validate presence of 'top menu' setting 2018-01-17 01:43:53 +05:30
regex_setting_validator_spec.rb FEATURE: add censored_pattern setting to censor posts using regex 2016-11-08 16:39:26 -05:00
reply_by_email_address_validator_spec.rb DEV: Refactor some mail receiver related specs. 2018-08-21 14:00:45 +08:00
reply_by_email_enabled_validator_spec.rb FEATURE: new 'manual_polling_enabled' site setting 2016-03-16 22:28:01 +01:00
sso_overrides_email_validator_spec.rb fix the build 2017-12-23 14:42:40 +05:30
string_setting_validator_spec.rb Prepare for separation of RSpec helper files 2015-12-01 20:39:42 +00:00
topic_title_length_validator_spec.rb rename 'min_private_message_{post/title}_length' to 'min_personal_message_{post/title}_length' 2018-02-01 13:25:29 +05:30
upload_validator_spec.rb FEATURE: Upload Site Settings. (#6573) 2018-11-14 15:03:02 +08:00
url_validator_spec.rb Treat non-ascii URLs in UrlValidator. 2017-12-21 14:22:55 +08:00
user_full_name_validator_spec.rb Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
username_setting_validator_spec.rb allow regex options on username site settings 2017-10-04 15:08:51 -04:00