Skip to content

Commit c5c39ba

Browse files
author
Jonathan Chan
committed
Adding searchable false test case
1 parent 8206409 commit c5c39ba

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

spec/ajax-datatables-rails/datatable/column_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@
127127
end
128128
end
129129
end
130+
131+
describe 'unsearchable column' do
132+
let(:column) { datatable.datatable.columns.find{ |c| c.data == 'email_hash' } }
133+
134+
it 'is not searchable' do
135+
expect(column.searchable?).to eql(false)
136+
end
137+
end
130138

131139
describe '#formatter' do
132140
let(:datatable) { DatatableWithFormater.new(sample_params) }

spec/support/datatables/complex_datatable.rb

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def view_columns
99
last_name: { source: 'User.last_name' },
1010
full_name: { source: 'full_name' },
1111
post_id: { source: 'User.post_id', orderable: false },
12+
email_hash: { source: 'email_hash', searchable: false },
1213
created_at: { source: 'User.created_at' },
1314
}
1415
end

spec/support/models/user.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# frozen_string_literal: true
22

3+
require 'digest'
4+
35
class User < ActiveRecord::Base
46
def full_name
57
"#{first_name} #{last_name}"
68
end
9+
10+
def email_hash
11+
Digest::SHA256.hexdigest email
12+
end
713
end

0 commit comments

Comments
 (0)