Skip to content

Commit

Permalink
Fix tests on Oracle DB
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Dec 12, 2019
1 parent 6b8fc55 commit f5ee338
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions spec/ajax-datatables-rails/datatable/simple_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
after { AjaxDatatablesRails.config.nulls_last = false }

it 'sql query' do
skip('unsupported database adapter') if ENV['DB_ADAPTER'] == 'oracle_enhanced'

expect(simple_order.query('email')).to eq(
"email DESC #{nulls_last_sql}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
expect(result).to be_a(Arel::Nodes::And)
end

if AjaxDatatablesRails.config.db_adapter == :postgresql
if ENV['DB_ADAPTER'] == 'postgresql'
context 'when db_adapter is postgresql' do
it 'can call #to_sql on returned object' do
result = datatable.build_conditions_for_selected_columns
Expand All @@ -138,7 +138,7 @@
end
end

if AjaxDatatablesRails.config.db_adapter.in? %i[oracle oracleenhanced]
if ENV['DB_ADAPTER'] == 'oracle_enhanced'
context 'when db_adapter is oracle' do
it 'can call #to_sql on returned object' do
result = datatable.build_conditions_for_selected_columns
Expand All @@ -150,7 +150,7 @@
end
end

if AjaxDatatablesRails.config.db_adapter.in? %i[mysql2 sqlite3]
if ENV['DB_ADAPTER'] == 'mysql2'
context 'when db_adapter is mysql2' do
it 'can call #to_sql on returned object' do
result = datatable.build_conditions_for_selected_columns
Expand Down Expand Up @@ -288,7 +288,7 @@
create(:user, last_name: 'MARY')
end

if AjaxDatatablesRails.config.db_adapter == :oracleenhanced
if ENV['DB_ADAPTER'] == 'oracle_enhanced'
context 'when db_adapter is oracleenhanced' do
it 'should filter records matching' do
datatable.params[:columns]['3'][:search][:value] = 'RY'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
end

it 'paginates records properly' do
if AjaxDatatablesRails.config.db_adapter.in? %i[oracle oracleenhanced]
if Rails.version.in? %w[4.0.13 4.1.16 4.2.10]
if ENV['DB_ADAPTER'] == 'oracle_enhanced'
if Rails.version.in? %w[4.2.11]
expect(datatable.paginate_records(records).to_sql).to include(
'rownum <= 10'
)
Expand All @@ -34,8 +34,8 @@

datatable.params[:start] = '26'
datatable.params[:length] = '25'
if AjaxDatatablesRails.config.db_adapter.in? %i[oracle oracleenhanced]
if Rails.version.in? %w[4.0.13 4.1.16 4.2.10]
if ENV['DB_ADAPTER'] == 'oracle_enhanced'
if Rails.version.in? %w[4.2.11]
expect(datatable.paginate_records(records).to_sql).to include(
'rownum <= 51'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
after { AjaxDatatablesRails.config.nulls_last = false }

it 'can handle multiple sorting columns' do
skip('unsupported database adapter') if ENV['DB_ADAPTER'] == 'oracle_enhanced'

# set to order by Users username in ascending order, and
# by Users email in descending order
datatable.params[:order]['0'] = { column: '0', dir: 'asc' }
Expand All @@ -61,6 +63,8 @@

describe '#sort_records with nulls last using column config' do
it 'can handle multiple sorting columns' do
skip('unsupported database adapter') if ENV['DB_ADAPTER'] == 'oracle_enhanced'

# set to order by Users username in ascending order, and
# by Users email in descending order
nulls_last_datatable.params[:order]['0'] = { column: '0', dir: 'asc' }
Expand Down

0 comments on commit f5ee338

Please sign in to comment.