Skip to content

Commit

Permalink
Set correct config for MySQL db connection
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Jan 30, 2025
1 parent 24a4887 commit f115529
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.0-preview2
8 changes: 0 additions & 8 deletions test/database.yml

This file was deleted.

19 changes: 14 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def assert_data_loss(record)

persisted_values = record.reload.attributes.slice(*attributes)
refute_equal provided_values, persisted_values
rescue RangeError
rescue ActiveRecord::RangeError, ActiveRecord::StatementInvalid, ActiveModel::RangeError
pass
end

Expand All @@ -33,8 +33,17 @@ def refute_data_loss(record)
end
end

Minitest::Test = MiniTest::Unit::TestCase unless defined?(MiniTest::Test)

database_yml = YAML.load_file(File.expand_path('../database.yml', __FILE__))
ActiveRecord::Base.establish_connection(database_yml['test'])
mysql_host = ENV.fetch("MYSQL_HOST") { "localhost" }
mysql_port = ENV.fetch("MYSQL_PORT") { 3306 }
connection_config = {
adapter: "mysql2",
database: "database_validations",
username: "root",
encoding: "utf8mb4",
strict: false,
host: mysql_host,
port: mysql_port,
}

ActiveRecord::Base.establish_connection(connection_config)
I18n.enforce_available_locales = false

0 comments on commit f115529

Please sign in to comment.