-
Notifications
You must be signed in to change notification settings - Fork 37
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
Allow bootstrapped variants when client is disabled #138
Allow bootstrapped variants when client is disabled #138
Conversation
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.
Looks good, but would like tests in get_variant()
that test explicitly the case where context is nil.
lib/unleash/feature_toggle.rb
Outdated
return context.get_by_name(stickiness) unless stickiness == "default" || context.nil? | ||
return context.user_id unless context&.user_id.to_s.empty? | ||
return context.session_id unless context&.session_id.to_s.empty? | ||
return context.remote_address unless context&.remote_address.to_s.empty? |
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.
Can you add an explicit test for this case?
I think it should be somewhere around:
- the end of
feature_toggle_spec.rb
and/or - the end of
client_spec.rb
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.
Note that since this is a private method, the test should be in the closest public method that calls this. Probably in get_variant()
in FeatureToggle
and/or Client
.
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.
Do you mean tests that pass in a context missing one of user_id, session_id, remote_address
additively each time?
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.
I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.
But the fix in feature_toggle.rb
that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.
Pull Request Test Coverage Report for Build 4983808189
💛 - Coveralls |
Co-authored-by: Renato Arruda <git@rarruda.org>
lib/unleash/feature_toggle.rb
Outdated
return context.get_by_name(stickiness) unless stickiness == "default" || context.nil? | ||
return context.user_id unless context&.user_id.to_s.empty? | ||
return context.session_id unless context&.session_id.to_s.empty? | ||
return context.remote_address unless context&.remote_address.to_s.empty? |
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.
I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.
But the fix in feature_toggle.rb
that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.
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.
I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.
But the fix in feature_toggle.rb that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.
Co-authored-by: Renato Arruda <git@rarruda.org>
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.
It looks awesome now! Thanks for finding the issue and creating the PR!
Your welcome. Thank you for taking the time to consider, and being so timely with the response. |
About the changes
Attempts to address #137
Variants in a bootstrap configuration are ignored with the client is disabled. These changes remove that limitation, so disabled clients can interact with bootstrapped variants.
Auxiliary changes:
Calling
get_variant
allows passing a nil context, however attributes of this context are referenced when calculating the variant salt resulting inundefined method ... for nil
errors. Account for a nil context in this method which results in the default: random number.