Skip to content
Browse files

oops, forgot to commit this test!

  • Loading branch information...
1 parent eb1eac9 commit 66c8c6cb0d5af5467d876c8f4b774d09373d888c @tenderlove tenderlove committed Mar 21, 2011
Showing with 36 additions and 0 deletions.
  1. +36 −0 activerecord/test/cases/adapters/mysql/schema_test.rb
View
36 activerecord/test/cases/adapters/mysql/schema_test.rb
@@ -0,0 +1,36 @@
+require "cases/helper"
+require 'models/post'
+require 'models/comment'
+
+module ActiveRecord
+ module ConnectionAdapters
+ class MysqlSchemaTest < ActiveRecord::TestCase
+ fixtures :posts
+
+ def setup
+ @connection = ActiveRecord::Base.connection
+ db = Post.connection_pool.spec.config[:database]
+ table = Post.table_name
+ @db_name = db
+
+ @omgpost = Class.new(Post) do
+ set_table_name "#{db}.#{table}"
+ def self.name; 'Post'; end
+ end
+ end
+
+ def test_schema
+ assert @omgpost.find(:first)
+ end
+
+ def test_table_exists?
+ name = @omgpost.table_name
+ assert @connection.table_exists?(name), "#{name} table should exist"
+ end
+
+ def test_table_exists_wrong_schema
+ assert(!@connection.table_exists?("#{@db_name}.zomg"), "table should not exist")
+ end
+ end if current_adapter?(:MysqlAdapter)
+ end
+end

0 comments on commit 66c8c6c

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