database_flusher 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90cac9582ff73ebe0151abb8ea901bdae8280dc4
|
4
|
+
data.tar.gz: 99ebfe15fbf6de3c1ac4d479f7bda06ec6c89995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b30f3618eff2f27ecb506c79ee2d80df941ac008ddbbed8c505f82b6df9bd31344ef6cecaa9534987450b49c7e80f2390b815dbb910ba56f2b256f7e9c9d56c
|
7
|
+
data.tar.gz: a5b2ce6762f219a3172c4db6eb229a2a1a0ee5344b9956690ebbc6bda4e41fa9152c9adc4a76bdd1ec28dc1e01b26ff4572a5106c811a430e5c5b9ef0ecc5635
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ database_flusher is a tiny and fast database cleaner inspired by [database_clean
|
|
7
7
|
|
8
8
|
## Features
|
9
9
|
|
10
|
-
* No monkey patching - uses `ActiveSupport::Notifications` and `Mongo::Monitoring
|
10
|
+
* No monkey patching - uses `ActiveSupport::Notifications` and `Mongo::Monitoring` to catch `INSERT` statements
|
11
11
|
* Fast `:deletion` strategy that cleans only tables/collections where `INSERT` statements were performed
|
12
12
|
* Faster `disable_referential_integrity` for PostgreSQL
|
13
13
|
* Executes multiple `DELETE` statements as one query with ActiveRecord
|
@@ -105,17 +105,14 @@ end
|
|
105
105
|
DatabaseFlusher[:active_record].strategy = :transaction
|
106
106
|
DatabaseFlusher[:mongoid].strategy = :deletion
|
107
107
|
|
108
|
-
|
108
|
+
# Use Around hook to make sure it runs after capybara session reset.
|
109
|
+
Around do |scenario, block|
|
109
110
|
if Capybara.current_driver == :rack_test
|
110
111
|
DatabaseFlusher[:active_record].strategy = :transaction
|
111
112
|
else
|
112
113
|
DatabaseFlusher[:active_record].strategy = :deletion
|
113
114
|
end
|
114
|
-
DatabaseFlusher.
|
115
|
-
end
|
116
|
-
|
117
|
-
After do
|
118
|
-
DatabaseFlusher.clean
|
115
|
+
DatabaseFlusher.cleaning(&block)
|
119
116
|
end
|
120
117
|
```
|
121
118
|
|
data/lib/database_flusher.rb
CHANGED
@@ -5,18 +5,10 @@ module DatabaseFlusher
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def disable_referential_integrity(*tables)
|
8
|
-
|
9
|
-
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
10
|
-
rescue
|
11
|
-
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER USER" }.join(";"))
|
12
|
-
end
|
8
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
13
9
|
yield
|
14
10
|
ensure
|
15
|
-
|
16
|
-
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
17
|
-
rescue
|
18
|
-
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER USER" }.join(";"))
|
19
|
-
end
|
11
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
20
12
|
end
|
21
13
|
end
|
22
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_flusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgars Beigarts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|