mongo_mapper_versioned 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  module MongoMapper
3
3
  module Plugins
4
4
  module Versioned
5
- Version = '0.1.4'
5
+ Version = '0.1.5'
6
6
  end
7
7
  end
8
8
  end
@@ -7,7 +7,7 @@ module MongoMapper
7
7
  configuration = { :ignored_keys => %w(_id version_number created_at updated_at creator_id updater_id) }
8
8
  configuration.update(options) if options.is_a?(Hash)
9
9
 
10
- key :version_number, Integer, :default => 1, :index => true
10
+ key :version_number, Integer, :default => 0, :index => true
11
11
  many :versions, :class => MongoMapper::Plugins::Versioned::Version, :foreign_key => :versioned_id, :dependent => :destroy, :order => :version_number.asc
12
12
 
13
13
  after_create :create_version
@@ -24,7 +24,7 @@ module MongoMapper
24
24
  module InstanceMethods
25
25
 
26
26
  def create_version
27
- self.version_number = versions.last.version_number+1 if versions.count > 0
27
+ self.version_number = (versions.empty? ? 1 : versions.last.version_number+1)
28
28
  self.versions << current_version
29
29
  end
30
30
 
@@ -23,8 +23,8 @@ class VersionedTest < ActiveSupport::TestCase
23
23
  setup do
24
24
  @doc = VersionedDoc.new
25
25
  end
26
- should "be on version 1" do
27
- assert_equal 1, @doc.version_number
26
+ should "be on version 0" do
27
+ assert_equal 0, @doc.version_number
28
28
  end
29
29
  should "have 0 versions" do
30
30
  assert_equal 0, @doc.versions.count
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper_versioned
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tomas Celizna