Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove duplicated codes.

  • Loading branch information...
commit 30c84aababbd9411a0820e9e238f12b4c6054714 1 parent 1991195
@kennyj kennyj authored
Showing with 11 additions and 41 deletions.
  1. +11 −41 activerecord/test/cases/database_tasks_test.rb
View
52 activerecord/test/cases/database_tasks_test.rb
@@ -1,15 +1,17 @@
require 'cases/helper'
module ActiveRecord
- class DatabaseTasksCreateTest < ActiveRecord::TestCase
+ module DatabaseTasksSetupper
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::PostgreSQLDatabaseTasks.stubs(:new).returns @postgresql_tasks
ActiveRecord::Tasks::SQLiteDatabaseTasks.stubs(:new).returns @sqlite_tasks
end
+ end
+
+ class DatabaseTasksCreateTest < ActiveRecord::TestCase
+ include DatabaseTasksSetupper
def test_mysql_create
@mysql_tasks.expects(:create)
@@ -137,14 +139,7 @@ def test_establishes_connection_for_the_given_environment
end
class DatabaseTasksDropTest < 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
+ include DatabaseTasksSetupper
def test_mysql_create
@mysql_tasks.expects(:drop)
@@ -261,14 +256,7 @@ def test_creates_test_database_when_environment_is_database
end
class DatabaseTasksPurgeTest < 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
+ include DatabaseTasksSetupper
def test_mysql_create
@mysql_tasks.expects(:purge)
@@ -296,13 +284,7 @@ def test_sqlite_create
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
+ include DatabaseTasksSetupper
def test_mysql_charset
@mysql_tasks.expects(:charset)
@@ -330,13 +312,7 @@ def test_sqlite_charset
end
class DatabaseTasksStructureDumpTest < 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
+ include DatabaseTasksSetupper
def test_mysql_structure_dump
@mysql_tasks.expects(:structure_dump).with("awesome-file.sql")
@@ -364,13 +340,7 @@ def test_sqlite_structure_dump
end
class DatabaseTasksStructureLoadTest < 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
+ include DatabaseTasksSetupper
def test_mysql_structure_load
@mysql_tasks.expects(:structure_load).with("awesome-file.sql")
Please sign in to comment.
Something went wrong with that request. Please try again.