database_cleaner 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,26 @@
1
+ == 1.1.0 2013-08-01
2
+
3
+ === New Features/Changes
4
+
5
+ * schema_migrations table name is now retrieved from ActiveRecord (Kyle Stevens)
6
+ * Autoloading logic is now exposed, see PR #212 for details (Jeff Felchner)
7
+
8
+ === Bug Fixes
9
+
10
+ * Deletion strategy works again on MySQL, had to roll back multiple statements patch.
11
+ * Fix MySqlAdapter superclass bug via class_eval loading of superclasses (Tom Meier)
12
+ * Sequel strategy fix dealing with symbol/string mismatch on table names. (Fred Wu)
13
+
1
14
  == 1.0.1 2013-05-13
2
15
 
3
16
  * Patch release to fix broken gemspec file. Sorry folks!
4
17
 
5
18
  == 1.0.0 2013-05-13
6
19
 
7
- === New Features/Changes
20
+ === New Features/Changes
8
21
 
9
22
  * Dropping support for Ruby 1.8.x; Only 1.9.x and beyond will be supported going forward.
10
- * Now supporting (and testing against ruby 2.0.x).
23
+ * Now supporting and testing against ruby 2.0.x.
11
24
  * Adds support for AR 4.0 by using `begin_transaction` (David Chelimsky and Steve Madsen)
12
25
  * Adds Rails 4 support for SQLite3Adapter
13
26
  * Suppport for Moped when used without Mongoid (Cyprian Kowalczyk)
@@ -16,7 +29,8 @@
16
29
  * CI Improvements (Jan Vlnas, Murahashi Sanemat Kenichi, Samer Masry, Jordan Hollinger)
17
30
  * README/Documentation improvements (Marcelo Cajueiro, Donald Ball, TJ Chambers, Nick Huanca, Justin Edwards, Ryota Arai)
18
31
 
19
- === Bug Fixes
32
+ === Bug Fixes
33
+
20
34
  * Fixes transaction errors when using `after_commit` hooks in AR.
21
35
  * Fixes truncation error with SQLite (Daniel White)
22
36
  * Fixes `pre_count` logic in AR Postgres. (Jordan Hollinger)
@@ -24,9 +38,11 @@
24
38
  * #clean_with now works with multiple connections. (John Ferlito)
25
39
  * Always start a AR transaction to prevent nil errors in AR when rolling back (John Hampton, M.Shibuya)
26
40
 
27
- == 0.9.1 2012-10-11 (0.9.0 was released first but was yanked due to bad gemspec)
41
+ == 0.9.1 2012-10-11
28
42
 
29
- === New Features
43
+ (0.9.0 was released first but was yanked due to bad gemspec)
44
+
45
+ === New Features
30
46
 
31
47
  * New options for AR :truncation for speed. See README for details. (Stanislaw Pankevich)
32
48
  * view caching works with the schema_plus gem loaded
@@ -37,7 +53,8 @@
37
53
  * Add Sequel support for multiple migration storage names in #148 (Jack Chu)
38
54
  * Multiple database support for Mongoid 3 #149 (Luke Francl)
39
55
 
40
- === Bug Fixes
56
+ === Bug Fixes
57
+
41
58
  * :deletion for AR Postgres in JRuby now works #140 (Heiko Seebach)
42
59
  * Rescue LoadError when AR adapters not available. #145 (Garrow Bedrossian)
43
60
  * Fixes DatabaseCleaner::[] to cache cleaners.
@@ -57,9 +74,9 @@
57
74
 
58
75
  == 0.7.1 2012-01-15
59
76
 
60
- === New Features
77
+ === New Features
61
78
 
62
- * Support for Rails 3.2. (David Demaree)
79
+ * Support for Rails 3.2. (David Demaree)
63
80
 
64
81
  === Bugfixes
65
82
 
@@ -72,61 +89,69 @@
72
89
 
73
90
  == 0.7.0 2011-11-12
74
91
 
75
- === New Features
92
+ === New Features
76
93
 
