aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-07 10:58:55 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-03-07 10:58:55 -0800
commit89cef0757aee00e2b7dc742f155a18c82e3fa915 (patch)
tree0496f35d1794f170ec804b5f230aa6e8b2b239e4 /activerecord/test/cases
parent3da31b948f0e9af07e503d955f27ffd5d91c84cb (diff)
parent8dc1a625c87950f4b258b7f6fc1036e08b192daa (diff)
downloadrails-89cef0757aee00e2b7dc742f155a18c82e3fa915.tar.gz
rails-89cef0757aee00e2b7dc742f155a18c82e3fa915.tar.bz2
rails-89cef0757aee00e2b7dc742f155a18c82e3fa915.zip
Merge pull request #5315 from travisjeffery/enhance_postgresql_adapter_schema_support
Enhance PostgreSQL Adapter schema support
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/adapters/postgresql/schema_test.rb43
1 files changed, 41 insertions, 2 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb
index 18c81d2b09..9208f53997 100644
--- a/activerecord/test/cases/adapters/postgresql/schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb
@@ -71,6 +71,45 @@ class SchemaTest < ActiveRecord::TestCase
@connection.execute "DROP SCHEMA #{SCHEMA_NAME} CASCADE"
end
+ def test_schema_names
+ assert_equal ["public", "test_schema", "test_schema2"], @connection.schema_names
+ end
+
+ def test_create_schema
+ begin
+ @connection.create_schema "test_schema3"
+ assert @connection.schema_names.include? "test_schema3"
+ ensure
+ @connection.drop_schema "test_schema3"
+ end
+ end
+
+ def test_raise_create_schema_with_existing_schema
+ begin
+ @connection.create_schema "test_schema3"
+ assert_raises(ActiveRecord::StatementInvalid) do
+ @connection.create_schema "test_schema3"
+ end
+ ensure
+ @connection.drop_schema "test_schema3"
+ end
+ end
+
+ def test_drop_schema
+ begin
+ @connection.create_schema "test_schema3"
+ ensure
+ @connection.drop_schema "test_schema3"
+ end
+ assert !@connection.schema_names.include?("test_schema3")
+ end
+
+ def test_raise_drop_schema_with_nonexisting_schema
+ assert_raises(ActiveRecord::StatementInvalid) do
+ @connection.drop_schema "test_schema3"
+ end
+ end
+
def test_schema_change_with_prepared_stmt
altered = false
@connection.exec_query "select * from developers where id = $1", 'sql', [[nil, 1]]
@@ -183,13 +222,13 @@ class SchemaTest < ActiveRecord::TestCase
end
def test_raise_on_unquoted_schema_name
- assert_raise(ActiveRecord::StatementInvalid) do
+ assert_raises(ActiveRecord::StatementInvalid) do
with_schema_search_path '$user,public'
end
end
def test_without_schema_search_path
- assert_raise(ActiveRecord::StatementInvalid) { columns(TABLE_NAME) }
+ assert_raises(ActiveRecord::StatementInvalid) { columns(TABLE_NAME) }
end
def test_ignore_nil_schema_search_path