Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Sep 27, 2024

Motivation / Background

Implement ActionCable::TestHelper block-wise assertions in terms of #capture_broadcasts. This change inlines the private #new_broadcasts_from method contents into the #capture_broadcasts method, and uses #capture_broadcasts at all the previous #new_broadcasts_from call sites. This consolidation enables the removal of some JSON-parsing duplication across the other method implementations.

Detail

The test file changes were necessary to account for JSON-encoded String values (for example, transforming hello into "hello"). Since the broadcast documentation explicitly mentions that the message value will later be JSON encoded, this might not be considered a backwards incompatible change, since it brings actual behavior in-line with documented behavior.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
Implement `ActionCable::TestHelper` block-wise assertions in terms of `#capture_broadcasts`. This change inlines the private `#new_broadcasts_from` method contents into the `#capture_broadcasts` method, and uses `#capture_broadcasts` at all the previous `#new_broadcasts_from` call sites. This consolidation enables the removal of some JSON-parsing duplication across the other method implementations. The test file changes were necessary to account for JSON-encoded String values (for example, transforming `hello` into `"hello"`). Since the [broadcast][] documentation explicitly mentions that the `message` value <q>will later be JSON encoded</q>, this shouldn't be a backwards incompatible change. [broadcast]: https://edgeapi.rubyonrails.org/classes/ActiveRecord/AttributeMethods/BeforeTypeCast.html#method-i-read_attribute_before_type_cast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant