diff options
author | kenjiszk <kenji.suzuki.1984@gmail.com> | 2016-05-21 13:32:28 +0000 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-09-01 22:09:01 -0400 |
commit | 15e04b4ef8726198472382204196cad713aac364 (patch) | |
tree | 7da27742a64744ba413c9ad35a26792f8c4e0d54 /activerecord | |
parent | d8ac08f6bf545c025d7540fb680f41233bcca566 (diff) | |
download | rails-15e04b4ef8726198472382204196cad713aac364.tar.gz rails-15e04b4ef8726198472382204196cad713aac364.tar.bz2 rails-15e04b4ef8726198472382204196cad713aac364.zip |
add mysql and sqlite3 default test
[Gannon McGibbon + Kenji Suzuki]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/schema/mysql2_specific_schema.rb | 7 | ||||
-rw-r--r-- | activerecord/test/schema/sqlite_specific_schema.rb | 11 |
3 files changed, 23 insertions, 3 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d216fe16fa..f6311f9256 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -853,8 +853,7 @@ class BasicsTest < ActiveRecord::TestCase assert_equal company, Company.find(company.id) end - # TODO: extend defaults tests to other databases! - if current_adapter?(:PostgreSQLAdapter) + if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter, :SQLite3Adapter) def test_default with_timezone_config default: :local do default = Default.new @@ -866,7 +865,10 @@ class BasicsTest < ActiveRecord::TestCase # char types assert_equal "Y", default.char1 assert_equal "a varchar field", default.char2 - assert_equal "a text field", default.char3 + # Mysql text type can't have default value + unless current_adapter?(:Mysql2Adapter) + assert_equal "a text field", default.char3 + end end end end diff --git a/activerecord/test/schema/mysql2_specific_schema.rb b/activerecord/test/schema/mysql2_specific_schema.rb index 8371ba9528..0f2f6ddd68 100644 --- a/activerecord/test/schema/mysql2_specific_schema.rb +++ b/activerecord/test/schema/mysql2_specific_schema.rb @@ -14,6 +14,13 @@ ActiveRecord::Schema.define do end end + create_table :defaults, force: true do |t| + t.date :fixed_date, default: "2004-01-01" + t.datetime :fixed_time, default: "2004-01-01 00:00:00" + t.column :char1, "char(1)", default: "Y" + t.string :char2, limit: 50, default: "a varchar field" + end + create_table :binary_fields, force: true do |t| t.binary :var_binary, limit: 255 t.binary :var_binary_large, limit: 4095 diff --git a/activerecord/test/schema/sqlite_specific_schema.rb b/activerecord/test/schema/sqlite_specific_schema.rb new file mode 100644 index 0000000000..18192292e4 --- /dev/null +++ b/activerecord/test/schema/sqlite_specific_schema.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +ActiveRecord::Schema.define do + create_table :defaults, force: true do |t| + t.date :fixed_date, default: "2004-01-01" + t.datetime :fixed_time, default: "2004-01-01 00:00:00" + t.column :char1, "char(1)", default: "Y" + t.string :char2, limit: 50, default: "a varchar field" + t.text :char3, limit: 50, default: "a text field" + end +end |