diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..47b322c --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.4.1 diff --git a/dev.yml b/dev.yml new file mode 100644 index 0000000..aa887ab --- /dev/null +++ b/dev.yml @@ -0,0 +1,14 @@ +# This file is for Shopify employees development environment. +# If you are an external contributor you don't have to bother with it. +name: activerecord-databasevalidations + +up: + - packages: + - mysql_client + - ruby + - bundler + - mysql + - custom: + name: Create database + meet: mysql -uroot -h $MYSQL_HOST -P $MYSQL_PORT -e "CREATE DATABASE database_validations" + met?: mysql -uroot -h $MYSQL_HOST -P $MYSQL_PORT database_validations -e "SELECT 1" &> /dev/null diff --git a/test/database.yml b/test/database.yml deleted file mode 100644 index 2f90fd0..0000000 --- a/test/database.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - adapter: mysql2 - database: database_validations - #username: travis - host: localhost - username: root - encoding: utf8mb4 - strict: false diff --git a/test/test_helper.rb b/test/test_helper.rb index f7484b3..3d4cc27 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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 @@ -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