Add tests for hash generation#485
Merged
rei-moo merged 3 commits intogithub:feature-7.2from Dec 16, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the hash generation logic from the rake task into a testable TaskHelper module, enabling comprehensive testing of the whitespace handling fix introduced in PR #472.
Key Changes:
- Extracted hash generation methods from
lib/tasks/tasks.rakeinto a newTaskHelpermodule - Added comprehensive test coverage for inline script/style hash generation
- Tests verify that helper tag indentation doesn't affect hash generation (the core fix from #472)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/secure_headers/task_helper.rb |
New module containing extracted hash generation logic with methods for finding and hashing inline scripts/styles, previously embedded in the rake task |
lib/tasks/tasks.rake |
Refactored to use the new TaskHelper module, replacing inline method definitions with module inclusion |
spec/lib/secure_headers/task_helper_spec.rb |
New comprehensive test suite covering hash generation for scripts and styles, including tests for the indentation-independent hashing behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors the rake task to enable testing of the changes made in #472
All PRs: