Skip to content

Commit d37c54a

Browse files
committed
add spec for comma-separated search string
1 parent ae8dc99 commit d37c54a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/ajax-datatables-rails/base_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@
8686
expect(item[2]).to eq 'Name "><img src=x onerror=alert("first_name")>'
8787
expect(item[3]).to eq 'Name "><img src=x onerror=alert("last_name")>'
8888
end
89+
90+
context 'with no searchable columns' do
91+
let(:datatable) do
92+
ComplexDatatableArray.new(view).tap do |datatable|
93+
datatable.instance_variable_set :@searchable_columns, []
94+
end
95+
end
96+
97+
context 'when search value is comma-separated string' do
98+
let(:view) { double('view', params: sample_params.merge(search: { value: 'one, two' })) }
99+
100+
it 'should return an array of arrays' do
101+
create_list(:user, 5)
102+
expect(datatable.data).to be_a(Array)
103+
expect(datatable.data.size).to eq 5
104+
item = datatable.data.first
105+
expect(item).to be_a(Array)
106+
end
107+
end
108+
end
89109
end
90110
end
91111

0 commit comments

Comments
 (0)