Skip to content

Commit

Permalink
Merge pull request #10775 from senny/postgres_adapter_test_cleanup
Browse files Browse the repository at this point in the history
test cleanup, replace `define_method` and `remove_method` with stubs.
  • Loading branch information
rafaelfranca committed May 28, 2013
2 parents 5a687e9 + 1c998a7 commit bf4f821
Showing 1 changed file with 1 addition and 5 deletions.
Expand Up @@ -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'")
Expand All @@ -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
Expand Down

0 comments on commit bf4f821

Please sign in to comment.