Skip to content

Commit

Permalink
Don't pass data attribute appended to query params
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Apr 7, 2022
1 parent ce75337 commit a71ad58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ransack/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def name

def url_options
@params.merge(
@options.except(:class).merge(
@options.except(:class, :data).merge(
@search.context.search_key => search_and_sort_params))
end

Expand Down
12 changes: 12 additions & 0 deletions spec/ransack/helpers/form_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,18 @@ module Helpers
end
end

describe '#sort_link with data option' do
subject { @controller.view_context
.sort_link(
[:main_app, Person.ransack(sorts: ['name desc'])],
:name,
data: { turbo_action: :advance }, controller: 'people'
)
}
it { should match /data-turbo-action="advance"/ }
it { should_not match /people\?data%5Bturbo_action%5D=advance/ }
end

describe '#search_form_for with default format' do
subject { @controller.view_context
.search_form_for(Person.ransack) {} }
Expand Down

0 comments on commit a71ad58

Please sign in to comment.