mastodon/spec/fabricators
Matt Jankowski 4fa462a9f8 Extract form batch classes for relationships and follow recommendations
Related to - https://github.com/mastodon/mastodon/pull/35458 - which added a batch base class, and to - https://github.com/mastodon/mastodon/pull/35872 - which envisions a world where form objects tell the view what to do.

Background here...

- The `Form::AccountBatch` form object is used in a few different places, for somewhat varied purposes
- The user relationships view uses it on a show page, which does a PUT to update, and uses the `follow`, `unfollow`, `remove_from_followers`, and `remove_domains_from_followers` "actions" of the form model
- The admin accounts view shows a form on index view, does POST to batch action, uses the `suspend`, `approve` and `reject` actions.
- The admin relationships view (for admins only) also has a form on index and does a POST back to that same spot
- The admin/follow_recommendations page has a form on show and does PUT to update, using the `suppress_follow_recommendation` and `unsuppress_follow_recommendation` actions

So, while these are all related in that they supply an `accounts_ids` array, the actual things that they "bulk update" are Follow (from relationships), FollowRecommendationSuppression (from follow recs) and Account (from accounts). This is a little inconsistent with other of the "batch form model" classes, which tend to update the same domain concept (ie, CustomEmojiBlock, IpBlockBatch, EmailDomainBlockBatch, etc) that they are named after (and in some cases that a "filter" class is named after).

All that said, the changes here:

- Pull out `Form::FollowRecommendationBatch` and `Form::RelationshipBatch` classes, which more closely align with the domain concept they are bulk updating (open to naming suggestions here)
- Mark both of these as `persisted?` true so that their form views will infer correct HTTP action
- Add some missing coverage to existing class, and coverage for new classes as well

It would be pretty straightforward to chop this up into smaller pieces, if any of "just the coverage first", "just the boolean attribute", "one new batch class at a time", etc - were more appealing.

Possible follow-up:

