Skip to content

Commit 5820fad

Browse files
author
Nicolas Rodriguez
committed
Fix tests with MySQL
1 parent 61ca5a1 commit 5820fad

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spec/spec_helper.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@
5757

5858
require 'ajax-datatables-rails'
5959

60-
ActiveRecord::Base.establish_connection(
61-
adapter: ENV.fetch('DB_ADAPTER', 'postgresql'),
62-
database: 'ajax_datatables_rails'
63-
)
60+
adapter = ENV.fetch('DB_ADAPTER', 'postgresql')
61+
62+
options = {
63+
adapter: adapter,
64+
database: 'ajax_datatables_rails',
65+
encoding: 'utf8'
66+
}
67+
68+
options = options.merge(username: 'root', host: '127.0.0.1') if adapter == 'mysql2'
69+
options = options.merge(database: 'tmp/test.sqlite3') if adapter == 'sqlite3'
70+
71+
ActiveRecord::Base.establish_connection(options)
6472

6573
AjaxDatatablesRails.configure do |c|
6674
c.db_adapter = ActiveRecord::Base.connection.adapter_name.downcase.to_sym

0 commit comments

Comments
 (0)