-
Notifications
You must be signed in to change notification settings - Fork 28
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
Implement get_feature_variable and create unit tests #190
Conversation
… into brandon/get_feat_var
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.
Mostly looks ok, just have a small comment. @msohailhussain can you also take a look when you get the chance please
@@ -132,6 +132,15 @@ def inputs_valid?(variables, logger = NoOpLogger.new, level = Logger::ERROR) | |||
variables.delete :user_id | |||
end | |||
|
|||
if variables.include? :variable_type | |||
# Empty variable_type is a valid user ID. |
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.
huh? This can you explain this?
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.
If variables[:variable_type]
is anything other than a String or null value, it is invalid. Otherwise, it is valid, and so we remove variable_type
from variables
. That way, it does not go through the value.is_a?(String) && !value.empty?
check on line 145.
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.
Got it. Thanks
@brandonhudavid Can you please resolve lint errors. |
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
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 see these two extraneous files in your commit:
experiment_to_return,
and variation_to_return,
can you remove em?
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
Summary
get_feature_variable
method inoptimizely.rb
to return value of variable with any typeinputs_valid?
function invalidator.rb
to allow fornil
variable typeproject_spec.rb
to ensure functionality ofget_feature_variable
Ruby is a dynamically-typed language, like JavaScript, so it suffices to have a single method return the value of a feature variable rather than have a separate method for each possible feature variable type.
Test plan
project_spec.rb
Issues