Skip to content
This repository
Browse code

Make tests pass again for PostgreSQL and MySQL adapters.

  • Loading branch information...
commit c8bcd632392cb6bcd889fcfe13c9072b147587f7 1 parent c21f444
Anthony Eden aeden authored
2  lib/rails_sql_views/connection_adapters/abstract/schema_statements.rb
@@ -59,7 +59,7 @@ def create_mapping_view(old_name, new_name, options = {})
59 59 end
60 60
61 61 def drop_table_with_cascade(table_name, options = {})
62   - execute "DROP TABLE #{quote_table_name(table_name)} CASCADE CONSTRAINTS"
  62 + execute "DROP TABLE #{quote_table_name(table_name)} CASCADE"
63 63 end
64 64
65 65 # Drop a view.
2  lib/rails_sql_views/connection_adapters/postgresql_adapter.rb
@@ -2,7 +2,7 @@ module RailsSqlViews
2 2 module ConnectionAdapters
3 3 module PostgreSQLAdapter
4 4 def self.included(base)
5   - base.alias_method_chain :tables, :views_included unless base.method_defined?(:tables_with_views_included)
  5 + base.alias_method_chain :tables, :views_included
6 6 end
7 7 # Returns true as this adapter supports views.
8 8 def supports_views?
26 test/connection/native_mysql/connection.rb
@@ -6,8 +6,9 @@
6 6 #require 'logger'
7 7 #ActiveRecord::Base.logger = Logger.new("debug.log")
8 8
9   -ActiveRecord::Base.configurations = {
10   - config['database'] => {
  9 +ActiveRecord::Base.silence do
  10 + ActiveRecord::Base.configurations = {
  11 + config['database'] => {
11 12 :adapter => adapter_name,
12 13 :username => config['username'],
13 14 :password => config['password'],
@@ -16,15 +17,16 @@
16 17 :encoding => config['encoding'],
17 18 :schema_file => config['schema_file'],
18 19 }
19   -}
  20 + }
20 21
21   -ActiveRecord::Base.establish_connection config['database']
22   -ActiveRecord::Migration.verbose = false
  22 + ActiveRecord::Base.establish_connection config['database']
  23 + ActiveRecord::Migration.verbose = false
23 24
24   -puts "Resetting database"
25   -conn = ActiveRecord::Base.connection
26   -conn.recreate_database(conn.current_database)
27   -conn.reconnect!
28   -lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
29   -lines.join.split(';').each { |line| conn.execute(line) }
30   -conn.reconnect!
  25 + puts "Resetting database"
  26 + conn = ActiveRecord::Base.connection
  27 + conn.recreate_database(conn.current_database)
  28 + conn.reconnect!
  29 + lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
  30 + lines.join.split(';').each { |line| conn.execute(line) }
  31 + conn.reconnect!
  32 +end
22 test/connection/native_postgresql/connection.rb
@@ -6,7 +6,8 @@
6 6 #require 'logger'
7 7 #ActiveRecord::Base.logger = Logger.new("debug.log")
8 8
9   -ActiveRecord::Base.configurations = {
  9 +ActiveRecord::Base.silence do
  10 + ActiveRecord::Base.configurations = {
10 11 'rails_sql_views_unittest' => {
11 12 :adapter => adapter_name,
12 13 :username => config['username'],
@@ -16,14 +17,15 @@
16 17 :encoding => config['encoding'],
17 18 :schema_file => config['schema_file'],
18 19 }
19   -}
  20 + }
20 21
21   -ActiveRecord::Base.establish_connection config['database']
  22 + ActiveRecord::Base.establish_connection config['database']
22 23
23   -puts "Resetting database"
24   -conn = ActiveRecord::Base.connection
25   -#conn.recreate_database(conn.current_database)
26   -conn.reconnect!
27   -lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
28   -lines.join.split(';').each { |line| conn.execute(line) }
29   -conn.reconnect!
  24 + puts "Resetting database"
  25 + conn = ActiveRecord::Base.connection
  26 + #conn.recreate_database(conn.current_database)
  27 + conn.reconnect!
  28 + lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
  29 + lines.join.split(';').each { |line| conn.execute(line) }
  30 + conn.reconnect!
  31 +end

0 comments on commit c8bcd63

Please sign in to comment.
Something went wrong with that request. Please try again.