aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/active_schema_test_postgresql.rb
blob: f106e14319848db35f6e4b19be54e79b502dab62 (plain) (tree)
1
2
3
4
5
6
7





                                                                     
                            




                                          



                                                                     


                                        

                                                                                                                      






                                                                   
require 'cases/helper'

class PostgresqlActiveSchemaTest < Test::Unit::TestCase
  def setup
    ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
      alias_method :real_execute, :execute
      remove_method :execute
      def execute(sql, name = nil) sql end
    end
  end

  def teardown
    ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
      remove_method :execute
      alias_method :execute, :real_execute
    end
  end

  def test_create_database_with_encoding
    assert_equal %(CREATE DATABASE "matt" ENCODING = 'utf8'), create_database(:matt)
    assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'latin1'), create_database(:aimonetti, :encoding => :latin1)
  end

  private
    def method_missing(method_symbol, *arguments)
      ActiveRecord::Base.connection.send(method_symbol, *arguments)
    end
end