aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-10 10:23:42 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-10 10:23:42 -0800
commit3092324ef4e2f6f096adfbcf92597502b3ce91aa (patch)
treee88523b0d13982371dfd6ec3d36000191d128e67 /activerecord/test/cases/adapters/postgresql/active_schema_test.rb
parentfc3fad8d85a82e2ac9ed5c108fb2410b72ab447b (diff)
parentaaffc2acd5fa3104fa936c334ef9d50774071c8b (diff)
downloadrails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.tar.gz
rails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.tar.bz2
rails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.zip
Merge pull request #4956 from mhfs/pg_partial_indices
Add support for partial indices to PostgreSQL adapter
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/active_schema_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/active_schema_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
index e4746d4aa3..447d729e52 100644
--- a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
@@ -21,6 +21,18 @@ class PostgresqlActiveSchemaTest < ActiveRecord::TestCase
assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'latin1'), create_database(:aimonetti, :encoding => :latin1)
end
+ def test_add_index
+ # add_index calls index_name_exists? which can't work since execute is stubbed
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:define_method, :index_name_exists?) do |*|
+ false
+ end
+
+ expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" ("last_name") WHERE state = 'active')
+ assert_equal expected, add_index(:people, :last_name, :unique => true, :where => "state = 'active'")
+
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:remove_method, :index_name_exists?)
+ end
+
private
def method_missing(method_symbol, *arguments)
ActiveRecord::Base.connection.send(method_symbol, *arguments)