Sha256: d679a0495ae0c955f89e18f3046ac104e54214e738af094ec82ad18bb0682d0e
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'pathname' require 'yaml' require 'ar_transaction_changes' require 'minitest/autorun' ENV["RAILS_ENV"] = "test" test_dir = Pathname.new(File.dirname(__FILE__)) config_filename = test_dir.join("database.yml").exist? ? "database.yml" : "database.yml.default" database_yml = YAML.load(test_dir.join(config_filename).read) database_config = database_yml.fetch("test") if database_config.fetch('adapter') != 'sqlite3' ActiveRecord::Base.establish_connection(database_config.except("database")) ActiveRecord::Base.connection.recreate_database(database_config.fetch("database")) end ActiveRecord::Base.establish_connection(database_config) ActiveRecord::Base.connection.tap do |db| db.create_table(:users) do |t| t.string :name t.string :occupation t.integer :age t.text :connection_details t.text :notes t.timestamps null: false end end Dir[test_dir.join("models/*.rb")].each{ |file| require file } serializable_classes = [User::ConnectionDetails] if ActiveRecord::VERSION::MAJOR >= 7 ActiveRecord.yaml_column_permitted_classes += serializable_classes else ActiveRecord::Base.yaml_column_permitted_classes += serializable_classes end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ar_transaction_changes-1.1.9 | test/test_helper.rb |