-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
Strip whitespace out of feature/actor/group values posted by UI #205
Strip whitespace out of feature/actor/group values posted by UI #205
Conversation
@@ -24,7 +24,7 @@ def get | |||
def post | |||
feature_name = Rack::Utils.unescape(request.path.split('/')[-2]) | |||
feature = flipper[feature_name.to_sym] | |||
value = params["value"] | |||
value = params["value"].strip | |||
|
|||
if Util.blank?(value) |
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 like the code expects a possible nil
value here, which means that your change on line 27
will raise an undefined method for nil nilclass
maybe strip
inside the if block?
@@ -34,7 +34,7 @@ def post | |||
halt view_response(:feature_creation_disabled) | |||
end | |||
|
|||
value = params["value"] | |||
value = params["value"].strip |
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.
same as above
before do | ||
flipper[:search].enable_actor Flipper::UI::Actor.new("User:6") | ||
post "features/search/actors", | ||
{"value" => "User:6", "operation" => "disable", "authenticity_token" => token}, | ||
{"value" => value, "operation" => "disable", "authenticity_token" => token}, |
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.
maybe add a test where you don't pass a value
? seems like that's missing here
@midu Added more tests related to empty values (not exactly the same as a param hash missing the
I do wanna make sure the value (nil, empty or present) is converted to a string and cleaned up before we test for its validity so that the UI helps the user as much as possible |
My preference is to_s.strip. It works with older versions of ruby and flipper doesn't care about nil uniquely since nil/blank are treated the same. |
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 great. Thanks!
Fix #204
By investigating the initial issue, I was able to identify several areas impacted by it.
Still via the UI, adding an actor to the second one seemed to have actually added it to the first one.
Both links in the UI leads to the same feature:
This PR fixes all of these issues above by applying
String#strip
to the params send from the front-end to the back-end of Flipper UI.cc @jnunemaker & @AlexWheeler for review/feedback, and @susanblueapron for finding the bug in the first place