aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql/schema_test.rb
diff options
context:
space:
mode:
authorJohn Mileham <jmileham@gmail.com>2011-03-24 15:03:08 -0400
committerJohn Mileham <jmileham@gmail.com>2011-03-24 15:03:08 -0400
commitb44a0ec153c84384e9b97a069e81f28bc5c2a4bf (patch)
tree94713aff0c241f91530dfd714bf685019c84ccab /activerecord/test/cases/adapters/mysql/schema_test.rb
parentd5994ee48af14d67f0eec7d23863d4b19211b078 (diff)
parent5214e73850916de3c9127d35a4ecee0424d364a3 (diff)
downloadrails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.tar.gz
rails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.tar.bz2
rails-b44a0ec153c84384e9b97a069e81f28bc5c2a4bf.zip
Merge branch 'master' of github.com:rails/rails into count_behavior
Diffstat (limited to 'activerecord/test/cases/adapters/mysql/schema_test.rb')
-rw-r--r--activerecord/test/cases/adapters/mysql/schema_test.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb
new file mode 100644
index 0000000000..c6c1d1dad5
--- /dev/null
+++ b/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