Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Make tests pass again for PostgreSQL and MySQL adapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
aeden committed Aug 25, 2010
1 parent c21f444 commit c8bcd63
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def create_mapping_view(old_name, new_name, options = {})
end

def drop_table_with_cascade(table_name, options = {})
execute "DROP TABLE #{quote_table_name(table_name)} CASCADE CONSTRAINTS"
execute "DROP TABLE #{quote_table_name(table_name)} CASCADE"
end

# Drop a view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module RailsSqlViews
module ConnectionAdapters
module PostgreSQLAdapter
def self.included(base)
base.alias_method_chain :tables, :views_included unless base.method_defined?(:tables_with_views_included)
base.alias_method_chain :tables, :views_included
end
# Returns true as this adapter supports views.
def supports_views?
Expand Down
26 changes: 14 additions & 12 deletions test/connection/native_mysql/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#require 'logger'
#ActiveRecord::Base.logger = Logger.new("debug.log")

ActiveRecord::Base.configurations = {
config['database'] => {
ActiveRecord::Base.silence do
ActiveRecord::Base.configurations = {
config['database'] => {
:adapter => adapter_name,
:username => config['username'],
:password => config['password'],
Expand All @@ -16,15 +17,16 @@
:encoding => config['encoding'],
:schema_file => config['schema_file'],
}
}
}

ActiveRecord::Base.establish_connection config['database']
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.establish_connection config['database']
ActiveRecord::Migration.verbose = false

puts "Resetting database"
conn = ActiveRecord::Base.connection
conn.recreate_database(conn.current_database)
conn.reconnect!
lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
lines.join.split(';').each { |line| conn.execute(line) }
conn.reconnect!
puts "Resetting database"
conn = ActiveRecord::Base.connection
conn.recreate_database(conn.current_database)
conn.reconnect!
lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
lines.join.split(';').each { |line| conn.execute(line) }
conn.reconnect!
end
22 changes: 12 additions & 10 deletions test/connection/native_postgresql/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#require 'logger'
#ActiveRecord::Base.logger = Logger.new("debug.log")

ActiveRecord::Base.configurations = {
ActiveRecord::Base.silence do
ActiveRecord::Base.configurations = {
'rails_sql_views_unittest' => {
:adapter => adapter_name,
:username => config['username'],
Expand All @@ -16,14 +17,15 @@
:encoding => config['encoding'],
:schema_file => config['schema_file'],
}
}
}

ActiveRecord::Base.establish_connection config['database']
ActiveRecord::Base.establish_connection config['database']

puts "Resetting database"
conn = ActiveRecord::Base.connection
#conn.recreate_database(conn.current_database)
conn.reconnect!
lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
lines.join.split(';').each { |line| conn.execute(line) }
conn.reconnect!
puts "Resetting database"
conn = ActiveRecord::Base.connection
#conn.recreate_database(conn.current_database)
conn.reconnect!
lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
lines.join.split(';').each { |line| conn.execute(line) }
conn.reconnect!
end

0 comments on commit c8bcd63

Please sign in to comment.