Skip to content

Commit 4792df2

Browse files
committed
Add spec for "cond: <proc/lambda>"
1 parent 0a32d5f commit 4792df2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

spec/ajax-datatables-rails/orm/active_record_filter_records_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,25 @@
420420
end
421421
end
422422

423+
context 'proc condition' do
424+
describe 'it can filter records with lambda/proc condition' do
425+
let(:datatable) { DatatableCondProc.new(sample_params) }
426+
427+
before(:each) do
428+
create(:user, username: 'johndoe', email: 'johndoe@example.com')
429+
create(:user, username: 'johndie', email: 'johndie@example.com')
430+
create(:user, username: 'msmith', email: 'mary.smith@example.com')
431+
end
432+
433+
it 'should filter records matching' do
434+
datatable.params[:columns]['0'][:search][:value] = 'john'
435+
expect(datatable.data.size).to eq 2
436+
item = datatable.data.first
437+
expect(item[:username]).to eq 'johndie'
438+
end
439+
end
440+
end
441+
423442
context 'string condition' do
424443
describe 'it can filter records with condition :start_with' do
425444
let(:datatable) { DatatableCondStartWith.new(sample_params) }

0 commit comments

Comments
 (0)