-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not fail when case insentive enabled while having a complex context object #191
Conversation
For the sake of preventing regressions, would it be possible to implement the failing test in rspec? |
Absolutely, I didn't know we had proper unit tests in this project, I was trying to find them and I was unaware they were under spec folder. Just asked a colleague and they point me in the right direction. I was expecting a test folder or files prefixed with test. |
I totally understand! No sweat. rspec uses Unfortunately I'm too time constrained to be of more hands-on help at the moment. 🙁 |
Pull Request Test Coverage Report for Build 10612694617Details
💛 - Coveralls |
fa51677
to
0076e2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is what I found:
So, based on JS client which is the one accepting complex objects I think we can follow your suggestion and return false |
lib/unleash/constraint.rb
Outdated
# always return false, if we are comparing a non string with a string operator: | ||
return false if !context_value.is_a?(String) && STRING_OPERATORS.include?(self.operator) | ||
|
||
if self.case_insensitive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic is now in the line above isn't it? This can change can get rolled back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the fix is in the line above. ( https://github.com/Unleash/unleash-client-ruby/pull/191/files#diff-aa0ebe0760222c549034e2dfab10a550f29c632fcc9919cc84cb0e7675a46409R112 )
These changes are mostly a lint/simplification. ( https://github.com/Unleash/unleash-client-ruby/pull/191/files#diff-aa0ebe0760222c549034e2dfab10a550f29c632fcc9919cc84cb0e7675a46409R114-R117 ). So, nice to have, but not fixing a problem per-se.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#192 maybe this simplifies the if? It's needed but it's also having side effects on the values which I'd like to prevent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM
Context properties are always strings, regardless of what the surface level APIs in the SDKs may suggest. It's not clear to see in the dynamically typed languages because they can often skip the contextual parsing required in the constraints that the statically typed languages have to do but that leads to... well... this problem. In this case, this is a broken constraints because it can't be cast to the type that should be inferred from the local context provided by the constraint type so... +1 for return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks awesome! 🚀
About the changes
Closes #189