mongoid_token 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/mongoid/token/collisions.rb +2 -0
- data/lib/version.rb +1 -1
- data/spec/mongoid/token/collisions_spec.rb +11 -0
- data/spec/mongoid/token_spec.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzAzMmIyYTMyMzIwMTkxZDk2NTI4OTU1NWQ5MDYwMDgzNmYwYTBiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjZiZDAzN2MyM2UxMjQ1Zjg5MWJhMWRhZDBiN2ZmMDczMDUzMDJjYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDQ3YjNiYjFmMWIyYWFlYjRiODdjYmRhNzRhOTIyNjEyOTVjM2Y5ZDk2ZTg5
|
10
|
+
MWEzYTEyYjA5MTFmMGE4NGM4ZDFlNWMwODcwMzNkNzliZDRkYTE3NzJjYmIy
|
11
|
+
OGMyOTkxOTE3M2JkNDNiNGZiZTFjN2VkZGY2MGQ1ZGI5MWQxNWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGYzN2NlZjlhZWIzYmNjZWEyNDJhZjcxMGIzMDgyYWVlZDhmMDhiMWVhYzMw
|
14
|
+
ZDE3NDIwZGMwY2Q0MzU2Y2NhM2IxZWMwZjBmYzBlMTMyMzU0NGUyNjM3YTFl
|
15
|
+
YTdmZjVlZTU0NmQwNzYwYjc5MWMxMjFkMjExNzk5MmVhNjVjNjg=
|
data/lib/version.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
2
|
|
3
|
+
require 'pp'
|
4
|
+
|
3
5
|
describe Mongoid::Token::Collisions do
|
4
6
|
let(:document) { Object.new }
|
5
7
|
describe "#resolve_token_collisions" do
|
@@ -39,6 +41,15 @@ describe Mongoid::Token::Collisions do
|
|
39
41
|
expect(attempts).to eq 4
|
40
42
|
end
|
41
43
|
end
|
44
|
+
|
45
|
+
context "and a different index is violated" do
|
46
|
+
it "should bubble the operation failure" do
|
47
|
+
document.stub(:is_duplicate_token_error?).and_return(false)
|
48
|
+
resolver.stub(:retry_count).and_return(3)
|
49
|
+
e = Moped::Errors::OperationFailure.new("command", {:details => "nope"})
|
50
|
+
expect{document.resolve_token_collisions(resolver) { raise e }}.to raise_error(e)
|
51
|
+
end
|
52
|
+
end
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|
data/spec/mongoid/token_spec.rb
CHANGED
@@ -209,10 +209,28 @@ describe Mongoid::Token do
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
it "should not raise a custom error if
|
212
|
+
it "should not raise a custom error if another error is thrown during saving" do
|
213
213
|
document_class.send(:field, :name)
|
214
214
|
document_class.send(:validates_presence_of, :name)
|
215
|
-
|
215
|
+
document_class.any_instance.stub(:generate_token).and_return("1234")
|
216
|
+
document_class.stub(:model_name).and_return(ActiveModel::Name.new(document_class, nil, "temp"))
|
217
|
+
expect{document_class.create!}.to raise_exception(Mongoid::Errors::Validations)
|
218
|
+
end
|
219
|
+
|
220
|
+
context "with other unique indexes present" do
|
221
|
+
before(:each) do
|
222
|
+
document_class.send(:field, :name)
|
223
|
+
document_class.send(:index, {:name => 1}, {:unique => true})
|
224
|
+
document_class.create_indexes
|
225
|
+
end
|
226
|
+
|
227
|
+
context "when violating the other index" do
|
228
|
+
it "should raise an operation failure" do
|
229
|
+
duplicate_name = "Got Duped."
|
230
|
+
document_class.create!(:name => duplicate_name)
|
231
|
+
expect{ document_class.create!(:name => duplicate_name) }.to raise_exception(Moped::Errors::OperationFailure)
|
232
|
+
end
|
233
|
+
end
|
216
234
|
end
|
217
235
|
end
|
218
236
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Bruning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|