Skip to content
Browse files

Handle empty arrays in Utils#flatten_params

  • Loading branch information...
1 parent 5a9f338 commit 1502de109e572a6a93c705e798ece3fad6d6c3b5 @hmarr hmarr committed Feb 11, 2013
Showing with 11 additions and 2 deletions.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 lib/gocardless/utils.rb
  3. +1 −1 lib/gocardless/version.rb
  4. +4 −0 spec/utils_spec.rb
View
5 CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.6.3 - February 11, 2013
+
+- Handle empty arrays in Utils#flatten_params
+
+
## 1.6.2 - January 25, 2013
- Add fee accessors to Bill
View
2 lib/gocardless/utils.rb
@@ -61,7 +61,7 @@ def flatten_params(obj, ns=nil)
pairs = obj.map { |k,v| flatten_params(v, ns ? "#{ns}[#{k}]" : k) }
pairs.empty? ? [] : pairs.inject(&:+)
when Array
- obj.map { |v| flatten_params(v, "#{ns}[]") }.inject(&:+)
+ obj.map { |v| flatten_params(v, "#{ns}[]") }.inject(&:+) || []
when Time
[[ns.to_s, iso_format_time(obj)]]
else
View
2 lib/gocardless/version.rb
@@ -1,3 +1,3 @@
module GoCardless
- VERSION = '1.6.2'.freeze
+ VERSION = '1.6.3'.freeze
end
View
4 spec/utils_spec.rb
@@ -133,6 +133,10 @@
subject['a' => ['b']].should == [['a[]', 'b']]
end
+ it "excludes values with empty arrays" do
+ subject['a' => []].should == []
+ end
+
it "includes all array values separately" do
result = subject['a' => ['b', 'c']]
result.should include ['a[]', 'b']

0 comments on commit 1502de1

Please sign in to comment.
Something went wrong with that request. Please try again.