Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting in Resources controller #1462

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/alchemy/admin/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/alchemy/admin/resources_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down