mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Fix sort_link
with :class
option.
It was being ignored (rather, added to the query string), instead of being added to the link's class option.
This commit is contained in:
parent
bbd4b148fe
commit
f5160c1b4b
3 changed files with 37 additions and 1 deletions
|
@ -2,6 +2,13 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
* Fix `:class` option to `sort_link` not being passed to the generated link
|
||||
correctly when no additional options are passed. For example:
|
||||
|
||||
```ruby
|
||||
sort_link(@q, :bussiness_name, class: "foo")
|
||||
```
|
||||
|
||||
## 2.6.0 - 2022-03-08
|
||||
|
||||
* Fix regression when joining a table with itself.
|
||||
|
|
|
@ -135,7 +135,12 @@ module Ransack
|
|||
end
|
||||
|
||||
def html_options(args)
|
||||
html_options = extract_options_and_mutate_args!(args)
|
||||
if args.empty?
|
||||
html_options = @options
|
||||
else
|
||||
html_options = extract_options_and_mutate_args!(args)
|
||||
end
|
||||
|
||||
html_options.merge(
|
||||
class: [['sort_link'.freeze, @current_dir], html_options[:class]]
|
||||
.compact.join(' '.freeze)
|
||||
|
|
|
@ -726,6 +726,30 @@ module Ransack
|
|||
it { should match /Block label ▼/ }
|
||||
end
|
||||
|
||||
describe '#sort_link with class option' do
|
||||
subject { @controller.view_context
|
||||
.sort_link(
|
||||
[:main_app, Person.ransack(sorts: ['name desc'])],
|
||||
:name,
|
||||
class: 'people', controller: 'people'
|
||||
)
|
||||
}
|
||||
it { should match /class="sort_link desc people"/ }
|
||||
end
|
||||
|
||||
describe '#sort_link with class option workaround' do
|
||||
subject { @controller.view_context
|
||||
.sort_link(
|
||||
[:main_app, Person.ransack(sorts: ['name desc'])],
|
||||
:name,
|
||||
'name',
|
||||
{ controller: 'people' },
|
||||
class: 'people'
|
||||
)
|
||||
}
|
||||
it { should match /class="sort_link desc people"/ }
|
||||
end
|
||||
|
||||
describe '#search_form_for with default format' do
|
||||
subject { @controller.view_context
|
||||
.search_form_for(Person.ransack) {} }
|
||||
|
|
Loading…
Reference in a new issue