diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-19 07:41:44 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-19 07:41:44 -0700 |
commit | 1aa052c6889bf5371ec92e5bfc461070d7d99761 (patch) | |
tree | 8f70dd921b3d88140ad1ee884ab6bee6d7f789c8 /activerecord/test | |
parent | 4d69cdbdd75f5a9594055099770c4c3d0ffeb98d (diff) | |
parent | 363ab882165dc89a642c4fed01417bd64cdce0a8 (diff) | |
download | rails-1aa052c6889bf5371ec92e5bfc461070d7d99761.tar.gz rails-1aa052c6889bf5371ec92e5bfc461070d7d99761.tar.bz2 rails-1aa052c6889bf5371ec92e5bfc461070d7d99761.zip |
Merge pull request #6779 from simonjefford/db-rake-charset
Refactor db:charset task
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/database_tasks_test.rb | 34 | ||||
-rw-r--r-- | activerecord/test/cases/mysql_rake_test.rb | 20 | ||||
-rw-r--r-- | activerecord/test/cases/postgresql_rake_test.rb | 20 | ||||
-rw-r--r-- | activerecord/test/cases/sqlite_rake_test.rb | 22 |
4 files changed, 93 insertions, 3 deletions
diff --git a/activerecord/test/cases/database_tasks_test.rb b/activerecord/test/cases/database_tasks_test.rb index 503e26f549..a5329073ed 100644 --- a/activerecord/test/cases/database_tasks_test.rb +++ b/activerecord/test/cases/database_tasks_test.rb @@ -294,4 +294,38 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.purge 'adapter' => 'sqlite3' end end + + class DatabaseTasksCharsetTest < ActiveRecord::TestCase + def setup + @mysql_tasks, @postgresql_tasks, @sqlite_tasks = stub, stub, stub + ActiveRecord::Tasks::MySQLDatabaseTasks.stubs(:new).returns @mysql_tasks + ActiveRecord::Tasks::PostgreSQLDatabaseTasks.stubs(:new). + returns @postgresql_tasks + ActiveRecord::Tasks::SQLiteDatabaseTasks.stubs(:new).returns @sqlite_tasks + end + + def test_mysql_charset + @mysql_tasks.expects(:charset) + + ActiveRecord::Tasks::DatabaseTasks.charset 'adapter' => 'mysql' + end + + def test_mysql2_charset + @mysql_tasks.expects(:charset) + + ActiveRecord::Tasks::DatabaseTasks.charset 'adapter' => 'mysql2' + end + + def test_postgresql_charset + @postgresql_tasks.expects(:charset) + + ActiveRecord::Tasks::DatabaseTasks.charset 'adapter' => 'postgresql' + end + + def test_sqlite_charset + @sqlite_tasks.expects(:charset) + + ActiveRecord::Tasks::DatabaseTasks.charset 'adapter' => 'sqlite3' + end + end end diff --git a/activerecord/test/cases/mysql_rake_test.rb b/activerecord/test/cases/mysql_rake_test.rb index 1dfd28df54..39d0ae428c 100644 --- a/activerecord/test/cases/mysql_rake_test.rb +++ b/activerecord/test/cases/mysql_rake_test.rb @@ -176,4 +176,22 @@ module ActiveRecord ) end end -end
\ No newline at end of file + + class MysqlDBCharsetTest < ActiveRecord::TestCase + def setup + @connection = stub(:create_database => true) + @configuration = { + 'adapter' => 'mysql', + 'database' => 'my-app-db' + } + + ActiveRecord::Base.stubs(:connection).returns(@connection) + ActiveRecord::Base.stubs(:establish_connection).returns(true) + end + + def test_db_retrieves_charset + @connection.expects(:charset) + ActiveRecord::Tasks::DatabaseTasks.charset @configuration + end + end +end diff --git a/activerecord/test/cases/postgresql_rake_test.rb b/activerecord/test/cases/postgresql_rake_test.rb index 58168e4948..a9e0d913fa 100644 --- a/activerecord/test/cases/postgresql_rake_test.rb +++ b/activerecord/test/cases/postgresql_rake_test.rb @@ -132,4 +132,22 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.purge @configuration end end -end
\ No newline at end of file + + class PostgreSQLDBCharsetTest < ActiveRecord::TestCase + def setup + @connection = stub(:create_database => true) + @configuration = { + 'adapter' => 'postgresql', + 'database' => 'my-app-db' + } + + ActiveRecord::Base.stubs(:connection).returns(@connection) + ActiveRecord::Base.stubs(:establish_connection).returns(true) + end + + def test_db_retrieves_charset + @connection.expects(:encoding) + ActiveRecord::Tasks::DatabaseTasks.charset @configuration + end + end +end diff --git a/activerecord/test/cases/sqlite_rake_test.rb b/activerecord/test/cases/sqlite_rake_test.rb index f68809bfda..cfca937a24 100644 --- a/activerecord/test/cases/sqlite_rake_test.rb +++ b/activerecord/test/cases/sqlite_rake_test.rb @@ -103,4 +103,24 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.drop @configuration, '/rails/root' end end -end
\ No newline at end of file + + class SqliteDBCharsetTest < ActiveRecord::TestCase + def setup + @database = 'db_create.sqlite3' + @connection = stub :connection + @configuration = { + 'adapter' => 'sqlite3', + 'database' => @database + } + + File.stubs(:exist?).returns(false) + ActiveRecord::Base.stubs(:connection).returns(@connection) + ActiveRecord::Base.stubs(:establish_connection).returns(true) + end + + def test_db_retrieves_charset + @connection.expects(:encoding) + ActiveRecord::Tasks::DatabaseTasks.charset @configuration, '/rails/root' + end + end +end |