- In the existing `Form::AccountBatch`, use attributes API for boolean `select_all_matching` value, remove query method
- Convert the relationships controller spec to mix of request/system specs, round out coverage
- Most (all maybe?) of the "batch actions" are doing a `POST` to a `batch` action on the controller of whatever they are related to. Might be worth looking at what the diff would look like to move these all to nested controllers where they did a `PUT to */batches#update` with restful routing, etc.
2025-08-25 10:31:37 -04:00
..
assets png optimization(loss less) (#19630) 2022-11-01 15:06:52 +01:00
fasp Persist follow recommendations from FASP (#35218) 2025-06-30 13:39:36 +00:00
access_grant_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
access_token_fabricator.rb Fix Lint/EmptyBlock cop (#27748) 2023-11-07 09:11:04 +00:00
accessible_access_token_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
account_conversation_fabricator.rb Worker specs coverage increase (#32541) 2024-10-23 07:50:20 +00:00
account_deletion_request_fabricator.rb Improve spec coverage for collection of workers/ classes (#27874) 2023-11-16 14:36:59 +00:00
account_domain_block_fabricator.rb Expand coverage for Export utility class (#32212) 2024-10-02 09:43:04 +00:00
account_fabricator.rb Add support for FASP data sharing (#34415) 2025-05-16 12:24:02 +00:00
account_migration_fabricator.rb Fabricator specs (#23925) 2023-03-04 17:12:09 +01:00
account_moderation_note_fabricator.rb Fix sort order of moderation notes on Reports and Accounts (#31528) 2024-09-06 14:58:36 +00:00
account_note_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
account_pin_fabricator.rb Fabricator specs (#23925) 2023-03-04 17:12:09 +01:00
account_relationship_severance_event_fabricator.rb Add notifications of severed relationships (#27511) 2024-03-20 15:37:21 +00:00
account_stat_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
account_statuses_cleanup_policy_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
account_warning_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
account_warning_preset_fabricator.rb Restore missing fabricators (#23951) 2023-03-04 18:31:13 +01:00
action_log_fabricator.rb Remove default_scope from Admin::ActionLog (#28026) 2023-11-29 10:39:59 +00:00
announcement_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
announcement_mute_fabricator.rb Improve spec coverage for models/announcement class (#28350) 2023-12-14 10:29:10 +00:00
announcement_reaction_fabricator.rb Improve spec coverage for models/announcement class (#28350) 2023-12-14 10:29:10 +00:00
appeal_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
application_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
backup_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
block_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
bookmark_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
bulk_import_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
bulk_import_row_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
canonical_email_block_fabricator.rb Revert "Allow unblocking email addresses from any matching account (#29305)" (#30385) 2024-05-21 08:56:08 +00:00
client_credentials_token_fabricator.rb Assert usage of client credentials for account registration (#34828) 2025-05-28 12:09:32 +00:00
conversation_fabricator.rb Fix Lint/EmptyBlock cop (#27748) 2023-11-07 09:11:04 +00:00
custom_emoji_category_fabricator.rb Add spec coverage for models/form/custom_emoji_batch class (#28388) 2023-12-18 12:41:37 +00:00
custom_emoji_fabricator.rb Improve spec coverage for models/announcement class (#28350) 2023-12-14 10:29:10 +00:00
custom_filter_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
custom_filter_keyword_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
custom_filter_status_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
domain_allow_fabricator.rb Migrate to request specs in /api/v1/admin/domain_allows (#25333) 2023-06-10 18:32:26 +02:00
domain_block_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
email_domain_block_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
favourite_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
featured_tag_fabricator.rb Fix results/query in api/v1/featured_tags/suggestions (#29597) 2024-03-22 15:08:27 +00:00
follow_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
follow_recommendation_mute_fabricator.rb Move followable_by coverage to suggestions (#28697) 2024-01-12 09:11:34 +00:00
follow_recommendation_suppression_fabricator.rb Extract form batch classes for relationships and follow recommendations 2025-08-25 10:31:37 -04:00
follow_request_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
generated_annual_report_fabricator.rb Add coverage for api/v1/annual_reports area (#31730) 2024-09-03 16:10:48 +00:00
identity_fabricator.rb Ensure unique values in fabricators (#29515) 2024-03-11 08:53:24 +00:00
instance_moderation_note_fabricator.rb Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
invite_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
ip_block_fabricator.rb Expand coverage for Scheduler::IpCleanupScheduler worker (#32499) 2024-10-15 13:09:25 +00:00
list_account_fabricator.rb Remove follow creation from ListAccount fabricator (#31902) 2024-09-16 08:56:40 +00:00
list_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
login_activity_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
marker_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
media_attachment_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
mention_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
mute_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
notification_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
notification_permission_fabricator.rb Add notification policies and notification requests (#29366) 2024-03-07 14:53:37 +00:00
notification_policy_fabricator.rb Add notification policies and notification requests (#29366) 2024-03-07 14:53:37 +00:00
notification_request_fabricator.rb Destroy NotificationRequests that are dismissed (#31008) 2024-07-12 12:09:52 +00:00
poll_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
poll_vote_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
preview_card_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
preview_card_provider_fabricator.rb Use fabrication sequence in domain values (#29895) 2024-04-11 08:59:01 +00:00
preview_card_trend_fabricator.rb Add coverage for StatusTrend and PreviewCardTrend models, add locales class method to RankedTrend (#32688) 2024-10-29 15:46:32 +00:00
quote_fabricator.rb Add initial support for ingesting and verifying remote quote posts (#34370) 2025-04-17 07:45:23 +00:00
relationship_severance_event_fabricator.rb Add notifications of severed relationships (#27511) 2024-03-20 15:37:21 +00:00
relay_fabricator.rb Ensure unique values in fabricators (#29515) 2024-03-11 08:53:24 +00:00
report_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
report_note_fabricator.rb Fix sort order of moderation notes on Reports and Accounts (#31528) 2024-09-06 14:58:36 +00:00
rule_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
rule_translation_fabricator.rb Add ability to translate server rules (#34494) 2025-05-21 11:54:12 +00:00
scheduled_status_fabricator.rb Convert api/v1/scheduled_statuses controller spec to request spec (#27986) 2023-11-20 09:36:49 +00:00
session_activation_fabricator.rb Fix RSpec/MessageChain cop (#27776) 2023-11-09 12:57:23 +00:00
setting_fabricator.rb Remove thing_type and thing_id columns from settings table (#31971) 2024-12-05 14:34:14 +00:00
severed_relationship_fabricator.rb Add notifications of severed relationships (#27511) 2024-03-20 15:37:21 +00:00
site_upload_fabricator.rb Ensure unique values in fabricators (#29515) 2024-03-11 08:53:24 +00:00
software_update_fabricator.rb Use sequence in software_update fabricator to allow multiple (#29438) 2024-02-29 10:51:11 +00:00
status_edit_fabricator.rb Ensure datetime/date are serialized to correct format (#33086) 2024-12-14 15:50:41 +00:00
status_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
status_pin_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
status_stat_fabricator.rb Add coverage for CLI::Cache command (#25238) 2023-06-10 18:36:09 +02:00
status_trend_fabricator.rb Add coverage for StatusTrend and PreviewCardTrend models, add locales class method to RankedTrend (#32688) 2024-10-29 15:46:32 +00:00
tag_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
tag_follow_fabricator.rb Use build where possible in fabricators (#25360) 2023-06-10 18:29:01 +02:00
tag_trend_fabricator.rb Change hashtag trends to be stored in the database instead of redis (#32837) 2024-12-04 11:59:17 +00:00
terms_of_service_fabricator.rb Make Faker generate unique TOS effective dates (#34122) 2025-03-10 09:33:37 +00:00
tombstone_fabricator.rb Add model spec for Tombstone (#32697) 2024-10-31 13:27:47 +00:00
unavailable_domain_fabricator.rb Use fabrication sequence in domain values (#29895) 2024-04-11 08:59:01 +00:00
user_fabricator.rb Add role-specific user fabricators (#33437) 2025-01-03 08:28:14 +00:00
user_role_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00
username_block_fabricator.rb Add ability to block words in usernames (#35407) 2025-07-29 10:19:15 +00:00
web_push_subscription_fabricator.rb Make Web::PushSubscription#user and Web::PushSubscription#access_token relationships non-optional (#34498) 2025-04-23 08:12:31 +00:00
webauthn_credential_fabricator.rb Use sequence for unique names on webauthn cred fabricator (#35356) 2025-07-14 09:20:50 +00:00
webhook_fabricator.rb Enable Style/FrozenStringLiteralComment for specs (#23790) 2023-02-22 09:55:31 +09:00