77
- * Sequel Support (Corin Langosch)
78
- * Updates DataMapper strategies to work with DataMapper 1.1 (Xavier Shay and Anthony Williams)
79
- * for AR and PSQL, truncate all tables with one command, improving performance due to avoiding cascades (Leonid Shevtsov)
94
+ * Sequel Support (Corin Langosch)
95
+ * Updates DataMapper strategies to work with DataMapper 1.1 (Xavier Shay and Anthony Williams)
96
+ * for AR and PSQL, truncate all tables with one command, improving performance due to avoiding cascades (Leonid Shevtsov)
80
97
 
81
98
  === Bugfixes
82
99
 
83
100
  * Avoids trying to load the ':default' ActiveRecord config. #72 (Ben Mabey)
84
101
 
85
-
86
102
  == 0.6.7 2011-04-21
87
103
 
88
104
  === Bugfixes
89
- * Explicity require ERB. (Vít Ondruch)
90
- * Cache DB connections, fixes referential integrity bug when using multiple DBs. (John Ferlito)
105
+
106
+ * Explicity require ERB. (Vít Ondruch)
107
+ * Cache DB connections, fixes referential integrity bug when using multiple DBs. (John Ferlito)
91
108
 
92
109
  == 0.6.6 2011-03-16
93
110
 
94
111
  === Bugfixes
95
- * Don't modify the array passed in with the :except key. (Eric Wollesen)
96
- * Fixes version checking for postgresql. (Greg Barnett)
112
+
113
+ * Don't modify the array passed in with the :except key. (Eric Wollesen)
114
+ * Fixes version checking for postgresql. (Greg Barnett)
97
115
 
98
116
  == 0.6.5 2011-03-08
99
117
 
100
118
  === Bugfixes
101
- * When truncating in postgresql (>= 8.4) sequences are now reset. (Greg Barnett)
102
- * Fixes the MongoDB truncation so non system collections starting with 'system' are not excluded for truncation. (Dmitry Naumov)
119
+
120
+ * When truncating in postgresql (>= 8.4) sequences are now reset. (Greg Barnett)
121
+ * Fixes the MongoDB truncation so non system collections starting with 'system' are not excluded for truncation. (Dmitry Naumov)
103
122
 
104
123
  == 0.6.4 2011-02-21
105
124
 
106
125
  === Bugfixes
107
- * Avoids trying to drop views in Postgres. (Bernerd Schaefer)
126
+
127
+ * Avoids trying to drop views in Postgres. (Bernerd Schaefer)
108
128
 
109
129
  == 0.6.3 2011-02-09
110
130
 
111
- === New Features
131
+ === New Features
132
+
112
133
  * Configurable logger to aid in debugging database cleaner. (Marty Haught)
113
134
 
114
135
  == 0.6.2 2011-02-04
115
136
 
116
- === New Features
137
+ === New Features
138
+
117
139
  * Support IBM_DB Adapter for table truncation. This is for DB2 >= 9.7 (GH-39 Samer Abukhait)
118
140
 
119
- === Bugfixes
141
+ === Bugfixes
142
+
120
143
  * Reversed GH-41 after larger community discussion. Mongo indexes are no longer dropped. (Ben Mabey)
121
144
  * Truncation strategy works on SqlServer tables with FKs. (GH-33, Hugo Freire)
122
145
 
123
146
  == 0.6.1 2011-01-27
124
147
 
125
- === New Features
148
+ === New Features
149
+
126
150
  * Default strategies for all ORM libs are defined. (GH-36, GH-38 Prem Sichanugrist)
127
151
  * Add a NullStrategy. (GH-6 Ben Mabey)
128
152
 
129
- === Bugfixes
153
+ === Bugfixes
154
+
130
155
  * Mongo colletion indexes are dropped for collections being removed. (GH-41 Ben Mabey)
131
156
  * Exclude database views from tables_to_truncate, if the connection adapter
132
157
  supports reading from the ANSI standard information_schema views. (GH-25 Samer Abukhait)
