noncommittal 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -2
- data/lib/noncommittal.rb +11 -2
- data/lib/noncommittal/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7557b627c1362e8ee9b04006e3c6d2e9663764fb4315714e600531f22907643
|
4
|
+
data.tar.gz: f7f88e955fdc0367083a8d6e403595ec4fc07302f06c8238e443c60c2de8491b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdcbc2d52e274631bb2a6df662745619247d5fcc6e590679c78772b13c39a1ee0fc4562b289ae783a5b0ff4b7e5849272771c2434bf481a7ea3b9d35086983da
|
7
|
+
data.tar.gz: 35390d884f70ce8c61fb207fd2ffbf21e1f2a97d21669cfebe524673de8cb43d5b611d35cc3eaac895566e09aab631cde3c300e140908f0ac5439b48734c0bed
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,8 +21,9 @@ Noncommittal.start!(tables: [:users, :posts])
|
|
21
21
|
```
|
22
22
|
|
23
23
|
This will create an empty table called `noncommittal_no_rows_allowed` and, for
|
24
|
-
|
25
|
-
prevent any records from being committed outside the test
|
24
|
+
every table in your database, a deferred foreign key constraint that will
|
25
|
+
effectively prevent any records from being committed outside the test
|
26
|
+
transaction.
|
26
27
|
|
27
28
|
## Do you have commitment issues?
|
28
29
|
|
@@ -73,6 +74,13 @@ like so:
|
|
73
74
|
Noncommittal.start!(tables: [:users, :posts])
|
74
75
|
```
|
75
76
|
|
77
|
+
If you simply want to exclude certain tables, you can set the `exclude_tables`
|
78
|
+
keyword argument:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Noncommittal.start!(exclude_tables: [:system_configurations])
|
82
|
+
```
|
83
|
+
|
76
84
|
## Limitations
|
77
85
|
|
78
86
|
This only works with Postgres currently. PRs welcome if you can accomplish the
|
data/lib/noncommittal.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
require "noncommittal/version"
|
2
2
|
|
3
3
|
module Noncommittal
|
4
|
-
def self.start!(tables: nil)
|
5
|
-
|
4
|
+
def self.start!(tables: nil, exclude_tables: [])
|
5
|
+
raise "noncommittal is only designed to be run in your test environment!" unless Rails.env.test?
|
6
|
+
|
7
|
+
tables ||= begin
|
8
|
+
ActiveRecord::Base.connection.select_values(
|
9
|
+
"select table_name from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE' and table_catalog = $1",
|
10
|
+
"SQL",
|
11
|
+
[ActiveRecord::Relation::QueryAttribute.new("table_name", ActiveRecord::Base.connection.current_database, ActiveRecord::Type::String.new)]
|
12
|
+
) - ["ar_internal_metadata", "schema_migrations"]
|
13
|
+
end
|
14
|
+
tables = tables.map(&:to_s) - exclude_tables.map(&:to_s)
|
6
15
|
|
7
16
|
ActiveRecord::Base.connection.execute <<~SQL
|
8
17
|
create table if not exists noncommittal_no_rows_allowed (id bigint unique);
|
data/lib/noncommittal/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noncommittal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
21
|
- ".travis.yml"
|
22
|
+
- CHANGELOG.md
|
22
23
|
- Gemfile
|
23
24
|
- Gemfile.lock
|
24
25
|
- LICENSE.txt
|