aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-11-06 15:31:18 +0100
committerYves Senn <yves.senn@gmail.com>2014-11-06 15:33:57 +0100
commitde83f28dc1385eb037c70b6c631fc3aeade9fceb (patch)
treeff26934c023e21686790f4382e158c06e819bc43 /activerecord/test/cases/adapters
parente16f8e58e75587033c4ac7acb11492f31387b90d (diff)
downloadrails-de83f28dc1385eb037c70b6c631fc3aeade9fceb.tar.gz
rails-de83f28dc1385eb037c70b6c631fc3aeade9fceb.tar.bz2
rails-de83f28dc1385eb037c70b6c631fc3aeade9fceb.zip
tests, use SchemaDumpingHelper to dump a specific table.
This makes debugging the generated schema output much easier. As a side effect it also shaves off 2.5 seconds of test runtime.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r--activerecord/test/cases/adapters/postgresql/uuid_test.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
index 376dc2490e..c3705e7dac 100644
--- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb
@@ -3,6 +3,7 @@
require "cases/helper"
require 'active_record/base'
require 'active_record/connection_adapters/postgresql_adapter'
+require 'support/schema_dumping_helper'
module PostgresqlUUIDHelper
def connection
@@ -112,6 +113,8 @@ end
class PostgresqlLargeKeysTest < ActiveRecord::TestCase
include PostgresqlUUIDHelper
+ include SchemaDumpingHelper
+
def setup
connection.create_table('big_serials', id: :bigserial) do |t|
t.string 'name'
@@ -119,10 +122,8 @@ class PostgresqlLargeKeysTest < ActiveRecord::TestCase
end
def test_omg
- schema = StringIO.new
- ActiveRecord::SchemaDumper.dump(connection, schema)
- assert_match "create_table \"big_serials\", id: :bigserial, force: true",
- schema.string
+ schema = dump_table_schema "big_serials"
+ assert_match "create_table \"big_serials\", id: :bigserial, force: true", schema
end
def teardown
@@ -132,6 +133,7 @@ end
class PostgresqlUUIDGenerationTest < ActiveRecord::TestCase
include PostgresqlUUIDHelper
+ include SchemaDumpingHelper
class UUID < ActiveRecord::Base
self.table_name = 'pg_uuids'
@@ -191,17 +193,15 @@ class PostgresqlUUIDGenerationTest < ActiveRecord::TestCase
end
def test_schema_dumper_for_uuid_primary_key
- schema = StringIO.new
- ActiveRecord::SchemaDumper.dump(connection, schema)
- assert_match(/\bcreate_table "pg_uuids", id: :uuid, default: "uuid_generate_v1\(\)"/, schema.string)
- assert_match(/t\.uuid "other_uuid", default: "uuid_generate_v4\(\)"/, schema.string)
+ schema = dump_table_schema "pg_uuids"
+ assert_match(/\bcreate_table "pg_uuids", id: :uuid, default: "uuid_generate_v1\(\)"/, schema)
+ assert_match(/t\.uuid "other_uuid", default: "uuid_generate_v4\(\)"/, schema)
end
def test_schema_dumper_for_uuid_primary_key_with_custom_default
- schema = StringIO.new
- ActiveRecord::SchemaDumper.dump(connection, schema)
- assert_match(/\bcreate_table "pg_uuids_2", id: :uuid, default: "my_uuid_generator\(\)"/, schema.string)
- assert_match(/t\.uuid "other_uuid_2", default: "my_uuid_generator\(\)"/, schema.string)
+ schema = dump_table_schema "pg_uuids_2"
+ assert_match(/\bcreate_table "pg_uuids_2", id: :uuid, default: "my_uuid_generator\(\)"/, schema)
+ assert_match(/t\.uuid "other_uuid_2", default: "my_uuid_generator\(\)"/, schema)
end
end
end