diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-05 07:06:09 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-06 08:30:45 -0600 |
commit | c52cb16e204669b005f0bab61f509c71993d88e2 (patch) | |
tree | 75b3332db2901efa72bc2b7655fba38e338bdf7d | |
parent | 485dab41c4ff7de392ffba132fbcbff49e6fe9ef (diff) | |
download | rails-c52cb16e204669b005f0bab61f509c71993d88e2.tar.gz rails-c52cb16e204669b005f0bab61f509c71993d88e2.tar.bz2 rails-c52cb16e204669b005f0bab61f509c71993d88e2.zip |
Add missing test cases for schema dumping defaults
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index ce2b06430b..e2a18d138d 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'support/schema_dumping_helper' class SchemaDumperTest < ActiveRecord::TestCase setup do @@ -403,3 +404,31 @@ class SchemaDumperTest < ActiveRecord::TestCase end end + +class SchemaDumperDefaultsTest < ActiveRecord::TestCase + include SchemaDumpingHelper + + setup do + @connection = ActiveRecord::Base.connection + @connection.create_table :defaults, force: true do |t| + t.string :string_with_default, default: "Hello!" + t.date :date_with_default, default: '2014-06-05' + t.datetime :datetime_with_default, default: "2014-06-05 07:17:04" + t.time :time_with_default, default: "07:17:04" + end + end + + teardown do + return unless @connection + @connection.execute 'DROP TABLE IF EXISTS defaults' + end + + def test_schema_dump_defaults_with_universally_supported_types + output = dump_table_schema('defaults') + + assert_match %r{t\.string\s+"string_with_default",\s+default: "Hello!"}, output + assert_match %r{t\.date\s+"date_with_default",\s+default: '2014-06-05'}, output + assert_match %r{t\.datetime\s+"datetime_with_default",\s+default: '2014-06-05 07:17:04'}, output + assert_match %r{t\.time\s+"time_with_default",\s+default: '2000-01-01 07:17:04'}, output + end +end |