Skip to content

Commit 96e0708

Browse files
Don't pass data attribute appended to query params (#1301)
1 parent daa940e commit 96e0708

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
* Fix `:data` option to `sort_link` being incorrectly appended to the generated
6+
link query parameters.
7+
PR [1301](https://github.com/activerecord-hackery/ransack/pull/1301)
8+
59
## 3.0.0 - 2022-03-30
610

711
* Move documentation into Docusaurus.

lib/ransack/helpers/form_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def name
130130

131131
def url_options
132132
@params.merge(
133-
@options.except(:class).merge(
133+
@options.except(:class, :data).merge(
134134
@search.context.search_key => search_and_sort_params))
135135
end
136136

spec/ransack/helpers/form_helper_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,18 @@ module Helpers
758758
end
759759
end
760760

761+
describe '#sort_link with data option' do
762+
subject { @controller.view_context
763+
.sort_link(
764+
[:main_app, Person.ransack(sorts: ['name desc'])],
765+
:name,
766+
data: { turbo_action: :advance }, controller: 'people'
767+
)
768+
}
769+
it { should match /data-turbo-action="advance"/ }
770+
it { should_not match /people\?data%5Bturbo_action%5D=advance/ }
771+
end
772+
761773
describe '#search_form_for with default format' do
762774
subject { @controller.view_context
763775
.search_form_for(Person.ransack) {} }

0 commit comments

Comments
 (0)