cerbero 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -1
- data/gemfiles/activerecord30.gemfile.lock +1 -1
- data/gemfiles/activerecord31.gemfile.lock +1 -1
- data/gemfiles/activerecord32.gemfile.lock +1 -1
- data/lib/cerbero.rb +2 -2
- data/lib/cerbero/version.rb +1 -1
- data/spec/cerbero_spec.rb +8 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Cerbero
|
2
2
|
|
3
|
-
Uniqueness validation
|
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.
|
data/lib/cerbero.rb
CHANGED
data/lib/cerbero/version.rb
CHANGED
data/spec/cerbero_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe 'cerbero' do
|
|
18
18
|
user.errors[:email].should_not be_blank
|
19
19
|
end
|
20
20
|
|
21
|
-
it '
|
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.
|
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-
|
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: -
|
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: -
|
147
|
+
hash: -738609250160776711
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
150
|
rubygems_version: 1.8.23
|