@@ -147,14 +172,16 @@ is backwards compatible.
147
172
  This release is a result of Jon Rowe's hard work. Many thanks to Jon for all
148
173
  of the hours and effort he put into making this feature request a reality.
149
174
 
150
- === New Features
175
+ === New Features
176
+
151
177
  * Ability to clean multiple database connections managed by the same ORM. (Jon Rowe)
152
178
  * Ability to clean multiple DBs managed by different ORMs in same project. (Jon Rowe)
153
179
  * Allows for the ActiveRecord config file (database.yml) to contain ERB and process it. (Fletcher Nichol)
154
180
  * Mysql2Adapter support. (Kamal Fariz Mahyuddin and John Ferlito)
155
181
  * Deletion strategy for ActiveRecord (Mikl Kurkov)
156
182
 
157
- === Bugfixes
183
+ === Bugfixes
184
+
158
185
  * Updates the DataMapper truncation strategy to version 0.10.3. (Robert Rouse)
159
186
  * Addresses Ruby 1.9 and 1.8 differences causing a bug in the AR PostgreSQLAdapter truncation strategy. (GH-14, James B. Byrne)
160
187
  * Fixes syntax error that MySQL was throwing during DataMapper truncation. (Blake Gentry)
@@ -163,7 +190,8 @@ of the hours and effort he put into making this feature request a reality.
163
190
 
164
191
  == 0.5.2
165
192
 
166
- === Bugfixes
193
+ === Bugfixes
194
+
167
195
  * Removes extraneous puts call from configuration.rb. (Ben Mabey)
168
196
 
169
197
  == 0.5.1 - The Mongoid Release
@@ -172,85 +200,108 @@ This release also attempts to fix AR for Rails 3 support. I have seen mixed rev
172
200
  claim the fixes allow for use in Rails3 while others have not had good luck with it. I plan on reworking
173
201
  the way AR support is added so that it is more friendly with how Rails 3 uses autoload.
174
202
 
175
- === New features
203
+ === New features
204
+
176
205
  * Clean and clean_with methods are now aliased to clean! and clean_with!. (Ben Mabey)
177
206
  * Mongoid Support! (Sidney Burks)
178
207
 
179
208
  === Bugfixes
209
+
180
210
  * Check PostgreSQL version >= 8.2 before using TRUNCATE CASCADE (James B. Byrne)
181
211
  * Correct superclass is used in ActiveRecord connection adapters. (johnathan, Aslak Hellesoy, Ben Mabey)
182
212
 
183
213
  == 0.5.0 2010-02-22 - The CouchPotato Release
184
214
 
185
- === New features
215
+ === New features
216
+
186
217
  * Basic truncation support for CouchPotato / CouchDB. (Martin Rehfeld)
187
218
  * SQLite3 on JRuby will fall back to delete if truncate doesn't work. (Darrin Holst)
188
219
  * JDBC is used for ActiveRecord automaticaly when JRuby is detected. (Darrin Holst)
189
220
 
190
- === Bufixes
221
+ === Bufixes
222
+
191
223
  * MongoMapper truncation strategy now works with :only and :except options. (Ben Mabey)
192
224
 
193
225
  == 0.4.3 2010-01-17
194
226
 
195
- === New features
227
+ === New features
228
+
196
229
  * Truncation for ActiveRecord oracle_enhanced adapter. (Edgars Beigarts)
197
230
 
198
231
  == 0.4.2 2010-01-12
199
232
 
200
- === Bufixes
233
+ === Bufixes
234
+
201
235
  * Datamapper truncation now uses 'select' instead of deprecated the 'query' method. (Steve Tooke)
202
236
 
203
237
  == 0.4.1 2010-01-07
204
238
 
205
- === Bufixes
239
+ === Bufixes
240
+
206
241
  * Postgres tables with FKs now truncate (added TRUNCADE CASCADE) using Datamapper. (Ben Mabey)
207
242
 
208
243
  == 0.4.0 2009-12-23 (The MongoMapper Edition)
209
244
 
