use_db 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -17
- data/lib/use_db/version.rb +1 -1
- data/lib/use_db.rb +1 -1
- data/lib/use_db_test_setup.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -61,32 +61,31 @@ You may find it useful (and more DRY) to define an abstract model to inherit fro
|
|
61
61
|
|
62
62
|
Each migration intended for a different database needs to be told which to use. Do this by adding a method "self.database_model" and returning the class name which defines the other database. If you don't, it defaults to the core database like normal.
|
63
63
|
|
64
|
-
class ChangeOtherDatabaseTable < ActiveRecord::Migration
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
class ChangeOtherDatabaseTable < ActiveRecord::Migration
|
65
|
+
# For clarity leave me at the top of the class.
|
66
|
+
def self.database_model
|
67
|
+
# Examples depending if you're using an abstract class or not:
|
68
|
+
# return "LegacyDataBase"
|
69
|
+
# return "MyModel"
|
70
|
+
end
|
71
71
|
end
|
72
72
|
|
73
|
-
end
|
74
|
-
|
75
73
|
=== TESTING
|
76
74
|
|
77
|
-
In order to test multiple databases, you must invoke a task which clones
|
78
|
-
structure and copies it into the test database, clearing out the existing test data.
|
79
|
-
helper method which executes this task and you invoke it as follows:
|
75
|
+
In order to test multiple databases, you must require the test setup class and invoke a task which clones
|
76
|
+
the development database structure and copies it into the test database, clearing out the existing test data.
|
77
|
+
There is a single helper method which executes this task and you invoke it as follows:
|
80
78
|
|
81
|
-
|
79
|
+
require 'use_db_test_setup'
|
80
|
+
UseDbTestSetup.prepare_test_db(:prefix => "your_other_database_prefix_", :suffix => "_is_legacy")
|
82
81
|
|
83
82
|
Even though it might not be the best place for it, I put this in my test_helper.
|
84
83
|
You don't want it to execute for every test, so put something like this around it:
|
85
84
|
|
86
|
-
unless defined?(CLONED_OTHER_DB_FOR_TESTING)
|
87
|
-
|
88
|
-
|
89
|
-
end
|
85
|
+
unless defined?(CLONED_OTHER_DB_FOR_TESTING)
|
86
|
+
UseDbTestSetup.prepare_test_db(:prefix => "your_other_database_prefix_", :suffix => "_is_legacy")
|
87
|
+
CLONED_OTHER_DB_FOR_TESTING = true
|
88
|
+
end
|
90
89
|
|
91
90
|
=== DEBUGGING
|
92
91
|
|
data/lib/use_db/version.rb
CHANGED
data/lib/use_db.rb
CHANGED
data/lib/use_db_test_setup.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: use_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ron Guarisco
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-12 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|