File tree 5 files changed +28
-9
lines changed
5 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 21
21
after { parent . nulls_last = false }
22
22
23
23
it 'sql query' do
24
- skip ( 'unsupported database adapter' ) if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
24
+ skip ( 'unsupported database adapter' ) if RunningSpec . oracle?
25
25
26
26
expect ( simple_order . query ( 'email' ) ) . to eq (
27
27
"email DESC #{ nulls_last_sql ( parent ) } "
Original file line number Diff line number Diff line change 168
168
expect ( result ) . to be_a ( Arel ::Nodes ::And )
169
169
end
170
170
171
- if ENV [ 'DB_ADAPTER' ] == ' postgresql'
171
+ if RunningSpec . postgresql?
172
172
context 'when db_adapter is postgresql' do
173
173
it 'can call #to_sql on returned object' do
174
174
result = datatable . build_conditions_for_selected_columns
180
180
end
181
181
end
182
182
183
- if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
183
+ if RunningSpec . oracle?
184
184
context 'when db_adapter is oracle' do
185
185
it 'can call #to_sql on returned object' do
186
186
result = datatable . build_conditions_for_selected_columns
192
192
end
193
193
end
194
194
195
- if ENV [ 'DB_ADAPTER' ] == 'mysql2'
195
+ if RunningSpec . mysql?
196
196
context 'when db_adapter is mysql2' do
197
197
it 'can call #to_sql on returned object' do
198
198
result = datatable . build_conditions_for_selected_columns
471
471
create ( :user , last_name : 'MARY' )
472
472
end
473
473
474
- if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
474
+ if RunningSpec . oracle?
475
475
context 'when db_adapter is oracleenhanced' do
476
476
it 'filters records matching' do
477
477
datatable . params [ :columns ] [ '3' ] [ :search ] [ :value ] = 'RY'
Original file line number Diff line number Diff line change 18
18
end
19
19
20
20
it 'paginates records properly' do
21
- if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
21
+ if RunningSpec . oracle?
22
22
if Rails . version . in? %w[ 4.2.11 ]
23
23
expect ( datatable . paginate_records ( records ) . to_sql ) . to include (
24
24
'rownum <= 10'
36
36
37
37
datatable . params [ :start ] = '26'
38
38
datatable . params [ :length ] = '25'
39
- if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
39
+ if RunningSpec . oracle?
40
40
if Rails . version . in? %w[ 4.2.11 ]
41
41
expect ( datatable . paginate_records ( records ) . to_sql ) . to include (
42
42
'rownum <= 51'
Original file line number Diff line number Diff line change 51
51
after { datatable . nulls_last = false }
52
52
53
53
it 'can handle multiple sorting columns' do
54
- skip ( 'unsupported database adapter' ) if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
54
+ skip ( 'unsupported database adapter' ) if RunningSpec . oracle?
55
55
56
56
# set to order by Users username in ascending order, and
57
57
# by Users email in descending order
65
65
66
66
describe '#sort_records with nulls last using column config' do
67
67
it 'can handle multiple sorting columns' do
68
- skip ( 'unsupported database adapter' ) if ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
68
+ skip ( 'unsupported database adapter' ) if RunningSpec . oracle?
69
69
70
70
# set to order by Users username in ascending order, and
71
71
# by Users email in descending order
Original file line number Diff line number Diff line change 61
61
end
62
62
end
63
63
64
+ class RunningSpec
65
+ def self . sqlite?
66
+ ENV [ 'DB_ADAPTER' ] == 'sqlite3'
67
+ end
68
+
69
+ def self . oracle?
70
+ ENV [ 'DB_ADAPTER' ] == 'oracle_enhanced'
71
+ end
72
+
73
+ def self . mysql?
74
+ ENV [ 'DB_ADAPTER' ] == 'mysql2'
75
+ end
76
+
77
+ def self . postgresql?
78
+ ENV [ 'DB_ADAPTER' ] == 'postgresql'
79
+ end
80
+ end
81
+
64
82
# Configure ActiveRecord
65
83
adapter = ENV . fetch ( 'DB_ADAPTER' , 'postgresql' )
84
+ ENV [ 'DB_ADAPTER' ] = adapter
66
85
67
86
options = {
68
87
adapter : adapter ,
You can’t perform that action at this time.
0 commit comments