diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 13:54:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 13:54:00 -0700 |
commit | 836b54eed8c78ccf53e9d76855a02fd007ad6145 (patch) | |
tree | 5fd9f04aa6061ee6c6a3a91f5fb1b6c4c111430c /activerecord/test | |
parent | d54ce7129c9a5983b5f0bfd05b35b52229211014 (diff) | |
parent | 323b7585e106ca9ca26db5a886801239c725a95a (diff) | |
download | rails-836b54eed8c78ccf53e9d76855a02fd007ad6145.tar.gz rails-836b54eed8c78ccf53e9d76855a02fd007ad6145.tar.bz2 rails-836b54eed8c78ccf53e9d76855a02fd007ad6145.zip |
Merge pull request #381 from joshk/mysql2_schema_test.
Added the mysql schema test to mysql2 adapter
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/schema_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/schema_test.rb | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb index c6c1d1dad5..a2155d1dd1 100644 --- a/activerecord/test/cases/adapters/mysql/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/schema_test.rb @@ -31,6 +31,6 @@ module ActiveRecord 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 end diff --git a/activerecord/test/cases/adapters/mysql2/schema_test.rb b/activerecord/test/cases/adapters/mysql2/schema_test.rb new file mode 100644 index 0000000000..858d1da2dd --- /dev/null +++ b/activerecord/test/cases/adapters/mysql2/schema_test.rb @@ -0,0 +1,36 @@ +require "cases/helper" +require 'models/post' +require 'models/comment' + +module ActiveRecord + module ConnectionAdapters + class Mysql2SchemaTest < 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 + end +end |