Add support for text columns for secure matchers#1479
Open
maxehmookau wants to merge 1 commit intothoughtbot:mainfrom
Open
Add support for text columns for secure matchers#1479maxehmookau wants to merge 1 commit intothoughtbot:mainfrom
maxehmookau wants to merge 1 commit intothoughtbot:mainfrom
Conversation
Author
|
I'm really struggling to get appraisals working to run the specs locally so I'm not convinced this works yet. 😢 |
mcmire
reviewed
Jan 18, 2022
|
|
||
| def has_expected_db_column? | ||
| matcher = HaveDbColumnMatcher.new(token_attribute).of_type(:string) | ||
| matcher = HaveDbColumnMatcher.new(token_attribute).of_type(:string) || HaveDbColumnMatcher.new(token_attribute).of_type(:text) |
Collaborator
There was a problem hiding this comment.
This is always going to return the first one, the one for :string. The reason is that this line merely returns a matcher object; it doesn't actually perform the matching. That happens in the next line.
What you probably want to do is:
matchers = [
HaveDbColumnMatcher.new(token_attribute).of_type(:string),
HaveDbColumnMatcher.new(token_attribute).of_type(:text)
]
matchers.any? { |matcher| matcher.matches?(@subject) }|
Mind if I copy this PR with the requested changes so we can get this merged in? |
Member
|
@krainboltgreene, sorry for the delayed response. I wasn't following this PR. I'd say to feel free to copy this PR with the requested changes just make sure to also give credits to @maxehmookau |
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.
Issue
Currently, using the
textdatatype for thehas_secure_tokenfunctionality is supported in Rails, but when used alongside shoulda-matchers it fails as the datatype must bestring.On codebases that use postgresql, there's no difference between using
textorstringand in most cases it makes sense to usetext.Proposed solution
Add support for
textdatatypes when using thehave_secure_tokenmatcher.