docbrown/app/models
Daniel Uber 6f84f4afe8
Validate profile field "website url" is in fact a url (don't generate local path links). (#14302)
* Validate website_url profile field is a url

related to issue #14300

May need a data update script to (fixup? remove?) invalid profiles
since not being able to save existing profiles will cause problems.

* Check that URI is a valid url

Require the scheme to be one of https or http, not something like
mailto:// or telnet:// (nobody would do that, but don't try and link
to it if they did).

* Rubocop fixup for validation rule

URI::regexp is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp

Prefer %w[] literals for arrays of words

Prefer the new style validations `validates :column, format: value` to validates_format_of

* Permit empty website_url fields

The previous validation was rejecting nil, which was the default. This
caused a lot of user factory calls to fail (since users didn't need
website urls in the profiles during testing unless the test was about
the website url link).

* Use :url validation as suggested

* Update validation error message

The validate_url gem gives a more complete error message to the
user. Update the spec to expect this.

* Use url_field rather than text_field in profile form

https://apidock.com/rails/v6.1.3.1/ActionView/Helpers/FormHelper/url_field

* Add data update to either fixup or clear invalid website urls

Checking blazer there are about 2600 profiles with "invalid" website
urls, typically a hostname, sometimes a hostname + path component,
which should be fixed up.

Naively add https:// to the front of the url, check that a valid
scheme and host are present on the resulting url, and save.

If an invalid url is generated (specifically, if host or scheme are
nil), just set the website url (with the invalid link) to an empty
string.

It's possible we'd want to notify users affected by this, that was not
included in this pass.

