Browse files

collection ordering case insensitive

  • Loading branch information...
1 parent 82eed81 commit 5daa83a7fb4025bfd1e7102471d670b94bf9b5ce @drouchy drouchy committed Jul 4, 2013
Showing with 7 additions and 4 deletions.
  1. +4 −1 lib/shutl/resource/rest_class_methods.rb
  2. +1 −1 lib/shutl/resource/version.rb
  3. +2 −2 spec/rest_resource_spec.rb
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

0 comments on commit 5daa83a

Please sign in to comment.