Skip to content

Commit

Permalink
replace the aaa_create_tables_test hack with loading test database sc…
Browse files Browse the repository at this point in the history
…hema in the test helper [#2663 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
mislav authored and josh committed May 17, 2009
1 parent 0920890 commit b33c0d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
24 changes: 0 additions & 24 deletions activerecord/test/cases/aaa_create_tables_test.rb

This file was deleted.

18 changes: 18 additions & 0 deletions activerecord/test/cases/helper.rb
Expand Up @@ -5,6 +5,7 @@

require 'rubygems'
require 'test/unit'
require 'stringio'
gem 'mocha', '>= 0.9.5'
require 'mocha'

Expand Down Expand Up @@ -72,3 +73,20 @@ def create_fixtures(*table_names, &block)
Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
end
end

# silence verbose schema loading
original_stdout = $stdout
$stdout = StringIO.new

begin
adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
adapter_specific_schema_file = SCHEMA_ROOT + "/#{adapter_name}_specific_schema.rb"

load SCHEMA_ROOT + "/schema.rb"

if File.exists?(adapter_specific_schema_file)
load adapter_specific_schema_file
end
ensure
$stdout = original_stdout
end
5 changes: 4 additions & 1 deletion activerecord/test/schema/schema.rb
@@ -1,4 +1,3 @@

ActiveRecord::Schema.define do
def except(adapter_names_to_exclude)
unless [adapter_names_to_exclude].flatten.include?(adapter_name)
Expand Down Expand Up @@ -500,3 +499,7 @@ def create_table(*args, &block)
execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})"
end
end

Course.connection.create_table :courses, :force => true do |t|
t.column :name, :string, :null => false
end
6 changes: 0 additions & 6 deletions activerecord/test/schema/schema2.rb

This file was deleted.

0 comments on commit b33c0d9

Please sign in to comment.