forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemas set by set_table_name are respected by the mysql adapter. [ra…
…ils#5322 state:resolved]
- Loading branch information
1 parent
96b9fc4
commit ea8fcfb
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |