noncommittal 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '029ebe87976f291a4998cefd198ee1003f0fcca977072621851247164496d25b'
4
- data.tar.gz: 17cf95e7f5e844d8fe226154092575cc8ec85089c1fac25e2dd2531ceb99b496
3
+ metadata.gz: a7557b627c1362e8ee9b04006e3c6d2e9663764fb4315714e600531f22907643
4
+ data.tar.gz: f7f88e955fdc0367083a8d6e403595ec4fc07302f06c8238e443c60c2de8491b
5
5
  SHA512:
6
- metadata.gz: 183e8f4fcddcdf2673c72707df77d961b42a62002961d06dd2e8d6510e9cb7c27b47b30332bc0e5d23d33397f0e0b9cd7f87b44338e41e3649beb70c4fe95056
7
- data.tar.gz: 27343c72bb0e819f7f6801866347dacdeeafce9d61c0844158bafe2e1f34dc0360c618f86605974e0abe960356f92862500916af5f55a703015e3bbb10ba7bee
6
+ metadata.gz: cdcbc2d52e274631bb2a6df662745619247d5fcc6e590679c78772b13c39a1ee0fc4562b289ae783a5b0ff4b7e5849272771c2434bf481a7ea3b9d35086983da
7
+ data.tar.gz: 35390d884f70ce8c61fb207fd2ffbf21e1f2a97d21669cfebe524673de8cb43d5b611d35cc3eaac895566e09aab631cde3c300e140908f0ac5439b48734c0bed
@@ -0,0 +1,10 @@
1
+ ## 0.1.1
2
+
3
+ * Locks down all tables by querying postgres as opposed to looking for
4
+ descendants of `ActiveRecord::Base`
5
+ * Adds an `exclude_tables` option
6
+
7
+ ## 0.1.0
8
+
9
+ * Initial release
10
+
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- noncommittal (0.1.0)
4
+ noncommittal (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- each of your models, a deferred foreign key constraint that will effectively
25
- prevent any records from being committed outside the test transaction.
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
@@ -1,8 +1,17 @@
1
1
  require "noncommittal/version"
2
2
 
3
3
  module Noncommittal
4
- def self.start!(tables: nil)
5
- tables ||= ActiveRecord::Base.descendants.map(&:table_name).compact.uniq - ["ar_internal_metadata", "schema_migrations"]
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);
@@ -1,3 +1,3 @@
1
1
  module Noncommittal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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