rescue_unique_constraint 1.3.0 → 1.4.0

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
  SHA1:
3
- metadata.gz: 55de7ae1c3d780eaedf246b1f67e7cf6fd9b6f64
4
- data.tar.gz: d35de4f38f093f526e8a3b11497103fdad7fd93e
3
+ metadata.gz: ea30803708b58175b2ea038bb6ebcb03b69d8db9
4
+ data.tar.gz: e28a19b92f52f1a71ec80e21b9a5f2ef5ca02e91
5
5
  SHA512:
6
- metadata.gz: 2954275c9aefff4a96de130fe19f43cfa05bfef820646325884df732223f6a02c0ac71e5cd80f460cf00f8a37af5fded59c80ba7ad666f440288db4edddf00ca
7
- data.tar.gz: d9f7dbe85c99b9282968f334bab83277b7c49ffc52060211743915242c527b8545089a1e5c3ed8af6fde36bf2825da4de47a0476d68584fcfc96da6f0bf4d4bc
6
+ metadata.gz: e0d875de50c7fe791881a78812d1c3bd6521ecf0b794acf3dc16ba067b5229a6f0648f96c1ebfcfebe5077e8b565be414ef95e592cfe126a7c51e6b1b51ca6a0
7
+ data.tar.gz: 4e8118681c357af946e7fc0cae167a96e4e90d2faaa46ec285bdc45078dfb5a990d77580ffd77bace0570f8b8465cc96773b050e709b80363a680d4e06771604
data/README.md CHANGED
@@ -30,22 +30,26 @@ Or install it yourself as:
30
30
 
31
31
  Assuming you've added unique index:
32
32
 
33
- class AddIndexToThing < ActiveRecord::Migration
34
- disable_ddl_transaction!
33
+ ```ruby
34
+ class AddIndexToThing < ActiveRecord::Migration
35
+ disable_ddl_transaction!
35
36
 
36
- def change
37
- add_index :things, :somefield, unique: true, algorithm: :concurrently, name: "my_unique_index"
38
- end
39
- end
37
+ def change
38
+ add_index :things, :somefield, unique: true, algorithm: :concurrently, name: "my_unique_index"
39
+ end
40
+ end
41
+ ```
40
42
 
41
43
  Before:
42
44
 
43
- class Thing < ActiveRecord::Base
44
- end
45
+ ```ruby
46
+ class Thing < ActiveRecord::Base
47
+ end
45
48
 
46
- thing = Thing.create(somefield: "foo")
47
- dupe = Thing.create(somefield: "foo")
48
- => raises ActiveRecord::RecordNotUnique
49
+ thing = Thing.create(somefield: "foo")
50
+ dupe = Thing.create(somefield: "foo")
51
+ # => raises ActiveRecord::RecordNotUnique
52
+ ```
49
53
 
50
54
  Note that if you have `validates :uniqueness` in your model, it will prevent
51
55
  the RecordNotUnique from being raised in _some_ cases, but not all, as race
@@ -54,25 +58,28 @@ enter your database.
54
58
 
55
59
  After:
56
60
 
57
- class Thing < ActiveRecord::Base
58
- include RescueUniqueConstraint
59
- rescue_unique_constraint index: "my_unique_index", field: "somefield"
60
- end
61
+ ```ruby
62
+ class Thing < ActiveRecord::Base
63
+ include RescueUniqueConstraint
64
+ rescue_unique_constraint index: "my_unique_index", field: "somefield"
65
+ end
61
66
 
62
- thing = Thing.create(somefield: "foo")
63
- dupe = Thing.create(somefield: "foo")
64
- => false
65
- thing.errors[:somefield] == "somefield has already been taken"
66
- => true
67
+ thing = Thing.create(somefield: "foo")
68
+ dupe = Thing.create(somefield: "foo")
69
+ # => false
70
+ thing.errors[:somefield] == "somefield has already been taken"
71
+ # => true
72
+ # => raises ActiveRecord::RecordNotUnique
73
+ ```
67
74
 
68
75
  ## Testing
69
76
 
70
77
  You'll need a database that supports unique constraints.
71
- This gem has been tested with PostgreSQL and SQLite only.
78
+ This gem has been tested with PostgreSQL, MySQL and SQLite.
72
79
 
73
80
  ## Contributing
74
81
 
75
- 1. Fork it ( https://github.com/[my-github-username]/rescue_unique_constraint/fork )
82
+ 1. [Fork it](https://github.com/reverbdotcom/rescue-unique-constraint/fork)
76
83
  2. Create your feature branch (`git checkout -b my-new-feature`)
77
84
  3. Commit your changes (`git commit -am 'Add some feature'`)
78
85
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ begin
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
8
+ rescue LoadError
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RescueUniqueConstraint
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activerecord", ">= 4.1", "< 6"
21
+ spec.add_dependency "activerecord", ">= 3.2", "< 6"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake", "~> 10.5"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rescue_unique_constraint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tam Dang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-22 00:00:00.000000000 Z
12
+ date: 2018-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,7 +17,7 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.1'
20
+ version: '3.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '6'
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '4.1'
30
+ version: '3.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '6'