Skip to content

Commit

Permalink
Merge pull request #3 from Shopify/shioyama/cleanup
Browse files Browse the repository at this point in the history
Get tests to pass locally
  • Loading branch information
shioyama authored Jan 31, 2025
2 parents 218ad02 + 5b9b481 commit 7cb42bf
Show file tree
Hide file tree
Showing 4 changed files with 29 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.1
14 changes: 14 additions & 0 deletions dev.yml
Original file line number Diff line number Diff line change
@@ -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
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 7cb42bf

Please sign in to comment.