-
Notifications
You must be signed in to change notification settings - Fork 472
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
issue #584: do not mutate route.path #585
Conversation
2b11193
to
96de759
Compare
- adds changelog entry
@@ -8,15 +8,15 @@ def can_be_moved?(params, http_verb) | |||
move_methods.include?(http_verb) && includes_body_param?(params) | |||
end | |||
|
|||
def to_definition(params, route, definitions) | |||
def to_definition(path, params, route, definitions) |
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.
Wouldn't it be better to append the new param path
instead of prepending it? This is a public method so the change could break other code.
specify 'The original route path is not mutated' do | ||
route = Struct.new(:version, :path).new | ||
route.path = '/foo/:dynamic/bar' | ||
subject.build(route, add_version: true) |
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 would like to see an expectation here as well to see that the path
was modified, but route.path
was not.
version = GrapeSwagger::DocMethods::Version.get(route) | ||
version = [version] unless version.is_a?(Array) | ||
Array( | ||
route.path.split('{')[0].split('/').reject(&:empty?).delete_if do |i| | ||
path.split('{')[0].split('/').reject(&:empty?).delete_if do |i| |
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 know you don't changed that, but please can we extract this split and reject into a separate method which explains, what it did? It's really hard to understand and a good method name would help with that.
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 still good to me... :)
version = GrapeSwagger::DocMethods::Version.get(route) | ||
version = [version] unless version.is_a?(Array) | ||
Array( | ||
route.path.split('{')[0].split('/').reject(&:empty?).delete_if do |i| | ||
path.split('{')[0].split('/').reject(&:empty?).delete_if do |i| |
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 array initialisation is quite complex and worth abstracting away from Application logic.
- adds changelog entry
No description provided.