database_cleaner 0.6.6 → 0.6.7.RC

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,5 +1,11 @@
1
1
  == 0.6.x (in git)
2
2
 
3
+ === Bugfixes
4
+ * Explicity require ERB. (Vít Ondruch)
5
+ * Cache DB connections, fixes referential integrity bug when using multiple DBs. (John Ferlito)
6
+
7
+ == 0.6.6 2011-03-16
8
+
3
9
  === Bugfixes
4
10
  * Don't modify the array passed in with the :except key. (Eric Wollesen)
5
11
  * Fixes version checking for postgresql. (Greg Barnett)
@@ -45,7 +51,7 @@
45
51
  == 0.6.0 2010-10-25 - The Multi-ORM/Connection Release
46
52
 
47
53
  This release has the often asked for functionality of being able to clean
48
- multiple databases within the same project. This involves being able to
54
+ multiple databases within the same project. This involves being able to
49
55
  clean databases managed by the same ORM (i.e. different connections) and
50
56
  also being able to clean databases managed by distinct ORMs. So, for
51
57
  example you can now use DatabaseCleaner on a project that has ActiveRecord
@@ -1,5 +1,6 @@
1
1
  require 'database_cleaner/generic/base'
2
2
  require 'active_record'
3
+ require 'erb'
3
4
 
4
5
  module DatabaseCleaner
5
6
  module ActiveRecord
@@ -53,10 +53,8 @@ module DatabaseCleaner::ActiveRecord
53
53
  class Deletion < Truncation
54
54
 
55
55
  def clean
56
- connection.disable_referential_integrity do
57
- tables_to_truncate.each do |table_name|
58
- connection.delete_table table_name
59
- end
56
+ each_table do |connection, table_name|
57
+ connection.delete_table table_name
60
58
  end
61
59
  end
62
60
 
@@ -103,24 +103,26 @@ module DatabaseCleaner::ActiveRecord
103
103
  include ::DatabaseCleaner::Generic::Truncation
104
104
 
105
105
  def clean
106
+ each_table do |connection, table_name|
107
+ connection.truncate_table table_name
108
+ end
109
+ end
110
+
111
+ def each_table
112
+ connection = connection_klass.connection
106
113
  connection.disable_referential_integrity do
107
- tables_to_truncate.each do |table_name|
108
- connection.truncate_table table_name
114
+ tables_to_truncate(connection).each do |table_name|
115
+ yield connection, table_name
109
116
  end
110
117
  end
111
118
  end
112
119
 
113
120
  private
114
121
 
115
- def tables_to_truncate
122
+ def tables_to_truncate(connection)
116
123
  (@only || connection.tables) - @tables_to_exclude - connection.views
117
124
  end
118
125
 
119
- def connection
120
- #::ActiveRecord::Base.connection
121
- connection_klass.connection
122
- end
123
-
124
126
  # overwritten
125
127
  def migration_storage_name
126
128
  'schema_migrations'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_cleaner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
4
+ hash: 5547382
5
+ prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 6
10
- version: 0.6.6
9
+ - 7
10
+ - RC
11
+ version: 0.6.7.RC
11
12
  platform: ruby
12
13
  authors:
13
14
  - Ben Mabey
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-03-16 00:00:00 -06:00
19
+ date: 2011-03-24 00:00:00 -06:00
19
20
  default_executable:
20
21
  dependencies: []
21
22