cerbero 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Cerbero
2
2
 
3
- Uniqueness validation do not guarantee uniqueness. Only the database
3
+ Uniqueness validation does not guarantee uniqueness. Only the database
4
4
  constraints do this. But there is a flaw - when database constraints
5
5
  fail, an exception is thrown, and even when we catch it, the validation
6
6
  error is not set.
@@ -36,6 +36,11 @@ and in your migration:
36
36
  add_index :users, [:email, :company_id], unique: true
37
37
  ```
38
38
 
39
+ __Important:__ you should add both validation and db constraint. If you
40
+ don't supply validation, you'll have `save` returning `false`, yet no
41
+ validation errors will be displayed, which is a strange and obscure
42
+ behavior.
43
+
39
44
  Then if the gem is required, it makes the stuff work so that when the
40
45
  uniqueness validtion lets you in, but the database constraint then
41
46
  fails, `save` returns `false`, then uniqueness validation is re-run and
@@ -53,6 +58,10 @@ provide some code:
53
58
  4. Push to the branch (`git push origin my-new-feature`)
54
59
  5. Create new Pull Request
55
60
 
61
+ ## Contributors
62
+
63
+ * [Andry Conchin](https://github.com/andrykonchin)
64
+
56
65
  ## TODO:
57
66
 
58
67
  - Apply a cleaner pattern to test via multiple databases.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/dak/projects/cerbero
3
3
  specs:
4
- cerbero (0.0.1)
4
+ cerbero (0.0.2)
5
5
  activerecord (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/dak/projects/cerbero
3
3
  specs:
4
- cerbero (0.0.1)
4
+ cerbero (0.0.2)
5
5
  activerecord (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/dak/projects/cerbero
3
3
  specs:
4
- cerbero (0.0.1)
4
+ cerbero (0.0.2)
5
5
  activerecord (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,9 +1,9 @@
1
1
  require "cerbero/version"
2
2
 
3
3
  class ActiveRecord::Base
4
- def save
4
+ def save(*args)
5
5
  super
6
- rescue ActiveRecord::RecordNotUnique, ActiveRecord::StatementInvalid
6
+ rescue ActiveRecord::StatementInvalid
7
7
  valid?
8
8
  false
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Cerbero
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -18,7 +18,7 @@ describe 'cerbero' do
18
18
  user.errors[:email].should_not be_blank
19
19
  end
20
20
 
21
- it 'gives validation error when database constraint throws error' do
21
+ it 'is not pokemon exception handling' do
22
22
  User.create! :email => 'test@mailinator.com', :company_id => 25
23
23
 
24
24
  stub_uniqueness_validation!
@@ -26,4 +26,11 @@ describe 'cerbero' do
26
26
  UserWithSaveError.create :email => 'test@mailinator.com', :company_id => 25
27
27
  }.should raise_error(RuntimeError)
28
28
  end
29
+
30
+ it 'supports saving with options' do
31
+ lambda {
32
+ user = User.new :email => 'test@mailinator.com', :company_id => 25
33
+ user.save(:validation => true)
34
+ }.should_not raise_error
35
+ end
29
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cerbero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: -2835968287369647992
138
+ hash: -738609250160776711
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: -2835968287369647992
147
+ hash: -738609250160776711
148
148
  requirements: []
149
149
  rubyforge_project:
150
150
  rubygems_version: 1.8.23