mastodon/spec/models
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
..
account Fix RSpec/VerifiedDoubles cop (#25469) 2023-06-22 14:55:22 +02:00
account_suggestions Fix friends-of-friends recommendations suggesting already-requested accounts (#35604) 2025-07-30 16:28:26 +00:00
admin Add role-specific user fabricators (#33437) 2025-01-03 08:28:14 +00:00
concerns Add experimental basic quote post authoring (#35355) 2025-07-25 12:35:24 +00:00
doorkeeper Add coverage for doorkeeper model extensions (#35161) 2025-06-25 07:50:20 +00:00
fasp Add delivery failure handling to FASP jobs (#35723) 2025-08-08 09:46:09 +00:00
form Extract form batch classes for relationships and follow recommendations 2025-08-25 10:31:37 -04:00
trends Add restrictions on which quote posts can trend (#35507) 2025-07-24 15:45:12 +00:00
user_settings Fix minor typos in comments and spec names (#21831) 2023-05-19 17:13:29 +02:00
web Fix RSpec/EmptyExampleGroup cop (#24735) 2023-07-28 23:15:33 +02:00
account_alias_spec.rb Add coverage for AccountAlias validations (#31936) 2024-10-23 06:39:19 +00:00
account_conversation_spec.rb Fix RSpec/DescribedClass cop (#25104) 2023-06-06 13:58:33 +02:00
account_deletion_request_spec.rb Add coverage for AccountDeletionRequest class (#31937) 2024-09-18 13:29:57 +00:00
account_domain_block_spec.rb Check both before/after state in AccountDomainBlock spec (#30640) 2024-06-11 13:59:56 +00:00
account_filter_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
account_migration_spec.rb Simplify model validation specs for AccountMigration (#32494) 2024-10-25 08:02:13 +00:00
account_moderation_note_spec.rb Simplify model validation spec in AccountModerationNote/ReportNote (#31792) 2024-10-24 12:52:38 +00:00
account_pin_spec.rb Add coverage for AccountPin model (#33231) 2024-12-10 13:02:52 +00:00
account_spec.rb Extract constant for attribution domains limit in account (#35350) 2025-07-15 13:08:24 +00:00
account_statuses_cleanup_policy_spec.rb Wrap assertions in change within AccountStatusesCleanupPolicy spec (#33335) 2024-12-17 16:25:02 +00:00
account_summary_spec.rb Use in_order_of with filter: false in AccountSummary.localized (#33446) 2025-01-06 08:18:05 +00:00
account_warning_preset_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
account_warning_spec.rb Add AccountWarning#appeal_eligible? method (#33526) 2025-01-09 15:08:39 +00:00
announcement_reaction_spec.rb Add coverage for AnnouncementReaction model (#35543) 2025-07-28 07:59:32 +00:00
announcement_spec.rb Simplify model validation specs for Announcement (#32481) 2024-10-23 07:47:46 +00:00
appeal_spec.rb Add AccountWarning#appeal_eligible? method (#33526) 2025-01-09 15:08:39 +00:00
async_refresh_spec.rb Experimental Async Refreshes API (#34918) 2025-06-12 14:54:00 +00:00
block_spec.rb Expand coverage for Block model (#32480) 2024-10-15 13:30:17 +00:00
bookmark_spec.rb Add coverage for Bookmark validation and reblog/status check callback (#31907) 2024-09-16 07:52:22 +00:00
bulk_import_spec.rb Add age/expiry duration constants to BulkImport class (#32839) 2024-11-12 08:57:06 +00:00
canonical_email_block_spec.rb Replace EmailHelper module with normalizes via model concern (#35702) 2025-08-07 13:47:47 +00:00
conversation_spec.rb Fix RSpec/InferredSpecType cop (#24736) 2023-05-04 05:49:53 +02:00
custom_emoji_category_spec.rb Simplify basic presence validations (#29664) 2024-09-05 15:36:05 +00:00
custom_emoji_filter_spec.rb Update rubocop-rspec to version 2.22.0, fix RSpec/IndexedLet cop (#24698) 2023-06-14 16:44:37 +02:00
custom_emoji_spec.rb Allow CustomEmoji to normalize its own domain (#35726) 2025-08-11 07:33:36 +00:00
custom_filter_keyword_spec.rb Add CustomFilterKeyword#to_regex method (#28893) 2024-01-25 13:00:34 +00:00
custom_filter_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
custom_filter_status_spec.rb Add coverage for CustomFilterStatus model (#35374) 2025-07-15 06:28:40 +00:00
domain_allow_spec.rb Simplify model validation specs for DomainAllow (#32496) 2024-10-25 08:42:14 +00:00
domain_block_spec.rb Reinforce coverage for DomainBlock model (#32473) 2024-10-14 12:51:01 +00:00
email_domain_block_spec.rb Fix RSpec/MissingExampleGroupArgument cop (#25310) 2023-06-06 15:51:42 +02:00
export_spec.rb Extract ExportSummary class for account object counts (#32227) 2024-10-03 13:09:58 +00:00
extended_description_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
favourite_spec.rb Fix RSpec/DescribedClass cop (#25104) 2023-06-06 13:58:33 +02:00
featured_tag_spec.rb Add REST API for featuring and unfeaturing a hashtag (#34489) 2025-04-25 15:12:05 +00:00
follow_recommendation_mute_spec.rb Add coverage for FollowRecommendationMute model (#35376) 2025-07-15 06:27:36 +00:00
follow_request_spec.rb Change lists to reflect added and removed users retroactively (#32930) 2024-11-19 10:04:12 +00:00
follow_spec.rb Fortify coverage for Follow model (#32472) 2024-10-23 07:46:55 +00:00
home_feed_spec.rb Experimental Async Refreshes API (#34918) 2025-06-12 14:54:00 +00:00
identity_spec.rb Merge pull request from GHSA-vm39-j3vx-pch3 2024-02-14 15:16:07 +01:00
instance_moderation_note_spec.rb Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
instance_spec.rb Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
invite_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
ip_block_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
list_account_spec.rb Remove follow creation from ListAccount fabricator (#31902) 2024-09-16 08:56:40 +00:00
list_spec.rb Add with_list_account scope to List model (#35539) 2025-07-28 08:26:29 +00:00
login_activity_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
marker_spec.rb Simplify basic presence validations (#29664) 2024-09-05 15:36:05 +00:00
media_attachment_spec.rb Add MediaAttachment.combined_media_file_size method (#35570) 2025-07-30 12:57:51 +00:00
mention_spec.rb Standardize uniqueness validation declaration on Mention (#33247) 2024-12-10 15:45:13 +00:00
mute_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
notification_policy_spec.rb Fix notification requests from suspended accounts still being listed (#32354) 2024-10-09 17:29:02 +00:00
notification_request_spec.rb Change notification requests to only count mentions (#31322) 2024-08-07 11:12:36 +00:00
notification_spec.rb Combine assertions in Notification model spec (#32015) 2024-09-23 10:45:34 +00:00
poll_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
poll_vote_spec.rb Fix RSpec/InferredSpecType cop (#24736) 2023-05-04 05:49:53 +02:00
preview_card_provider_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
preview_card_spec.rb Simplify model validation specs for PreviewCard (#32469) 2024-10-25 07:55:33 +00:00
preview_card_trend_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
privacy_policy_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
public_feed_spec.rb Reduce factory creation (73 -> 64) in PublicFeed spec (#32491) 2024-10-15 13:10:29 +00:00
relationship_filter_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
relationship_severance_event_spec.rb Add notifications of severed relationships (#27511) 2024-03-20 15:37:21 +00:00
relay_spec.rb Add coverage for model normalizations (#31734) 2024-09-04 05:12:40 +00:00
remote_follow_spec.rb Allow more flexible host/port treatment with LOCAL_DOMAIN values in tests (#35040) 2025-06-16 13:12:23 +00:00
report_filter_spec.rb Add relevant_params to ReportFilter (matches account filter) (#32136) 2024-10-02 13:24:40 +00:00
report_note_spec.rb Simplify model validation spec in AccountModerationNote/ReportNote (#31792) 2024-10-24 12:52:38 +00:00
report_spec.rb Simplify model validation specs for Report (#33267) 2024-12-12 09:09:35 +00:00
rule_spec.rb Use more generic locale as fallback for rules (#34756) 2025-05-21 16:22:54 +00:00
rule_translation_spec.rb Rely on pluck for the SELECT in RuleTranslation.languages (#35826) 2025-08-22 23:58:40 +00:00
scheduled_status_spec.rb Add Specs for Scheduled Status Model Validations (#30585) 2024-06-10 14:52:33 +00:00
session_activation_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
setting_spec.rb Clean up Setting model and remove dead code (#28661) 2024-01-09 14:01:53 +00:00
severed_relationship_spec.rb Add notifications of severed relationships (#27511) 2024-03-20 15:37:21 +00:00
site_upload_spec.rb Fix RSpec/DescribedClass cop (#25104) 2023-06-06 13:58:33 +02:00
software_update_spec.rb Add urgent scope and by_version method to SoftwareUpdate (#33470) 2025-01-06 18:23:57 +00:00
status_edit_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
status_pin_spec.rb Enhance coverage for StatusPin model (#32515) 2024-10-28 07:34:58 +00:00
status_spec.rb Add Status#not_replying_to_account scope for annual report classes (#35257) 2025-07-10 07:35:04 +00:00
status_trend_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
tag_feed_spec.rb Enable "zero monkey patching" mode in RSpec (#31614) 2024-09-04 05:12:25 +00:00
tag_spec.rb Fix Style/GuardClause in Tag (#35522) 2025-07-28 08:54:29 +00:00
tag_trend_spec.rb Update rubocop-rspec to version 3.6.0 (#34497) 2025-04-24 14:56:13 +00:00
terms_of_service_spec.rb Fix intermittent failure of TOS model spec from effective date collision (#35244) 2025-07-03 16:28:47 +00:00
tombstone_spec.rb Add model spec for Tombstone (#32697) 2024-10-31 13:27:47 +00:00
user_role_spec.rb Update user role position range limit (#33349) 2024-12-19 08:10:39 +00:00
user_settings_spec.rb Fix RSpec/DescribedClass cop (#29472) 2024-03-13 15:42:39 +00:00
user_spec.rb Add coverage to user spec for missing last_sign_in_at scenario (#35587) 2025-07-30 13:46:58 +00:00
username_block_spec.rb Add ability to block words in usernames (#35407) 2025-07-29 10:19:15 +00:00
webauthn_credential_spec.rb Simplify WebauthnCredential constant limit math (#35107) 2025-06-20 10:04:14 +00:00
webhook_spec.rb Extract secret size constants in Webhook model (#35104) 2025-06-20 10:05:24 +00:00
worker_batch_spec.rb Make WorkerBatch spec more robust (#35656) 2025-08-04 14:04:40 +00:00