Permalink
Browse files

Merge pull request #10775 from senny/postgres_adapter_test_cleanup

test cleanup, replace `define_method` and `remove_method` with stubs.
  • Loading branch information...
2 parents 5a687e9 + 1c998a7 commit bf4f8211e1bc76fe4976d37998c81994b6dc3864 @rafaelfranca rafaelfranca committed May 28, 2013
Showing with 1 addition and 5 deletions.
  1. +1 −5 activerecord/test/cases/adapters/postgresql/active_schema_test.rb
@@ -25,9 +25,7 @@ def test_create_database_with_collation_and_ctype
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
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.stubs(:index_name_exists?).returns(false)
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'")
@@ -51,8 +49,6 @@ def test_add_index
expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" USING gist ("last_name") WHERE state = 'active')
assert_equal expected, add_index(:people, :last_name, :unique => true, :where => "state = 'active'", :using => :gist)
-
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:remove_method, :index_name_exists?)
end
private

0 comments on commit bf4f821

Please sign in to comment.