210
- === New features
245
+ === New features
246
+
211
247
  * MongoMapper support for the truncation strategy. (Aubrey Holland)
212
248
 
213
249
  == 0.3.0 2009-12-20
214
250
 
215
- === New features
251
+ === New features
252
+
216
253
  * DataMapper 0.10.0 Compatible. (Martin Gamsjaeger)
217
- === Bufixes
254
+
255
+ === Bufixes
256
+
218
257
  * Postgres tables with FKs now truncate (added TRUNCADE CASCADE). (Vika - yozhyk on github)
219
258
 
220
259
  == 0.2.3 2009-05-30
221
260
 
222
- === New features
261
+ === New features
262
+
223
263
  * Support for SQL Server truncation (Adam Meehan)
224
264
 
225
265
  == 0.2.2 2009-05-08
226
- === Bufixes
266
+
267
+ === Bufixes
268
+
227
269
  * Added proper gemspec description and summary. (Ben Mabey, thanks to Martin Gamsjaeger)
228
270
 
229
- === New features
271
+ === New features
230
272
 
231
273
  == 0.2.1 2009-05-08
232
- === Bufixes
274
+
275
+ === Bufixes
276
+
233
277
  * Removed extraneous TruncationBase class definition. (Ben Mabey)
234
278
 
235
279
  == 0.2.0 2009-05-08 - The Datamapper Release
236
280
 
237
- === New features
281
+ === New features
282
+
238
283
  * DataMapper strategies (Martin Gamsjaeger)
239
284
  * Transaction
240
285
  * Truncation - working SQLite3, MySQL adapters. Experimental Postgres adapter (not tested).
241
286
 
242
287
  == 0.1.3 2009-04-30
243
288
 
244
- === New features
289
+ === New features
290
+
245
291
  * PostgresSQLAdapter for AR to support the truncation strategy. (Alberto Perdomo)
246
- === Bufixes
292
+
293
+ === Bufixes
294
+
247
295
  * Added missing quotes around table names in truncation calls. (Michael MacDonald)
248
296
 
249
297
  == 0.1.2 2009-03-05
250
- === New features
298
+
299
+ === New features
300
+
251
301
  * JDBC Adapter to enable AR truncation strategy to work. (Kamal Fariz Mahyuddin)
252
302
 
253
303
  == 0.1.1 2009-03-04 - Initial Release (Ben Mabey)
304
+
254
305
  * Basic infrastructure
255
306
  * Features, RSpec code examples
256
307
  * ActiveRecord strategies
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :minor: 0
2
+ :minor: 1
3
3
  :build:
4
- :patch: 1
4
+ :patch: 0
5
5
  :major: 1
@@ -1,3 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
2
2
  require 'database_cleaner/configuration'
3
3
 
4
+ module DatabaseCleaner
5
+ def self.can_detect_orm?
6
+ DatabaseCleaner::Base.autodetect_orm
7
+ end
8
+ end
@@ -3,6 +3,51 @@ require 'active_record/connection_adapters/abstract_adapter'
3
3
  require "database_cleaner/generic/truncation"
4
4
  require 'database_cleaner/active_record/base'
5
5
  require 'database_cleaner/active_record/truncation'
6
+ # This file may seem to have duplication with that of truncation, but by keeping them separate
7
+ # we avoiding loading this code when it is not being used (which is the common case).
8
+
9
+ module ActiveRecord
10
+ module ConnectionAdapters
11
+
12
+ class MysqlAdapter < MYSQL_ADAPTER_PARENT
13
+ def delete_table(table_name)
14
+ execute("DELETE FROM #{quote_table_name(table_name)};")
15
+ end
16
+ end
17
+
18
+ class Mysql2Adapter < MYSQL2_ADAPTER_PARENT
19
+ def delete_table(table_name)
20
+ execute("DELETE FROM #{quote_table_name(table_name)};")
21
+ end
22
+ end
23
+
24
+ class JdbcAdapter < AbstractAdapter
25
+ def delete_table(table_name)
26
+ execute("DELETE FROM #{quote_table_name(table_name)};")
27
+ end
28
+ end
29
+
30
+ class PostgreSQLAdapter < POSTGRE_ADAPTER_PARENT
31
+ def delete_table(table_name)
32
+ execute("DELETE FROM #{quote_table_name(table_name)};")
33
+ end
34
+ end
35
+
36
+ class SQLServerAdapter < AbstractAdapter
37
+ def delete_table(table_name)
38
+ execute("DELETE FROM #{quote_table_name(table_name)};")
39
+ end
40
+ end
41
+
42
+ class OracleEnhancedAdapter < AbstractAdapter
43
+ def delete_table(table_name)
44
+ execute("DELETE FROM #{quote_table_name(table_name)}")
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+
6
51
 
