mongoid-history 0.3.0 → 0.3.1

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.
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ services: mongodb
2
3
  rvm:
3
4
  - 1.9.3
4
5
 
@@ -1,13 +1,19 @@
1
- Next Release
2
- ------------
1
+ 0.3.1
2
+ -----
3
3
 
4
- *
4
+ * [#45](https://github.com/aq1018/mongoid-history/pull/45) Fix: intermittent hash ordering issue with history_tracks - [@getaroom](https://github.com/getaroom).
5
+ * [#50](https://github.com/aq1018/mongoid-history/pull/50) Fix: tracking of array changes, undo and redo of field changes on non-embedded objects - [@dblock](https://github.com/dblock).
6
+
7
+ 0.3.0 (8/21/2012)
8
+ -----------------
9
+
10
+ * [#41](https://github.com/aq1018/mongoid-history/pull/41) Mongoid 3.x support - [@zambot](https://github.com/zambot).
5
11
 
6
12
  0.2.4 (8/21/2012)
7
13
  -----------------
8
14
 
9
- * [#38](https://github.com/aq1018/mongoid-history/pull/38) Fix: Allow sub-models to be tracked by using `collection_name` as the scope - [@acant](https://github.com/acant).
10
- * [#35](https://github.com/aq1018/mongoid-history/pull/35): Fix: sweeper references record of change, not the record changed - [@dblock](https://github.com/dblock).
15
+ * [#38](https://github.com/aq1018/mongoid-history/pull/38) Fix: allow sub-models to be tracked by using `collection_name` as the scope - [@acant](https://github.com/acant).
16
+ * [#35](https://github.com/aq1018/mongoid-history/pull/35) Fix: sweeper references record of change, not the record changed - [@dblock](https://github.com/dblock).
11
17
 
12
18
  0.2.3 (4/20/2012)
13
19
  -----------------
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  mongoid-history
2
2
  ===============
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/aq1018/mongoid-history.png?branch=master)](http://travis-ci.org/aq1018/mongoid-history) [![Dependency Status](https://gemnasium.com/aq1018/mongoid-history.png?travis)](https://gemnasium.com/aq1018/mongoid-history)
4
+ [![Build Status](https://secure.travis-ci.org/aq1018/mongoid-history.png?branch=master)](http://travis-ci.org/aq1018/mongoid-history)
5
5
 
6
6
  Mongoid-history tracks historical changes for any document, including embedded ones. It achieves this by storing all history tracks in a single collection that you define. Embedded documents are referenced by storing an association path, which is an array of `document_name` and `document_id` fields starting from the top most parent document and down to the embedded document that should track history.
7
7
 
@@ -178,6 +178,6 @@ Contributing to mongoid-history
178
178
  Copyright
179
179
  ---------
180
180
 
181
- Copyright (c) 2011-2012 Aaron Qian. MIT License.
181
+ Copyright (c) 2011-2012 Aaron Qian. MIT License.
182
182
  See [LICENSE.txt](https://github.com/aq1018/mongoid-history/blob/master/LICENSE.txt) for further details.
183
183
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -71,7 +71,7 @@ module Mongoid::History
71
71
 
72
72
  module MyInstanceMethods
73
73
  def history_tracks
74
- @history_tracks ||= Mongoid::History.tracker_class.where(:scope => history_trackable_options[:scope], :association_chain => association_hash)
74
+ @history_tracks ||= Mongoid::History.tracker_class.where(:scope => history_trackable_options[:scope], :association_chain => { "$elemMatch" => association_hash })
75
75
  end
76
76
 
77
77
  # undo :from => 1, :to => 5
@@ -239,7 +239,7 @@ module Mongoid::History
239
239
  modified[k] = m unless m.nil?
240
240
  end
241
241
 
242
- return original.easy_diff modified
242
+ [ original, modified ]
243
243
  end
244
244
 
245
245
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mongoid-history"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Qian", "Justin Grimes"]
12
- s.date = "2012-08-21"
12
+ s.date = "2012-11-16"
13
13
  s.description = "In frustration of Mongoid::Versioning, I created this plugin for tracking historical changes for any document, including embedded ones. It achieves this by storing all history tracks in a single collection that you define. (See Usage for more details) Embedded documents are referenced by storing an association path, which is an array of document_name and document_id fields starting from the top most parent document and down to the embedded document that should track history.\n\n This plugin implements multi-user undo, which allows users to undo any history change in any order. Undoing a document also creates a new history track. This is great for auditing and preventing vandalism, but it is probably not suitable for use cases such as a wiki."
14
14
  s.email = ["aq1018@gmail.com", "justin.mgrimes@gmail.com"]
15
15
  s.extra_rdoc_files = [
@@ -52,6 +52,7 @@ describe Mongoid::History do
52
52
 
53
53
  field :email
54
54
  field :name
55
+ field :aliases, :type => Array
55
56
  track_history :except => [:email]
56
57
  end
57
58
 
@@ -59,7 +60,7 @@ describe Mongoid::History do
59
60
  include Mongoid::Document
60
61
  include Mongoid::Timestamps
61
62
  include Mongoid::History::Trackable
62
-
63
+
63
64
  belongs_to :updated_by, :class_name => "User"
64
65
 
65
66
  field :title
@@ -68,7 +69,7 @@ describe Mongoid::History do
68
69
  end
69
70
 
70
71
  before :each do
71
- @user = User.create(:name => "Aaron", :email => "aaron@randomemail.com")
72
+ @user = User.create(:name => "Aaron", :email => "aaron@randomemail.com", :aliases => [ 'bob' ])
72
73
  @another_user = User.create(:name => "Another Guy", :email => "anotherguy@randomemail.com")
73
74
  @post = Post.create(:title => "Test", :body => "Post", :modifier => @user, :views => 100)
74
75
  @comment = @post.comments.create(:title => "test", :body => "comment", :modifier => @user)
@@ -189,10 +190,35 @@ describe Mongoid::History do
189
190
  end
190
191
 
191
192
  it "should exclude defined options" do
193
+ name = @user.name
194
+ @user.update_attributes(:name => "Aaron2", :email => "aaronsnewemail@randomemail.com")
195
+ @user.history_tracks.first.original.keys.should == [ "name", "updated_at" ]
196
+ @user.history_tracks.first.original["name"].should == name
197
+ @user.history_tracks.first.modified.keys.should == [ "name", "updated_at" ]
198
+ @user.history_tracks.first.modified["name"].should == @user.name
199
+ end
200
+
201
+ it "should undo field changes" do
202
+ name = @user.name
192
203
  @user.update_attributes(:name => "Aaron2", :email => "aaronsnewemail@randomemail.com")
193
- @user.history_tracks.first.modified.keys.should include "name"
194
- @user.history_tracks.first.modified.keys.should_not include "email"
204
+ @user.history_tracks.first.undo! nil
205
+ @user.reload.name.should == name
206
+ end
207
+
208
+ it "should track array changes" do
209
+ aliases = @user.aliases
210
+ @user.update_attributes(:aliases => [ 'bob', 'joe' ])
211
+ @user.history_tracks.first.original["aliases"].should == aliases
212
+ @user.history_tracks.first.modified["aliases"].should == @user.aliases
195
213
  end
214
+
215
+ it "should undo array changes" do
216
+ aliases = @user.aliases
217
+ @user.update_attributes(:aliases => [ 'bob', 'joe' ])
218
+ @user.history_tracks.first.undo! nil
219
+ @user.reload.aliases.should == aliases
220
+ end
221
+
196
222
  end
197
223
 
198
224
  describe "on update non-embedded twice" do
@@ -367,7 +393,7 @@ describe Mongoid::History do
367
393
  @tag_foo = @post.tags.create(:title => "foo", :updated_by => @user)
368
394
  @tag_bar = @post.tags.create(:title => "bar")
369
395
  end
370
-
396
+
371
397
  after(:each) do
372
398
  Thread.current[:mongoid_history_sweeper_controller] = nil
373
399
  end
@@ -400,7 +426,7 @@ describe Mongoid::History do
400
426
  @tag_foo.history_tracks.last.association_chain.last["name"].should == "tags"
401
427
  lambda{ @tag_foo.history_tracks.last.trackable }.should_not raise_error
402
428
  end
403
-
429
+
404
430
  it "should save modifier" do
405
431
  @tag_foo.history_tracks.last.modifier.should eq @user
406
432
  @tag_bar.history_tracks.last.modifier.should eq @user
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-21 00:00:00.000000000 Z
13
+ date: 2012-11-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: easy_diff
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 877523070155476761
103
+ hash: -3144305441896243530
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements: