Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

collection ordering case insensitive

  • Loading branch information...
commit 5daa83a7fb4025bfd1e7102471d670b94bf9b5ce 1 parent 82eed81
@drouchy drouchy authored
View
5 lib/shutl/resource/rest_class_methods.rb
@@ -83,9 +83,12 @@ def all(args = {})
end
if order_collection?
response_object.sort! do |a,b|
- a.send(@order_collection_by) <=> b.send(@order_collection_by)
+ str_a = a.send(@order_collection_by).to_s
+ str_b = b.send(@order_collection_by).to_s
+ str_a.casecmp(str_b)
end
end
+
RestCollection.new(response_object, response.parsed_response['pagination'])
end
View
2  lib/shutl/resource/version.rb
@@ -1,5 +1,5 @@
module Shutl
module Resource
- VERSION = '0.10.0'
+ VERSION = '0.10.1'
end
end
View
4 spec/rest_resource_spec.rb
@@ -159,7 +159,7 @@
context 'ordering the collection' do
let(:body) do
'{
- "test_rests": [{ "name": "d" }, {"name": "e"}, {"name": "a"}],
+ "test_rests": [{ "name": "D" }, {"name": "e"}, {"name": "a"}],
"pagination":{"page": 0,"items_on_page": 1,"total_count": 3, "number_of_pages": 3}
}'
end
@@ -173,7 +173,7 @@
end
it 're-orders the result' do
- TestRest.all.map(&:name).should == %w(a d e)
+ TestRest.all.map(&:name).should == %w(a D e)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.