7
52
  module DatabaseCleaner::ActiveRecord
8
53
  class Deletion < Truncation
@@ -10,11 +55,9 @@ module DatabaseCleaner::ActiveRecord
10
55
  def clean
11
56
  connection = connection_class.connection
12
57
  connection.disable_referential_integrity do
13
- sql = tables_to_truncate(connection).map do |table_name|
14
- "DELETE FROM #{connection.quote_table_name(table_name)}"
15
- end.join(";")
16
-
17
- connection.execute sql
58
+ tables_to_truncate(connection).each do |table_name|
59
+ connection.delete_table table_name
60
+ end
18
61
  end
19
62
  end
20
63
 
@@ -176,56 +176,39 @@ module ActiveRecord
176
176
  module ConnectionAdapters
177
177
  # Activerecord-jdbc-adapter defines class dependencies a bit differently - if it is present, confirm to ArJdbc hierarchy to avoid 'superclass mismatch' errors.
178
178
  USE_ARJDBC_WORKAROUND = defined?(ArJdbc)
179
+ # ActiveRecord 3.1+ support
180
+ MYSQL_ABSTRACT_ADAPTER = defined?(AbstractMysqlAdapter) ? AbstractMysqlAdapter : AbstractAdapter
179
181
 
180
- class AbstractAdapter
181
- include ::DatabaseCleaner::ActiveRecord::AbstractAdapter
182
- end
183
-
184
- unless USE_ARJDBC_WORKAROUND
185
- class SQLiteAdapter < AbstractAdapter
186
- end
187
- end
182
+ AbstractAdapter.send(:include, ::DatabaseCleaner::ActiveRecord::AbstractAdapter)
188
183
 
189
- # ActiveRecord 3.1 support
190
- if defined?(AbstractMysqlAdapter)
191
- MYSQL_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractMysqlAdapter
192
- MYSQL2_ADAPTER_PARENT = AbstractMysqlAdapter
184
+ if USE_ARJDBC_WORKAROUND
185
+ MYSQL_ADAPTER_PARENT = JdbcAdapter
193
186
  else
194
- MYSQL_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractAdapter
195
- MYSQL2_ADAPTER_PARENT = AbstractAdapter
187
+ MYSQL_ADAPTER_PARENT = MYSQL_ABSTRACT_ADAPTER
188
+ class SQLiteAdapter < AbstractAdapter; end
196
189
  end
190
+ MYSQL2_ADAPTER_PARENT = MYSQL_ABSTRACT_ADAPTER
197
191
 
198
192
  if defined?(SQLite3Adapter) && SQLite3Adapter.superclass == ActiveRecord::ConnectionAdapters::AbstractAdapter
199
193
  SQLITE_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractAdapter
200
194
  else
201
195
  SQLITE_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : SQLiteAdapter
202
196
  end
203
- POSTGRE_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractAdapter
204
-
205
- class MysqlAdapter < MYSQL_ADAPTER_PARENT
206
- include ::DatabaseCleaner::ActiveRecord::MysqlAdapter
207
- end
197
+ POSTGRES_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractAdapter
208
198
 
