Skip to content

Commit

Permalink
When parameters where in the path and in a validation, they were twic…
Browse files Browse the repository at this point in the history
…e in the params hash (once with symbol key, once with string key)
  • Loading branch information
tim-vandecasteele committed Jul 19, 2012
1 parent 1145b78 commit b1a8bad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/grape/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def document_attribute(names, opts)
@last_description[:params] ||= {}

Array(names).each do |name|
@last_description[:params][name.to_sym] ||= {}
@last_description[:params][name.to_sym].merge!(opts)
@last_description[:params][name.to_s] ||= {}
@last_description[:params][name.to_s].merge!(opts)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def three
subject.routes.map { |route|
{ :description => route.route_description, :params => route.route_params }
}.should eq [
{ :description => "method", :params => { :ns_param => { :required => true, :desc => "namespace parameter" }, :method_param => { :required => false, :desc => "method parameter" } } }
{ :description => "method", :params => { "ns_param" => { :required => true, :desc => "namespace parameter" }, "method_param" => { :required => false, :desc => "method parameter" } } }
]
end
it "should merge the parameters of nested namespaces" do
Expand All @@ -964,7 +964,7 @@ def three
subject.routes.map { |route|
{ :description => route.route_description, :params => route.route_params }
}.should eq [
{ :description => "method", :params => { :ns_param => { :required => true, :desc => "ns param 2" }, :ns1_param => { :required => true, :desc => "ns1 param" }, :ns2_param => { :required => true, :desc => "ns2 param" }, :method_param => { :required => false, :desc => "method param" } } }
{ :description => "method", :params => { "ns_param" => { :required => true, :desc => "ns param 2" }, "ns1_param" => { :required => true, :desc => "ns1 param" }, "ns2_param" => { :required => true, :desc => "ns2 param" }, "method_param" => { :required => false, :desc => "method param" } } }
]
end
it "should not symbolize params" do
Expand Down

0 comments on commit b1a8bad

Please sign in to comment.