* Skip validations for intentionally invalid test cases
2021-07-22 12:02:29 -05:00
..
ahoy [15 Min Fix]: Fix incorrect scope used by metrics:overview rake task (#13138) 2021-03-25 17:31:10 -07:00
articles Rubocop: Move from OpenStruct to Struct in Organization (#9431) 2020-07-30 21:04:05 +07:00
concerns Remove CustomProfileField (#14286) 2021-07-22 10:05:39 +07:00
liquid_tags [deploy] Add role and docs for user subscription liquid tag (#9170) 2020-07-08 14:07:53 -04:00
settings Allow setting nil value in Settings::Upsert (#14228) 2021-07-20 10:57:09 -04:00
users Fix brand color validation (#14303) 2021-07-22 09:35:20 +01:00
webhook Add missing presence validators to models (#10495) 2020-10-01 16:15:32 +02:00
admin_menu.rb feat: add the comments in the navbar (#14067) 2021-06-25 13:00:57 +02:00
announcement.rb Add Polymorphism to Broadcasts (Part 1) (#9231) [deploy] 2020-07-13 09:36:19 -06:00
api_secret.rb
application_record.rb Filter only ordinary tables in estimated count (#8913) 2020-06-25 14:04:13 -04:00
article.rb Allow multiple users to fetch all articles from the same RSS feed (#14160) 2021-07-19 15:15:32 +02:00
audit_log.rb Add missing presence validators to models (#10495) 2020-10-01 16:15:32 +02:00
badge.rb Refactor cache purging (#12811) 2021-03-02 10:09:05 -05:00
badge_achievement.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
banished_user.rb
broadcast.rb Fix Rails/HasManyOrHasOneDependent for Broadcast and Collection (#9662) 2020-08-07 14:27:24 -04:00
campaign.rb Split Settings::Campaign from SiteConfig (#13238) 2021-04-19 10:01:03 +07:00
chat_channel.rb 🚀 Ability to allow tag moderators to create chat channels (#9741) 2020-12-08 13:10:36 +07:00
chat_channel_membership.rb Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
collection.rb Fix Rails/HasManyOrHasOneDependent for Broadcast and Collection (#9662) 2020-08-07 14:27:24 -04:00
comment.rb Fix shorten_urls to not remove formatting and image tags (#14262) 2021-07-20 10:10:34 -04:00
config.rb
consumer_app.rb Make Consumer Apps dictate aasa results (#14015) 2021-06-24 08:36:11 -06:00
credit.rb Replace activerecord-import with Rails 6 insert_all and upsert_all (#8407) 2020-06-12 11:16:06 +02:00
data_update_script.rb Navigation Items and Role access for Data Update Scripts (#12292) 2021-02-09 17:41:14 +02:00
device.rb Bump rubocop from 1.15.0 to 1.16.0 (#13894) 2021-06-02 09:11:38 -04:00
discussion_lock.rb Create DiscussionLocks (#13905) 2021-06-10 11:04:33 -04:00
display_ad.rb Move CodeBlockParse and MarkdownParser to service (#12112) 2021-01-07 10:13:01 -05:00
display_ad_event.rb
email_authorization.rb Add missing presence validators to models (#10495) 2020-10-01 16:15:32 +02:00
email_message.rb Upgrade to Ahoy 2.0.x (#13085) 2021-04-06 10:12:32 -05:00
event.rb Rename MarkdownParser to MarkdownProcessor::Parser (#12248) 2021-01-13 10:39:13 -05:00
feedback_message.rb Add open reports count to admin overview (#13346) 2021-04-12 12:03:11 -05:00
follow.rb rubocop -a (#11674) 2020-11-30 14:50:13 +01:00
forem_instance.rb [15-Minute Fix] Ensure "Locked Screen" Checkbox Conditionally Renders (#14161) 2021-07-12 14:14:43 -06:00
github_issue.rb Replace need for GitHub ENV vars on bootup (#10372) 2020-09-18 11:21:31 -04:00
github_repo.rb Refactor cache purging (#12811) 2021-03-02 10:09:05 -05:00
html_variant.rb Fix html variant image prefix logic (#11917) 2020-12-15 14:44:11 -05:00
html_variant_success.rb [deploy] Add relations and foreign keys between HtmlVariant related models (#9846) 2020-08-18 11:33:38 -04:00
html_variant_trial.rb [deploy] Add relations and foreign keys between HtmlVariant related models (#9846) 2020-08-18 11:33:38 -04:00
identity.rb secure Identity#email in case of missing auth_data_dump hash (#11936) (#12322) 2021-01-18 19:27:07 -05:00
invitation.rb [deploy] Invite users to join and create password (#9294) 2020-07-15 11:37:19 -04:00
listing.rb Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
listing_category.rb [deploy] Manage listing categories in dashboard (#10506) 2020-10-02 11:05:09 -04:00
mention.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
message.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
mod.rb
moderator_action.rb
navigation_link.rb Static Sections for Site Navigation - Pt1 (#14213) 2021-07-14 11:01:56 -04:00
note.rb [deploy] Add missing dependent clauses to User and cleanup relations (#10011) 2020-08-28 20:19:24 +02:00
notification.rb Expand @-mention functionality to posts (#13367) 2021-05-12 07:33:33 -07:00
notification_subscription.rb Add missing presence validators to models (#10495) 2020-10-01 16:15:32 +02:00
organization.rb Organizations delete optimizations and refactoring (#13610) 2021-05-11 12:14:55 +03:00
organization_membership.rb Refactoring ChatChannel - distributing into services (#9253) 2020-08-07 10:41:34 +02:00
overview.rb Add admin overview page (#12726) 2021-03-01 18:59:05 -06:00
page.rb [15 min fix] Refactor private landing pages model code (#13982) 2021-06-15 18:17:15 +02:00
page_view.rb Declare winner in feed_top_articles_query test (#12308) 2021-02-04 13:02:00 -05:00
permission.rb
pinned_article.rb Pin posts to feed (#13807) 2021-06-04 10:54:53 +02:00
podcast.rb Podcast ownership join table (MLH Fellowship #81) (#11410) 2020-11-19 12:41:17 +01:00
podcast_episode.rb Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
podcast_episode_appearance.rb Add podcast_appearances joined table (forem#82) (#11354) 2020-11-30 17:12:52 +01:00
podcast_ownership.rb Podcast ownership join table (MLH Fellowship #81) (#11410) 2020-11-19 12:41:17 +01:00
poll.rb Rename MarkdownParser to MarkdownProcessor::Parser (#12248) 2021-01-13 10:39:13 -05:00
poll_option.rb Rename MarkdownParser to MarkdownProcessor::Parser (#12248) 2021-01-13 10:39:13 -05:00
poll_skip.rb
poll_vote.rb Rubocop: enable and fix new Rails cops (#9537) 2020-07-29 11:14:19 +02:00
privileged_reaction.rb [deploy] New Feature: Mod Actions Panel (#7777) 2020-06-08 13:24:18 -04:00
profile.rb Validate profile field "website url" is in fact a url (don't generate local path links). (#14302) 2021-07-22 12:02:29 -05:00
profile_field.rb Remove CustomProfileField (#14286) 2021-07-22 10:05:39 +07:00
profile_field_group.rb [deploy] /profile/settings page rendering (Ridhwana/Michael) (#10733) 2020-10-20 09:18:13 -04:00
profile_pin.rb
rating_vote.rb [deploy] Add missing foreign keys to models related to users (#10018) 2020-08-31 15:39:57 +02:00
reaction.rb Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
response_template.rb
role.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
secret.rb [deploy] Feature: Setup Admin Area to Update Vault Secrets (#8935) 2020-06-29 15:08:09 -05:00
sponsorship.rb Add missing presence validators to models (#10495) 2020-10-01 16:15:32 +02:00
tag.rb Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606) 2021-05-03 11:09:45 -04:00
tag_adjustment.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
timeframe.rb Remove timeframer from app/labor (#11782) 2020-12-08 12:52:33 +07:00
tool.rb
tweet.rb Refactor RssReader and Feeds::Import common parts: take 1 (#11412) 2020-11-18 14:17:53 +01:00
user.rb Remove Settings Columns from User (#14252) 2021-07-19 09:12:27 +07:00
user_block.rb Fix and refactor hide user content (#12307) 2021-01-18 11:08:23 -05:00
user_role.rb [Search 2.0] Users (#13453) 2021-04-24 19:06:06 +02:00
user_subscription.rb Rename MarkdownParser to MarkdownProcessor::Parser (#12248) 2021-01-13 10:39:13 -05:00
webhook_endpoint.rb
welcome.rb
welcome_notification.rb Add Polymorphism to Broadcasts (Part 1) (#9231) [deploy] 2020-07-13 09:36:19 -06:00