docbrown/spec/lib/data_update_scripts
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
..
add_data_updates_scripts_feature_flag_spec.rb Adds a feature flag for Data Update Scripts (#12641) 2021-02-10 18:22:27 +02:00
add_fastly_http_purge_feature_flag_spec.rb Fastly edge caching: use PURGE HTTP method instead of POST (#12627) 2021-02-17 13:34:37 -05:00
add_single_resource_role_to_tech_admins_spec.rb Fix erroring data update script (#12628) 2021-02-09 11:16:44 -08:00
add_work_profile_field_spec.rb Add 'Work' profile field (#14106) 2021-07-09 09:24:08 +07:00
backfill_forem_consumer_app_team_id_spec.rb Make Consumer Apps dictate aasa results (#14015) 2021-06-24 08:36:11 -06:00
backfill_section_column_for_navigation_links_spec.rb Static Sections for Site Navigation - Pt1 (#14213) 2021-07-14 11:01:56 -04:00
cleanup_articles_with_invalid_feed_source_url_spec.rb [deploy] Remove draft articles with duplicate feed source URL and cleanup invalid data: take 2 (#10239) 2020-09-08 11:53:41 -05:00
cleanup_orphan_git_hub_repositories_spec.rb Remove GitHub repositories when GitHub identity is removed (#11951) 2020-12-20 15:15:40 +01:00
create_profile_fields_spec.rb Remove unused profile fields (#14206) 2021-07-16 09:45:12 -04:00
drop_profile_fields_for_static_attributes_spec.rb Drop profile fields for static attributes (#14109) 2021-07-01 14:30:40 -04:00
make_local_navigation_links_relative_spec.rb Update NavigationLink handling (#12316) 2021-01-20 13:57:59 -05:00
make_tags_with_mods_supported_spec.rb Automatically mark tag supported when adding mod (#11151) 2020-10-30 09:46:10 -04:00
migrate_data_to_work_field_spec.rb Fix data update script for work field migration (#14207) 2021-07-13 13:20:21 +07:00
populate_explicit_follow_points_spec.rb Add implicit points to follows to improve feed relevancy (in all algorithms) (#11513) 2020-11-25 16:09:51 -05:00
profile_website_url_format_spec.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
remove_feeds_import_feature_flag_spec.rb Remove RssReader (#12169) 2021-01-08 11:45:15 -05:00
remove_notification_setting_migration_scripts_spec.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
remove_runtime_banner_feature_flag_spec.rb Remove :runtime_banner feature flag (#13662) 2021-05-28 15:10:15 -06:00
remove_site_config_scripts_spec.rb [Hotfix] Fix DataUpdateScripts::RemoveSiteConfigScripts script (#13824) 2021-05-21 16:34:21 +02:00
remove_unused_data_update_scripts_spec.rb Cleanup unused DataUpdateScripts (#13640) 2021-05-04 09:19:24 -04:00
set_onboarding_profile_fields_for_existing_forems_spec.rb Upgrade rubocop* packages to the latest version and fix violations (#11972) 2020-12-21 18:29:43 +01:00
set_proper_display_area_for_profile_fields_spec.rb Remove references to social link profile fields (#13252) 2021-05-03 10:16:02 -05:00
touch_articles_with_capitalized_paths_spec.rb Upgrade rubocop* packages to the latest version and fix violations (#11972) 2020-12-21 18:29:43 +01:00
update_article_main_image_path_spec.rb Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
update_articles_cached_entities_spec.rb Bug Fix:Update Article Cached Org and Docs When Org is Deleted (#12100) 2021-01-04 12:36:28 -06:00
update_user_update_rate_limit_default_spec.rb Create settings model for rate limits (#13381) 2021-04-20 11:29:22 +07:00