209
- class Mysql2Adapter < MYSQL2_ADAPTER_PARENT
210
- include ::DatabaseCleaner::ActiveRecord::MysqlAdapter
211
- end
199
+ MYSQL_ADAPTER_PARENT.class_eval { include ::DatabaseCleaner::ActiveRecord::MysqlAdapter }
200
+ MYSQL2_ADAPTER_PARENT.class_eval { include ::DatabaseCleaner::ActiveRecord::MysqlAdapter }
201
+ SQLITE_ADAPTER_PARENT.class_eval { include ::DatabaseCleaner::ActiveRecord::SQLiteAdapter }
202
+ POSTGRES_ADAPTER_PARENT.class_eval { include ::DatabaseCleaner::ActiveRecord::PostgreSQLAdapter }
212
203
 
213
204
  class IBM_DBAdapter < AbstractAdapter
214
205
  include ::DatabaseCleaner::ActiveRecord::IBM_DBAdapter
215
206
  end
216
207
 
217
- class SQLite3Adapter < SQLITE_ADAPTER_PARENT
218
- include ::DatabaseCleaner::ActiveRecord::SQLiteAdapter
219
- end
220
-
221
208
  class JdbcAdapter < AbstractAdapter
222
209
  include ::DatabaseCleaner::ActiveRecord::TruncateOrDelete
223
210
  end
224
211
 
225
- class PostgreSQLAdapter < POSTGRE_ADAPTER_PARENT
226
- include ::DatabaseCleaner::ActiveRecord::PostgreSQLAdapter
227
- end
228
-
229
212
  class SQLServerAdapter < AbstractAdapter
230
213
  include ::DatabaseCleaner::ActiveRecord::TruncateOrDelete
231
214
  end
@@ -233,7 +216,6 @@ module ActiveRecord
233
216
  class OracleEnhancedAdapter < AbstractAdapter
234
217
  include ::DatabaseCleaner::ActiveRecord::OracleEnhancedAdapter
235
218
  end
236
-
237
219
  end
238
220
  end
239
221
 
@@ -262,7 +244,7 @@ module DatabaseCleaner::ActiveRecord
262
244
 
263
245
  # overwritten
264
246
  def migration_storage_names
265
- %w[schema_migrations]
247
+ [::ActiveRecord::Migrator.schema_migrations_table_name]
266
248
  end
267
249
 
268
250
  def pre_count?
@@ -1,7 +1,6 @@
1
1
  require 'database_cleaner/null_strategy'
2
2
  module DatabaseCleaner
3
3
  class Base
4
-
5
4
  def initialize(desired_orm = nil,opts = {})
6
5
  if [:autodetect, nil, "autodetect"].include?(desired_orm)
7
6
  autodetect
@@ -98,6 +97,28 @@ module DatabaseCleaner
98
97
  self.orm == other.orm && self.db == other.db
99
98
  end
100
99
 
100
+ def autodetect_orm
101
+ if defined? ::ActiveRecord
102
+ :active_record
103
+ elsif defined? ::DataMapper
104
+ :data_mapper
105
+ elsif defined? ::MongoMapper
106
+ :mongo_mapper
107
+ elsif defined? ::Mongoid
108
+ :mongoid
109
+ elsif defined? ::CouchPotato
110
+ :couch_potato
111
+ elsif defined? ::Sequel
112
+ :sequel
113
+ elsif defined? ::Moped
114
+ :moped
115
+ elsif defined? ::Ohm
116
+ :ohm
117
+ elsif defined? ::Redis
118
+ :redis
119
+ end
120
+ end
121
+
101
122
  private
102
123
 
103
124
  def orm_module
@@ -116,30 +137,10 @@ module DatabaseCleaner
116
137
  end
117
138
 
118
139
  def autodetect
