Skip to content

Add test coverage for IsolatedExecutionState#key?, #delete, and #context#57032

Merged
byroot merged 1 commit into
rails:mainfrom
hammadxcm:add-isolated-execution-state-tests
Mar 23, 2026
Merged

Add test coverage for IsolatedExecutionState#key?, #delete, and #context#57032
byroot merged 1 commit into
rails:mainfrom
hammadxcm:add-isolated-execution-state-tests

Conversation

@hammadxcm
Copy link
Copy Markdown
Contributor

Motivation / Background

ActiveSupport::IsolatedExecutionState has tests for #[], #[]=, isolation level switching, and #share_with, but the #key?, #delete, and #context public methods have no dedicated test coverage.

Detail

This Pull Request adds 7 tests to activesupport/test/isolated_execution_state_test.rb:

  • #key? returns true for existing key — sets a key, verifies key? returns true
  • #key? returns false for non-existing key — verifies key? returns false for missing key
  • #key? handles nil state gracefully — clears state, verifies no error when state is uninitialized
  • #delete removes key and returns its value — sets a key, deletes it, verifies return value and absence
  • #delete returns nil for non-existing key — deletes a missing key, asserts nil
  • #context returns current thread — under :thread isolation, verifies context == Thread.current
  • #context returns current fiber — under :fiber isolation, verifies context == Fiber.current

Additional information

All 13 tests in isolated_execution_state_test.rb pass with 0 failures, 27 assertions.

Checklist

  • 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.
  • 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.

These public methods on IsolatedExecutionState had no dedicated test
coverage.
@hammadxcm hammadxcm force-pushed the add-isolated-execution-state-tests branch from 9774e91 to 649c762 Compare March 22, 2026 12:28
@byroot byroot merged commit bfff951 into rails:main Mar 23, 2026
3 of 4 checks passed
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.

2 participants