mongoid_token 2.0.1 → 2.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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjI5OGI0MDMxODMzNjQwOTQyZTJjZDdlN2JmYmI0NmQ1Y2EyZjQyNQ==
4
+ NzAzMmIyYTMyMzIwMTkxZDk2NTI4OTU1NWQ5MDYwMDgzNmYwYTBiOQ==
5
5
  data.tar.gz: !binary |-
6
- MzhmM2JjY2ViNjNkYjUwYjQwNmMyMzQzYjMyMTc1ZjBkMDA5MjY0Mg==
6
+ MjZiZDAzN2MyM2UxMjQ1Zjg5MWJhMWRhZDBiN2ZmMDczMDUzMDJjYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjFlNjMxM2Q2MTE4NmI1YzNiN2ZiYjI5NzJmYzA1ZjEzNmRiYzU5NjZkYjYy
10
- ZjU3Y2RmZDJhZDhlOTJlMmFlNWNiMmQ5NTA2NzhiZDk0MmMwMzAwYWYwMjdm
11
- NmYzODcxM2QwYTE5YmI3YTdiYWY2Y2YwYzQ4ZjBmMWU1ZjQxMDY=
9
+ NDQ3YjNiYjFmMWIyYWFlYjRiODdjYmRhNzRhOTIyNjEyOTVjM2Y5ZDk2ZTg5
10
+ MWEzYTEyYjA5MTFmMGE4NGM4ZDFlNWMwODcwMzNkNzliZDRkYTE3NzJjYmIy
11
+ OGMyOTkxOTE3M2JkNDNiNGZiZTFjN2VkZGY2MGQ1ZGI5MWQxNWQ=
12
12
  data.tar.gz: !binary |-
13
- MGM4YjYyYWFmZDU0MjA4MmRkNjQ4ZTk3YjM0YzYwNWY4OTc4MzdlZjZlYTY5
14
- M2NmNzRmMDJjNDRiNDE3MDhiY2RkZjM5NjI1NzI3NmNmMGZiZGJmNjI0MzZm
15
- ZDQ4MjE2MDVkNjcwNmU2NDZlNmFiMGFmOWMxOTZmZmY1NTExNzg=
13
+ NGYzN2NlZjlhZWIzYmNjZWEyNDJhZjcxMGIzMDgyYWVlZDhmMDhiMWVhYzMw
14
+ ZDE3NDIwZGMwY2Q0MzU2Y2NhM2IxZWMwZjBmYzBlMTMyMzU0NGUyNjM3YTFl
15
+ YTdmZjVlZTU0NmQwNzYwYjc5MWMxMjFkMjExNzk5MmVhNjVjNjg=
@@ -12,6 +12,8 @@ module Mongoid
12
12
  retry
13
13
  end
14
14
  raise_collision_retries_exceeded_error resolver.field_name, resolver.retry_count
15
+ else
16
+ raise e
15
17
  end
16
18
  end
17
19
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MongoidToken
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -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
 
@@ -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 an operation failure is thrown for another reason" do
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
- expect{document_class.create!}.to_not raise_exception(Mongoid::Token::CollisionRetriesExceeded)
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.1
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-06 00:00:00.000000000 Z
11
+ date: 2013-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid