Skip to content

Commit 467d15f

Browse files
committed
Merge pull request #343 from senid231/fix_parse_sort_criteria
fix parse_sort_criteria when sort is empty
2 parents 35beaf5 + c2ad419 commit 467d15f

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/jsonapi/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def set_default_filters
234234
end
235235

236236
def parse_sort_criteria(sort_criteria)
237-
return unless sort_criteria
237+
return unless sort_criteria.present?
238238

239239
@sort_criteria = CSV.parse_line(URI.unescape(sort_criteria)).collect do |sort|
240240
if sort.start_with?('-')

test/controllers/controller_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def test_index_filter_on_relationship
205205
assert_equal 3, json_response['data'].size
206206
end
207207

208+
def test_sorting_blank
209+
get :index, {sort: ''}
210+
211+
assert_response :success
212+
end
213+
208214
def test_sorting_asc
209215
get :index, {sort: 'title'}
210216

0 commit comments

Comments
 (0)