mongoid_auto_inc 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module MongoidAutoInc
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -9,7 +9,7 @@ module MongoidAutoInc
9
9
  seq_name = "#{self.name.downcase}_#{name}"
10
10
  @@incrementor = MongoidAutoInc::Incrementor.new(options)
11
11
 
12
- before_create { self.send("#{name}=", @@incrementor[seq_name].inc) }
12
+ before_create { self.send("#{name}=", @@incrementor[seq_name].inc) unless self[name.to_sym].present? }
13
13
  end
14
14
  end
15
15
  end
@@ -34,6 +34,11 @@ describe MongoidAutoInc do
34
34
  DocumentA.create!
35
35
  DocumentA.create!.seq.should == 2
36
36
  end
37
+
38
+ it "should not auto increment when value is provided" do
39
+ doc = DocumentA.create!(seq: 33)
40
+ doc.seq.should == 33
41
+ end
37
42
  end
38
43
 
39
44
  describe "auto increment with :collection option" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_auto_inc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-25 00:00:00.000000000Z
12
+ date: 2012-02-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2172656860 !ruby/object:Gem::Requirement
16
+ requirement: &2153476000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0.beta.22
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2172656860
24
+ version_requirements: *2153476000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mongoid
27
- requirement: &2172656360 !ruby/object:Gem::Requirement
27
+ requirement: &2153475500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0.rc.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2172656360
35
+ version_requirements: *2153475500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &2172655880 !ruby/object:Gem::Requirement
38
+ requirement: &2153475020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 3.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2172655880
46
+ version_requirements: *2153475020
47
47
  description: Adds auto increment capabilities to Mongoid::Document
48
48
  email:
49
49
  - jffreyjs@gmail.com