diff --git a/app/controllers/alchemy/admin/resources_controller.rb b/app/controllers/alchemy/admin/resources_controller.rb index 613f80ff7e..c3b9c8093b 100644 --- a/app/controllers/alchemy/admin/resources_controller.rb +++ b/app/controllers/alchemy/admin/resources_controller.rb @@ -144,7 +144,10 @@ def common_search_filter_includes [ # contrary to Rails' documentation passing an empty hash to permit all keys does not work {options: options_from_params.keys}, - {q: resource_handler.search_field_name}, + {q: [ + resource_handler.search_field_name, + :s + ]}, :tagged_with, :filter, :page diff --git a/spec/controllers/alchemy/admin/resources_controller_spec.rb b/spec/controllers/alchemy/admin/resources_controller_spec.rb index 1c9c9632ea..52dd8572e2 100644 --- a/spec/controllers/alchemy/admin/resources_controller_spec.rb +++ b/spec/controllers/alchemy/admin/resources_controller_spec.rb @@ -46,6 +46,15 @@ expect(assigns(:events)).not_to include(lustig) end end + + context 'with sort parameter given' do + let(:params) { {q: {s: "name asc"}} } + + it "returns records in the right order" do + get :index, params: params + expect(assigns(:events)).to eq([lustig, peter]) + end + end end end