119
- @orm ||= begin
120
- @autodetected = true
121
- if defined? ::ActiveRecord
122
- :active_record
123
- elsif defined? ::DataMapper
124
- :data_mapper
125
- elsif defined? ::MongoMapper
126
- :mongo_mapper
127
- elsif defined? ::Mongoid
128
- :mongoid
129
- elsif defined? ::CouchPotato
130
- :couch_potato
131
- elsif defined? ::Sequel
132
- :sequel
133
- elsif defined? ::Moped
134
- :moped
135
- elsif defined? ::Ohm
136
- :ohm
137
- elsif defined? ::Redis
138
- :redis
139
- else
140
- raise NoORMDetected, "No known ORM was detected! Is ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, Moped, or CouchPotato, Redis or Ohm loaded?"
141
- end
142
- end
140
+ @autodetected = true
141
+
142
+ @orm ||= autodetect_orm ||
143
+ raise(NoORMDetected, "No known ORM was detected! Is ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, Moped, or CouchPotato, Redis or Ohm loaded?")
143
144
  end
144
145
 
145
146
  def set_default_orm_strategy
@@ -28,7 +28,7 @@ module DatabaseCleaner
28
28
 
29
29
  def each_table
30
30
  tables_to_truncate(db).each do |table|
31
- yield db, table
31
+ yield db, table.to_sym
32
32
  end
33
33
  end
34
34
 
@@ -1,5 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
  require 'active_record'
3
+ require 'active_record/connection_adapters/mysql_adapter'
4
+ require 'active_record/connection_adapters/mysql2_adapter'
5
+ require 'active_record/connection_adapters/sqlite3_adapter'
6
+ require 'active_record/connection_adapters/postgresql_adapter'
3
7
 
4
8
  require 'database_cleaner/active_record/truncation'
5
9
 
@@ -35,6 +39,16 @@ module DatabaseCleaner
35
39
  Truncation.new.clean
36
40
  end
37
41
 
42
+ it "should use ActiveRecord's schema_migrations_table_name" do
43
+ connection.stub!(:database_cleaner_table_cache).and_return(%w[pre_schema_migrations_suf widgets dogs])
44
+ ::ActiveRecord::Base.stub!(:table_name_prefix).and_return('pre_')
45
+ ::ActiveRecord::Base.stub!(:table_name_suffix).and_return('_suf')
46
+
47
+ connection.should_receive(:truncate_tables).with(['widgets', 'dogs'])
48
+
49
+ Truncation.new.clean
50
+ end
51
+
38
52
  it "should only truncate the tables specified in the :only option when provided" do
39
53
  connection.stub!(:database_cleaner_table_cache).and_return(%w[schema_migrations widgets dogs])
40
54
 
@@ -119,14 +133,14 @@ module DatabaseCleaner
119
133
  subject.send(:pre_count?).should == false
120
134
  end
121
135
  end
122
-
136
+
123
137
  describe '#reset_ids?' do
124
138
  before(:each) do
125
139
  connection.stub!(:disable_referential_integrity).and_yield
126
140
  connection.stub!(:database_cleaner_view_cache).and_return([])
127
141
  ::ActiveRecord::Base.stub!(:connection).and_return(connection)
128
142
  end
129
-
143
+
130
144
  subject { Truncation.new }
131
145
  its(:reset_ids?) { should == true }
132
146
 
@@ -1,6 +1,7 @@
1
1
  require 'support/active_record/database_setup'
2
2
  require 'support/active_record/schema_setup'
3
3
 
4
+
4
5
  module MySQL2Helper
5
6
  puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql2"
6
7
 
@@ -36,3 +37,4 @@ end
36
37
  RSpec.configure do |c|
37
38
  c.include MySQL2Helper
38
39
  end
40
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Strategies for cleaning databases. Can be used to ensure a clean state
15
15
  for testing.
@@ -22,7 +22,7 @@ extra_rdoc_files:
22
22
  - TODO
23
23
  files:
24
24
  - Gemfile.lock
25
- - History.txt
25
+ - History.rdoc
26
26
  - README.markdown
27
27
  - Rakefile
28
28
  - VERSION.yml
@@ -130,7 +130,8 @@ files:
130
130
  - LICENSE
131
131
  - TODO
132
132
  homepage: http://github.com/bmabey/database_cleaner
133
- licenses: []
133
+ licenses:
134
+ - MIT
134
135
  post_install_message:
135
136
  rdoc_options: []
136
137
  require_paths: