Add test for AC:Parameter object params in sort_link
Follow-up to PR #644 by @ryanswood. Closes #644.
This commit is contained in:
parent
3a3cb8a153
commit
b1cfed8fa9
|
@ -33,6 +33,12 @@
|
|||
|
||||
*Josh Hunter*, *Jon Atack*
|
||||
|
||||
* Add test for ActionController:Parameter object params in sort_link to ensure
|
||||
Ransack is handling the Rails 5 changes correctly. Follow-up to
|
||||
[#644](https://github.com/activerecord-hackery/ransack/pull/644).
|
||||
|
||||
*Ryan Wood*
|
||||
|
||||
* Add failing tests to facilitate work on issue
|
||||
[#566](https://github.com/activerecord-hackery/ransack/issues/566)
|
||||
of passing boolean values to search scopes. PR
|
||||
|
|
|
@ -310,12 +310,13 @@ module Ransack
|
|||
end
|
||||
|
||||
context 'view has existing parameters' do
|
||||
before do
|
||||
@controller.view_context.params[:exist] = 'existing'
|
||||
end
|
||||
|
||||
describe '#sort_link should not remove existing params' do
|
||||
subject { @controller.view_context
|
||||
.sort_link(
|
||||
|
||||
before { @controller.view_context.params[:exist] = 'existing' }
|
||||
|
||||
subject {
|
||||
@controller.view_context.sort_link(
|
||||
Person.search(
|
||||
{ sorts: ['name desc'] },
|
||||
search_key: 'people_search'
|
||||
|
@ -324,8 +325,33 @@ module Ransack
|
|||
controller: 'people'
|
||||
)
|
||||
}
|
||||
|
||||
it { should match /exist\=existing/ }
|
||||
end
|
||||
|
||||
context 'using real ActionController Parameter object',
|
||||
if: ::ActiveRecord::VERSION::MAJOR > 4 do
|
||||
|
||||
describe '#sort_link should include search params' do
|
||||
|
||||
subject { @controller.view_context.sort_link(Person.search, :name) }
|
||||
|
||||
let(:params) {
|
||||
ActionController::Parameters
|
||||
.new({ 'q' => { name_eq: 'TEST' }, controller: 'people' })
|
||||
}
|
||||
|
||||
before { @controller.instance_variable_set(:@params, params) }
|
||||
|
||||
it {
|
||||
should match(
|
||||
/people\?q(%5B|\[)name_eq(%5D|\])=TEST&q(%5B|\[)s(%5D|\])
|
||||
=name\+asc/x,
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe '#sort_link with hide order indicator set to true' do
|
||||
|
|
Loading…
Reference in New Issue