Skip to content

AO3-6547 Extract WorkRecipients concern from Work model#5910

Open
pmonfort wants to merge 2 commits into
otwcode:masterfrom
pmonfort:AO3-6547
Open

AO3-6547 Extract WorkRecipients concern from Work model#5910
pmonfort wants to merge 2 commits into
otwcode:masterfrom
pmonfort:AO3-6547

Conversation

@pmonfort

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6547

Purpose

Extract all work recipients logic into a WorkRecipients concern to make the code cleaner and easier to modify. The recipients code was spread across Work and CreationNotifier.

Changes:

  • Create app/models/concerns/work_recipients.rb with all recipients logic moved from Work: gifts association, recipients=/recipients methods, validations (new_recipients_allow_gifts, new_recipients_have_not_blocked_gift_giver), save_new_gifts, and challenge_bypass?
  • Simplify collections branch in notify_recipients
  • Use keyword argument for recipients(for_form:) instead of positional boolean
  • Use .exists? instead of .present? in save_new_gifts
  • Use gifts.create instead of Gift.create(work: self)
  • Rename challenge_bypass to challenge_bypass? (Ruby predicate convention)

No behavior changes.

Testing Instructions

Testing instructions are in the Jira issue.

Credit

Pablo Monfort (he/him)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant