mongoid-history 0.8.0 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.coveralls.yml +1 -1
  3. data/.document +5 -5
  4. data/.github/workflows/test.yml +72 -0
  5. data/.gitignore +46 -46
  6. data/.rspec +2 -2
  7. data/.rubocop.yml +6 -6
  8. data/.rubocop_todo.yml +99 -101
  9. data/CHANGELOG.md +173 -144
  10. data/CONTRIBUTING.md +117 -118
  11. data/Dangerfile +1 -1
  12. data/Gemfile +49 -37
  13. data/LICENSE.txt +20 -20
  14. data/README.md +609 -595
  15. data/RELEASING.md +66 -67
  16. data/Rakefile +24 -24
  17. data/UPGRADING.md +53 -34
  18. data/lib/mongoid/history/attributes/base.rb +72 -72
  19. data/lib/mongoid/history/attributes/create.rb +45 -50
  20. data/lib/mongoid/history/attributes/destroy.rb +34 -34
  21. data/lib/mongoid/history/attributes/update.rb +104 -45
  22. data/lib/mongoid/history/options.rb +177 -179
  23. data/lib/mongoid/history/trackable.rb +588 -521
  24. data/lib/mongoid/history/tracker.rb +247 -244
  25. data/lib/mongoid/history/version.rb +5 -5
  26. data/lib/mongoid/history.rb +77 -52
  27. data/lib/mongoid-history.rb +1 -1
  28. data/mongoid-history.gemspec +25 -25
  29. data/perf/benchmark_modified_attributes_for_create.rb +65 -0
  30. data/perf/gc_suite.rb +21 -0
  31. data/spec/integration/embedded_in_polymorphic_spec.rb +112 -135
  32. data/spec/integration/integration_spec.rb +976 -942
  33. data/spec/integration/multi_relation_spec.rb +47 -53
  34. data/spec/integration/multiple_trackers_spec.rb +68 -71
  35. data/spec/integration/nested_embedded_documents_spec.rb +64 -84
  36. data/spec/integration/nested_embedded_documents_tracked_in_parent_spec.rb +124 -0
  37. data/spec/integration/nested_embedded_polymorphic_documents_spec.rb +115 -127
  38. data/spec/integration/subclasses_spec.rb +47 -29
  39. data/spec/integration/track_history_order_spec.rb +84 -52
  40. data/spec/integration/validation_failure_spec.rb +76 -63
  41. data/spec/spec_helper.rb +32 -25
  42. data/spec/support/error_helpers.rb +7 -0
  43. data/spec/support/mongoid.rb +11 -11
  44. data/spec/support/mongoid_history.rb +12 -13
  45. data/spec/unit/attributes/base_spec.rb +141 -150
  46. data/spec/unit/attributes/create_spec.rb +342 -315
  47. data/spec/unit/attributes/destroy_spec.rb +228 -218
  48. data/spec/unit/attributes/update_spec.rb +342 -321
  49. data/spec/unit/callback_options_spec.rb +165 -159
  50. data/spec/unit/embedded_methods_spec.rb +87 -69
  51. data/spec/unit/history_spec.rb +58 -35
  52. data/spec/unit/my_instance_methods_spec.rb +555 -485
  53. data/spec/unit/options_spec.rb +365 -327
  54. data/spec/unit/singleton_methods_spec.rb +406 -338
  55. data/spec/unit/store/default_store_spec.rb +11 -11
  56. data/spec/unit/store/request_store_spec.rb +13 -13
  57. data/spec/unit/trackable_spec.rb +1057 -689
  58. data/spec/unit/tracker_spec.rb +190 -163
  59. metadata +13 -8
  60. data/.travis.yml +0 -35
data/CHANGELOG.md CHANGED
@@ -1,144 +1,173 @@
1
- ### 0.8.0 (2018/01/16)
2
-
3
- * [#180](https://github.com/mongoid/mongoid-history/pull/180): Removed deprecation notice - [@sivagollapalli](https://github.com/sivagollapalli).
4
- * [#208](https://github.com/mongoid/mongoid-history/pull/208): Fix: history tracks fields declared after `track_history` - [@mikwat](https://github.com/mikwat).
5
- * [#210](https://github.com/mongoid/mongoid-history/pull/210): Do not track unmodified embedded relations - [@jagdeepsingh](https://github.com/jagdeepsingh).
6
- * [#205](https://github.com/mongoid/mongoid-history/pull/205): Allow modifier field to be optional - [@yads](https://github.com/yads).
7
- * [#211](https://github.com/mongoid/mongoid-history/pull/211): Enable tracking create/destroy by default - [@jagdeepsingh](https://github.com/jagdeepsingh).
8
- * [#212](https://github.com/mongoid/mongoid-history/pull/212): `track_history` method support for `:if` and `:unless` options - [@jagdeepsingh](https://github.com/jagdeepsingh).
9
-
10
- ### 0.7.0 (2017/11/14)
11
-
12
- * [#202](https://github.com/mongoid/mongoid-history/pull/202): Do not create tracker on persistence error - [@mikwat](https://github.com/mikwat).
13
- * [#196](https://github.com/mongoid/mongoid-history/pull/196): Fix bug causing history tracks to get mixed up between multiple trackers when using multiple trackers - [@ojbucao](https://github.com/ojbucao).
14
-
15
- ### 0.6.1 (2017/01/04)
16
-
17
- * [#182](https://github.com/mongoid/mongoid-history/pull/182): No-op on repeated calls to destroy - [@msaffitz](https://github.com/msaffitz).
18
- * [#170](https://github.com/mongoid/mongoid-history/pull/170): Parent repo is now [mongoid/mongoid-history](https://github.com/mongoid/mongoid-history) - [@dblock](https://github.com/dblock).
19
- * [#171](https://github.com/mongoid/mongoid-history/pull/171): Add field formatting - [@jnfeinstein](https://github.com/jnfeinstein).
20
- * [#172](https://github.com/mongoid/mongoid-history/pull/172): Add config helper to track all embedded relations - [@jnfeinstein](https://github.com/jnfeinstein).
21
- * [#173](https://github.com/mongoid/mongoid-history/pull/173): Compatible with mongoid 6 - [@sivagollapalli](https://github.com/sivagollapalli).
22
-
23
- ### 0.6.0 (2016/09/13)
24
-
25
- * [#2](https://github.com/dblock/mongoid-history/pull/2): Forked into the [mongoid](https://github.com/mongoid) organization - [@dblock](https://github.com/dblock).
26
- * [#1](https://github.com/dblock/mongoid-history/pull/1): Added Danger, PR linter - [@dblock](https://github.com/dblock).
27
- * [#166](https://github.com/mongoid/mongoid-history/pull/166): Hash fields should default to an empty Hash - [@johnnyshields](https://github.com/johnnyshields).
28
- * [#162](https://github.com/mongoid/mongoid-history/pull/162): Do not consider embedded relations as dynamic fields - [@JagdeepSingh](https://github.com/JagdeepSingh).
29
- * [#144](https://github.com/mongoid/mongoid-history/pull/158): Can modify history tracker insertion on object creation - [@sivagollapalli](https://github.com/sivagollapalli).
30
- * [#155](https://github.com/mongoid/mongoid-history/pull/155): Add support to whitelist the attributes for tracked embeds_one and embeds_many relations - [@JagdeepSingh](https://github.com/JagdeepSingh).
31
- * [#154](https://github.com/mongoid/mongoid-history/pull/154): Prevent soft-deleted embedded documents from tracking - [@JagdeepSingh](https://github.com/JagdeepSingh).
32
- * [#151](https://github.com/mongoid/mongoid-history/pull/151): Added ability to customize tracker class for each trackable; multiple trackers across the app are now possible - [@JagdeepSingh](https://github.com/JagdeepSingh).
33
- * [#151](https://github.com/mongoid/mongoid-history/pull/151): Added automatic support for `request_store` gem as drop-in replacement for `Thread.current` - [@JagdeepSingh](https://github.com/JagdeepSingh).
34
- * [#150](https://github.com/mongoid/mongoid-history/pull/150): Added support for keeping embedded objects audit history in parent itself - [@JagdeepSingh](https://github.com/JagdeepSingh).
35
-
36
- ### 0.5.0 (2015/09/18)
37
-
38
- * [#143](https://github.com/mongoid/mongoid-history/pull/143): Added support for Mongoid 5 - [@dblock](https://github.com/dblock).
39
- * [#133](https://github.com/mongoid/mongoid-history/pull/133): Added dynamic attributes tracking (Mongoid::Attributes::Dynamic) - [@minisai](https://github.com/minisai).
40
- * [#142](https://github.com/mongoid/mongoid-history/pull/142): Allow non-database fields to be specified in conjunction with a custom changes method - [@kayakyakr](https://github.com/kayakyakr).
41
-
42
- ### 0.4.7 (2015/04/06)
43
-
44
- * [#124](https://github.com/mongoid/mongoid-history/pull/124): You can require both `mongoid-history` and `mongoid/history` - [@dblock](https://github.com/dblock).
45
-
46
- ### 0.4.5 (2015/02/09)
47
-
48
- * [#131](https://github.com/mongoid/mongoid-history/pull/131): Added `undo` method, that helps to get specific version of an object without saving changes - [@alexkravets](https://github.com/alexkravets).
49
- * [#127](https://github.com/mongoid/mongoid-history/pull/127): Fixed gem naming per [rubygems](http://guides.rubygems.org/name-your-gem/) specs, now you can `require 'mongoid/history'` - [@nofxx](https://github.com/nofxx).
50
- * [#129](https://github.com/mongoid/mongoid-history/pull/129): Support multiple levels of embedded polimorphic documents - [@BrunoChauvet](https://github.com/BrunoChauvet).
51
- * [#123](https://github.com/mongoid/mongoid-history/pull/123): Used a method compatible with mongoid-observers to determinine the version of Mongoid - [@zeitnot](https://github.com/zeitnot).
52
-
53
- ### 0.4.4 (2014/7/29)
54
-
55
- * [#111](https://github.com/mongoid/mongoid-history/pull/111): Fixed compatibility of `undo!` and `redo!` methods with Rails 3.x - [@mrjlynch](https://github.com/mrjlynch).
56
-
57
- ### 0.4.3 (2014/07/10)
58
-
59
- * [#110](https://github.com/mongoid/mongoid-history/pull/110): Fixed scope reference on history tracks criteria - [@adbeelitamar](https://github.com/adbeelitamar).
60
-
61
- ### 0.4.2 (2014/07/01)
62
-
63
- * [#106](https://github.com/mongoid/mongoid-history/pull/106): Added support for polymorphic relationship `scope` - [@adbeelitamar](https://github.com/adbeelitamar).
64
- * [#106](https://github.com/mongoid/mongoid-history/pull/106): Enabled specifying an array of relationships in `scope` - [@adbeelitamar](https://github.com/adbeelitamar).
65
- * [#83](https://github.com/mongoid/mongoid-history/pull/83): Added support for Mongoid 4.x, which removed `attr_accessible` in favor of protected attributes - [@dblock](https://github.com/dblock).
66
- * [#103](https://github.com/mongoid/mongoid-history/pull/103): Fixed compatibility with models using `default_scope` - [@mrjlynch](https://github.com/mrjlynch).
67
-
68
- ### 0.4.1 (2014/01/11)
69
-
70
- * Fixed compatibility with Mongoid 4.x - [@dblock](https://github.com/dblock).
71
- * `Mongoid::History::Sweeper` has been removed, in accorance with Mongoid 4.x (see [#3108](https://github.com/mongoid/mongoid/issues/3108)) and Rails 4.x observer deprecation - [@dblock](https://github.com/dblock).
72
- * Default modifier parameter to `nil` in `undo!` and `redo!` - [@dblock](https://github.com/dblock).
73
- * Fixed `undo!` and `redo!` for mass-assignment protected attributes - [@mati0090](https://github.com/mati0090).
74
- * Implemented Rubocop, Ruby style linter - [@dblock](https://github.com/dblock).
75
- * Remove unneeded coma from README - [@matsprea](https://github.com/matsprea).
76
- * Replace Jeweler with Gem-Release - [@johnnyshields](https://github.com/johnnyshields).
77
- * Track version as a Ruby file - [@johnnyshields](https://github.com/johnnyshields).
78
-
79
- ### 0.4.0 (2013/06/12)
80
-
81
- * Added `Mongoid::History.disable` and `Mongoid::History.enabled?` methods for global tracking disablement - [@johnnyshields](https://github.com/johnnyshields).
82
- * Added `:changes_method` that optionally overrides which method to call to collect changes - [@joelnordel](https://github.com/joelnordell).
83
- * The `:destroy` action now stores trackers in the format `original=value, modified=nil` (previously it was the reverse) - [@johnnyshields](https://github.com/johnnyshields).
84
- * Support for polymorphic embedded classes - [@tstepp](https://github.com/tstepp).
85
- * Support for Mongoid field aliases, e.g. `field :n, as: :name` - [@johnnyshields](https://github.com/johnnyshields).
86
- * Support for Mongoid embedded aliases, e.g. `embeds_many :comments, store_as: :coms` - [@johnnyshields](https://github.com/johnnyshields).
87
- * Added `#tracked_changes` and `#tracked_edits` methods to `Tracker` class for nicer change summaries - [@johnnyshields](https://github.com/johnnyshields) and [@tstepp](https://github.com/tstepp).
88
- * Refactored and exposed `#trackable_parent_class` in `Tracker`, which returns the class of the trackable regardless of whether the trackable itself has been destroyed - [@johnnyshields](https://github.com/johnnyshields).
89
- * Added class-level `#tracked_field?` and `#tracked_fields` methods; refactor logic to determine whether a field is tracked - [@johnnyshields](https://github.com/johnnyshields).
90
- * Fixed bug in Trackable#track_update where `return` condition at beginning of method caused a short-circuit where memoization would not be cleared properly - [@johnnyshields](https://github.com/johnnyshields).
91
- * Tests: Added spec for nested embedded documents - [@matekb](https://github.com/matekb).
92
- * Tests: Test run time cut in half (~2.5s versus ~5s) by using `#let` helper and removing class initialization before each test - [@johnnyshields](https://github.com/johnnyshields).
93
- * Tests: Remove `database_cleaner` gem in favor of `Mongoid.purge!` - [@johnnyshields](https://github.com/johnnyshields).
94
- * Tests: Remove dependency on non-committed file `mongoid.yml` and hardcode collection to `mongoid_history_test` - [@johnnyshields](https://github.com/johnnyshields).
95
-
96
- ### 0.3.3 (2013/04/01)
97
-
98
- * [#42](https://github.com/mongoid/mongoid-history/issues/42): Fix: corrected creation of association chain when using nested embedded documents - [@matekb](https://github.com/matekb).
99
- * [#56](https://github.com/mongoid/mongoid-history/issues/56): Fix: now possible to undo setting (creating) attributes that was previously unset - [@matekb](https://github.com/matekb).
100
- * [#49](https://github.com/mongoid/mongoid-history/issues/49): Fix: now correctly undo/redo localized fields - [@edejong](https://github.com/edejong).
101
-
102
-
103
- ### 0.3.2 (2013/01/24)
104
-
105
- * [#54](https://github.com/mongoid/mongoid-history/pull/54): Used an index instead of the `$elemMatch` selector in `history_tracks` - [@vecio](https://github.com/vecio).
106
- * [#11](https://github.com/mongoid/mongoid-history/issues/11): Added `:modifier_field_inverse_of` on `track_history` that defines the `:inverse_of` relationship of the modifier class - [@matekb](https://github.com/matekb), [@dblock](https://github.com/dblock).
107
-
108
- ### 0.3.1 (2012/11/16)
109
-
110
- * [#45](https://github.com/mongoid/mongoid-history/pull/45): Fix: intermittent hash ordering issue with `history_tracks` - [@getaroom](https://github.com/getaroom).
111
- * [#50](https://github.com/mongoid/mongoid-history/pull/50): Fix: tracking of array changes, undo and redo of field changes on non-embedded objects - [@dblock](https://github.com/dblock).
112
-
113
- ### 0.3.0 (2012/08/21)
114
-
115
- * [#41](https://github.com/mongoid/mongoid-history/pull/41): Mongoid 3.x support - [@zambot](https://github.com/zambot).
116
-
117
- ### 0.2.4 (2012/08/21)
118
-
119
- * [#38](https://github.com/mongoid/mongoid-history/pull/38): Fix: allow sub-models to be tracked by using `collection_name` as the scope - [@acant](https://github.com/acant).
120
- * [#35](https://github.com/mongoid/mongoid-history/pull/35): Fix: sweeper references record of change, not the record changed - [@dblock](https://github.com/dblock).
121
-
122
- ### 0.2.3 (2012/04/20)
123
-
124
- * [#23](https://github.com/mongoid/mongoid-history/pull/34): Updated `Trackable::association_hash` to write through parent - [@tcopple](https://github.com/tcopple).
125
- * Fix: `Trackable::association_hash` nil meta value call - [@tcopple](https://github.com/tcopple).
126
- * [#27](https://github.com/mongoid/mongoid-history/pull/27): Added support for re-creation of destroyed embedded documents - [@erlingwl](https://github.com/erlingwl).
127
-
128
- ### 0.1.7 (2011/12/09)
129
-
130
- * Fix: tracking `false` values - [@gottfrois](https://github.com/gottfrois).
131
- * Used a mongoid observer and controller `around_filter` to pick up modifying user from controller - [@bensymonds](https://github.com/bensymonds).
132
- * More flexible dependency on mongoid - [@sarcilav](https://github.com/sarcilav).
133
- * Fix: tracking broken in a multithreaded environment - [@dblock](https://github.com/dblock).
134
-
135
- ### 0.1.0 (2011/05/13)
136
-
137
- * Added support for `destroy` - [@dblock](https://github.com/dblock).
138
- * Added undo and redo - [@aq1018](https://github.com/aq1018).
139
- * Added support for temporarily disabling history tracking - [@aq1018](https://github.com/aq1018).
140
- * Record modifier for undo and redo actions - [@aq1018](https://github.com/aq1018).
141
-
142
- ### 0.0.1 (2011/03/04)
143
-
144
- * Intial public release - [@aq1018](https://github.com/aq1018).
1
+ ### 0.8.5 (Next)
2
+
3
+ * Your contribution here.
4
+
5
+ ### 0.8.4 (2021/09/18)
6
+
7
+ * [#250](https://github.com/mongoid/mongoid-history/pull/250): Migrate to Github actions - [@johnnyshields](https://github.com/johnnyshields).
8
+ * [#249](https://github.com/mongoid/mongoid-history/pull/249): Don't update version on embedded documents if the document itself is being destroyed - [@getaroom](https://github.com/getaroom).
9
+ * [#248](https://github.com/mongoid/mongoid-history/pull/248): Don't update version on embedded documents if an ancestor is being destroyed in the same operation - [@getaroom](https://github.com/getaroom).
10
+
11
+ ### 0.8.3 (2020/06/17)
12
+
13
+ * [#236](https://github.com/mongoid/mongoid-history/pull/236): Fix Ruby 2.7 keyword argument warnings - [@vasilysn](https://github.com/vasilysn).
14
+ * [#237](https://github.com/mongoid/mongoid-history/pull/237): Fix tracking subclasses with additional fields - [@getaroom](https://github.com/getaroom).
15
+ * [#239](https://github.com/mongoid/mongoid-history/pull/239): Optimize `modified_attributes_for_create` 6-7x - [@getaroom](https://github.com/getaroom).
16
+ * [#240](https://github.com/mongoid/mongoid-history/pull/240): `Mongoid::History.disable` and `disable_tracking` now restore the original state - [@getaroom](https://github.com/getaroom).
17
+ * [#240](https://github.com/mongoid/mongoid-history/pull/240): Added `Mongoid::History.enable`, `Mongoid::History.enable!`, `Mongoid::History.disable!`, `enable_tracking`, `enable_tracking!`, and `disable_tracking!` - [@getaroom](https://github.com/getaroom).
18
+
19
+ ### 0.8.2 (2019/12/02)
20
+
21
+ * [#233](https://github.com/mongoid/mongoid-history/pull/233): Bug fix-Track ALL embedded relations when used with fields and filtered attributes on embedded objects - [@jagdeepsingh](https://github.com/jagdeepsingh).
22
+ * [#232](https://github.com/mongoid/mongoid-history/pull/232): Bug/187 track changes from embedded documents (not deeply nested) - [@Startouf](https://github.com/Startouf).
23
+ * [#227](https://github.com/mongoid/mongoid-history/pull/227): Store options in inheritable class attributes - [@jnfeinstein](https://github.com/jnfeinstein).
24
+ * [#229](https://github.com/mongoid/mongoid-history/pull/229), [#225](https://github.com/mongoid/mongoid-history/pull/225): Fixed inheritance of `history_trackable_options` - [@jnfeinstein](https://github.com/jnfeinstein).
25
+
26
+ ### 0.8.1 (2018/06/28)
27
+
28
+ * [#221](https://github.com/mongoid/mongoid-history/pull/221): Mongoid 7 support - [@dblock](https://github.com/dblock).
29
+
30
+ ### 0.8.0 (2018/01/16)
31
+
32
+ * [#180](https://github.com/mongoid/mongoid-history/pull/180): Removed deprecation notice - [@sivagollapalli](https://github.com/sivagollapalli).
33
+ * [#208](https://github.com/mongoid/mongoid-history/pull/208): Fix: history tracks fields declared after `track_history` - [@mikwat](https://github.com/mikwat).
34
+ * [#210](https://github.com/mongoid/mongoid-history/pull/210): Do not track unmodified embedded relations - [@jagdeepsingh](https://github.com/jagdeepsingh).
35
+ * [#205](https://github.com/mongoid/mongoid-history/pull/205): Allow modifier field to be optional - [@yads](https://github.com/yads).
36
+ * [#211](https://github.com/mongoid/mongoid-history/pull/211): Enable tracking create/destroy by default - [@jagdeepsingh](https://github.com/jagdeepsingh).
37
+ * [#212](https://github.com/mongoid/mongoid-history/pull/212): `track_history` method support for `:if` and `:unless` options - [@jagdeepsingh](https://github.com/jagdeepsingh).
38
+
39
+ ### 0.7.0 (2017/11/14)
40
+
41
+ * [#202](https://github.com/mongoid/mongoid-history/pull/202): Do not create tracker on persistence error - [@mikwat](https://github.com/mikwat).
42
+ * [#196](https://github.com/mongoid/mongoid-history/pull/196): Fix bug causing history tracks to get mixed up between multiple trackers when using multiple trackers - [@ojbucao](https://github.com/ojbucao).
43
+
44
+ ### 0.6.1 (2017/01/04)
45
+
46
+ * [#182](https://github.com/mongoid/mongoid-history/pull/182): No-op on repeated calls to destroy - [@msaffitz](https://github.com/msaffitz).
47
+ * [#170](https://github.com/mongoid/mongoid-history/pull/170): Parent repo is now [mongoid/mongoid-history](https://github.com/mongoid/mongoid-history) - [@dblock](https://github.com/dblock).
48
+ * [#171](https://github.com/mongoid/mongoid-history/pull/171): Add field formatting - [@jnfeinstein](https://github.com/jnfeinstein).
49
+ * [#172](https://github.com/mongoid/mongoid-history/pull/172): Add config helper to track all embedded relations - [@jnfeinstein](https://github.com/jnfeinstein).
50
+ * [#173](https://github.com/mongoid/mongoid-history/pull/173): Compatible with mongoid 6 - [@sivagollapalli](https://github.com/sivagollapalli).
51
+
52
+ ### 0.6.0 (2016/09/13)
53
+
54
+ * [#2](https://github.com/dblock/mongoid-history/pull/2): Forked into the [mongoid](https://github.com/mongoid) organization - [@dblock](https://github.com/dblock).
55
+ * [#1](https://github.com/dblock/mongoid-history/pull/1): Added Danger, PR linter - [@dblock](https://github.com/dblock).
56
+ * [#166](https://github.com/mongoid/mongoid-history/pull/166): Hash fields should default to an empty Hash - [@johnnyshields](https://github.com/johnnyshields).
57
+ * [#162](https://github.com/mongoid/mongoid-history/pull/162): Do not consider embedded relations as dynamic fields - [@JagdeepSingh](https://github.com/JagdeepSingh).
58
+ * [#144](https://github.com/mongoid/mongoid-history/pull/158): Can modify history tracker insertion on object creation - [@sivagollapalli](https://github.com/sivagollapalli).
59
+ * [#155](https://github.com/mongoid/mongoid-history/pull/155): Add support to whitelist the attributes for tracked embeds_one and embeds_many relations - [@JagdeepSingh](https://github.com/JagdeepSingh).
60
+ * [#154](https://github.com/mongoid/mongoid-history/pull/154): Prevent soft-deleted embedded documents from tracking - [@JagdeepSingh](https://github.com/JagdeepSingh).
61
+ * [#151](https://github.com/mongoid/mongoid-history/pull/151): Added ability to customize tracker class for each trackable; multiple trackers across the app are now possible - [@JagdeepSingh](https://github.com/JagdeepSingh).
62
+ * [#151](https://github.com/mongoid/mongoid-history/pull/151): Added automatic support for `request_store` gem as drop-in replacement for `Thread.current` - [@JagdeepSingh](https://github.com/JagdeepSingh).
63
+ * [#150](https://github.com/mongoid/mongoid-history/pull/150): Added support for keeping embedded objects audit history in parent itself - [@JagdeepSingh](https://github.com/JagdeepSingh).
64
+
65
+ ### 0.5.0 (2015/09/18)
66
+
67
+ * [#143](https://github.com/mongoid/mongoid-history/pull/143): Added support for Mongoid 5 - [@dblock](https://github.com/dblock).
68
+ * [#133](https://github.com/mongoid/mongoid-history/pull/133): Added dynamic attributes tracking (Mongoid::Attributes::Dynamic) - [@minisai](https://github.com/minisai).
69
+ * [#142](https://github.com/mongoid/mongoid-history/pull/142): Allow non-database fields to be specified in conjunction with a custom changes method - [@kayakyakr](https://github.com/kayakyakr).
70
+
71
+ ### 0.4.7 (2015/04/06)
72
+
73
+ * [#124](https://github.com/mongoid/mongoid-history/pull/124): You can require both `mongoid-history` and `mongoid/history` - [@dblock](https://github.com/dblock).
74
+
75
+ ### 0.4.5 (2015/02/09)
76
+
77
+ * [#131](https://github.com/mongoid/mongoid-history/pull/131): Added `undo` method, that helps to get specific version of an object without saving changes - [@alexkravets](https://github.com/alexkravets).
78
+ * [#127](https://github.com/mongoid/mongoid-history/pull/127): Fixed gem naming per [rubygems](http://guides.rubygems.org/name-your-gem/) specs, now you can `require 'mongoid/history'` - [@nofxx](https://github.com/nofxx).
79
+ * [#129](https://github.com/mongoid/mongoid-history/pull/129): Support multiple levels of embedded polimorphic documents - [@BrunoChauvet](https://github.com/BrunoChauvet).
80
+ * [#123](https://github.com/mongoid/mongoid-history/pull/123): Used a method compatible with mongoid-observers to determinine the version of Mongoid - [@zeitnot](https://github.com/zeitnot).
81
+
82
+ ### 0.4.4 (2014/7/29)
83
+
84
+ * [#111](https://github.com/mongoid/mongoid-history/pull/111): Fixed compatibility of `undo!` and `redo!` methods with Rails 3.x - [@mrjlynch](https://github.com/mrjlynch).
85
+
86
+ ### 0.4.3 (2014/07/10)
87
+
88
+ * [#110](https://github.com/mongoid/mongoid-history/pull/110): Fixed scope reference on history tracks criteria - [@adbeelitamar](https://github.com/adbeelitamar).
89
+
90
+ ### 0.4.2 (2014/07/01)
91
+
92
+ * [#106](https://github.com/mongoid/mongoid-history/pull/106): Added support for polymorphic relationship `scope` - [@adbeelitamar](https://github.com/adbeelitamar).
93
+ * [#106](https://github.com/mongoid/mongoid-history/pull/106): Enabled specifying an array of relationships in `scope` - [@adbeelitamar](https://github.com/adbeelitamar).
94
+ * [#83](https://github.com/mongoid/mongoid-history/pull/83): Added support for Mongoid 4.x, which removed `attr_accessible` in favor of protected attributes - [@dblock](https://github.com/dblock).
95
+ * [#103](https://github.com/mongoid/mongoid-history/pull/103): Fixed compatibility with models using `default_scope` - [@mrjlynch](https://github.com/mrjlynch).
96
+
97
+ ### 0.4.1 (2014/01/11)
98
+
99
+ * Fixed compatibility with Mongoid 4.x - [@dblock](https://github.com/dblock).
100
+ * `Mongoid::History::Sweeper` has been removed, in accorance with Mongoid 4.x (see [#3108](https://github.com/mongoid/mongoid/issues/3108)) and Rails 4.x observer deprecation - [@dblock](https://github.com/dblock).
101
+ * Default modifier parameter to `nil` in `undo!` and `redo!` - [@dblock](https://github.com/dblock).
102
+ * Fixed `undo!` and `redo!` for mass-assignment protected attributes - [@mati0090](https://github.com/mati0090).
103
+ * Implemented Rubocop, Ruby style linter - [@dblock](https://github.com/dblock).
104
+ * Remove unneeded coma from README - [@matsprea](https://github.com/matsprea).
105
+ * Replace Jeweler with Gem-Release - [@johnnyshields](https://github.com/johnnyshields).
106
+ * Track version as a Ruby file - [@johnnyshields](https://github.com/johnnyshields).
107
+
108
+ ### 0.4.0 (2013/06/12)
109
+
110
+ * Added `Mongoid::History.disable` and `Mongoid::History.enabled?` methods for global tracking disablement - [@johnnyshields](https://github.com/johnnyshields).
111
+ * Added `:changes_method` that optionally overrides which method to call to collect changes - [@joelnordel](https://github.com/joelnordell).
112
+ * The `:destroy` action now stores trackers in the format `original=value, modified=nil` (previously it was the reverse) - [@johnnyshields](https://github.com/johnnyshields).
113
+ * Support for polymorphic embedded classes - [@tstepp](https://github.com/tstepp).
114
+ * Support for Mongoid field aliases, e.g. `field :n, as: :name` - [@johnnyshields](https://github.com/johnnyshields).
115
+ * Support for Mongoid embedded aliases, e.g. `embeds_many :comments, store_as: :coms` - [@johnnyshields](https://github.com/johnnyshields).
116
+ * Added `#tracked_changes` and `#tracked_edits` methods to `Tracker` class for nicer change summaries - [@johnnyshields](https://github.com/johnnyshields) and [@tstepp](https://github.com/tstepp).
117
+ * Refactored and exposed `#trackable_parent_class` in `Tracker`, which returns the class of the trackable regardless of whether the trackable itself has been destroyed - [@johnnyshields](https://github.com/johnnyshields).
118
+ * Added class-level `#tracked_field?` and `#tracked_fields` methods; refactor logic to determine whether a field is tracked - [@johnnyshields](https://github.com/johnnyshields).
119
+ * Fixed bug in Trackable#track_update where `return` condition at beginning of method caused a short-circuit where memoization would not be cleared properly - [@johnnyshields](https://github.com/johnnyshields).
120
+ * Tests: Added spec for nested embedded documents - [@matekb](https://github.com/matekb).
121
+ * Tests: Test run time cut in half (~2.5s versus ~5s) by using `#let` helper and removing class initialization before each test - [@johnnyshields](https://github.com/johnnyshields).
122
+ * Tests: Remove `database_cleaner` gem in favor of `Mongoid.purge!` - [@johnnyshields](https://github.com/johnnyshields).
123
+ * Tests: Remove dependency on non-committed file `mongoid.yml` and hardcode collection to `mongoid_history_test` - [@johnnyshields](https://github.com/johnnyshields).
124
+
125
+ ### 0.3.3 (2013/04/01)
126
+
127
+ * [#42](https://github.com/mongoid/mongoid-history/issues/42): Fix: corrected creation of association chain when using nested embedded documents - [@matekb](https://github.com/matekb).
128
+ * [#56](https://github.com/mongoid/mongoid-history/issues/56): Fix: now possible to undo setting (creating) attributes that was previously unset - [@matekb](https://github.com/matekb).
129
+ * [#49](https://github.com/mongoid/mongoid-history/issues/49): Fix: now correctly undo/redo localized fields - [@edejong](https://github.com/edejong).
130
+
131
+
132
+ ### 0.3.2 (2013/01/24)
133
+
134
+ * [#54](https://github.com/mongoid/mongoid-history/pull/54): Used an index instead of the `$elemMatch` selector in `history_tracks` - [@vecio](https://github.com/vecio).
135
+ * [#11](https://github.com/mongoid/mongoid-history/issues/11): Added `:modifier_field_inverse_of` on `track_history` that defines the `:inverse_of` relationship of the modifier class - [@matekb](https://github.com/matekb), [@dblock](https://github.com/dblock).
136
+
137
+ ### 0.3.1 (2012/11/16)
138
+
139
+ * [#45](https://github.com/mongoid/mongoid-history/pull/45): Fix: intermittent hash ordering issue with `history_tracks` - [@getaroom](https://github.com/getaroom).
140
+ * [#50](https://github.com/mongoid/mongoid-history/pull/50): Fix: tracking of array changes, undo and redo of field changes on non-embedded objects - [@dblock](https://github.com/dblock).
141
+
142
+ ### 0.3.0 (2012/08/21)
143
+
144
+ * [#41](https://github.com/mongoid/mongoid-history/pull/41): Mongoid 3.x support - [@zambot](https://github.com/zambot).
145
+
146
+ ### 0.2.4 (2012/08/21)
147
+
148
+ * [#38](https://github.com/mongoid/mongoid-history/pull/38): Fix: allow sub-models to be tracked by using `collection_name` as the scope - [@acant](https://github.com/acant).
149
+ * [#35](https://github.com/mongoid/mongoid-history/pull/35): Fix: sweeper references record of change, not the record changed - [@dblock](https://github.com/dblock).
150
+
151
+ ### 0.2.3 (2012/04/20)
152
+
153
+ * [#23](https://github.com/mongoid/mongoid-history/pull/34): Updated `Trackable::association_hash` to write through parent - [@tcopple](https://github.com/tcopple).
154
+ * Fix: `Trackable::association_hash` nil meta value call - [@tcopple](https://github.com/tcopple).
155
+ * [#27](https://github.com/mongoid/mongoid-history/pull/27): Added support for re-creation of destroyed embedded documents - [@erlingwl](https://github.com/erlingwl).
156
+
157
+ ### 0.1.7 (2011/12/09)
158
+
159
+ * Fix: tracking `false` values - [@gottfrois](https://github.com/gottfrois).
160
+ * Used a mongoid observer and controller `around_filter` to pick up modifying user from controller - [@bensymonds](https://github.com/bensymonds).
161
+ * More flexible dependency on mongoid - [@sarcilav](https://github.com/sarcilav).
162
+ * Fix: tracking broken in a multithreaded environment - [@dblock](https://github.com/dblock).
163
+
164
+ ### 0.1.0 (2011/05/13)
165
+
166
+ * Added support for `destroy` - [@dblock](https://github.com/dblock).
167
+ * Added undo and redo - [@aq1018](https://github.com/aq1018).
168
+ * Added support for temporarily disabling history tracking - [@aq1018](https://github.com/aq1018).
169
+ * Record modifier for undo and redo actions - [@aq1018](https://github.com/aq1018).
170
+
171
+ ### 0.0.1 (2011/03/04)
172
+
173
+ * Intial public release - [@aq1018](https://github.com/aq1018).
data/CONTRIBUTING.md CHANGED
@@ -1,118 +1,117 @@
1
- Contributing to Mongoid-History
2
- ===============================
3
-
4
- Mongoid-History is work of [many of contributors](https://github.com/intridea/mongoid-history/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/intridea/mongoid-history/pulls), [propose features, ask questions and discuss issues](https://github.com/intridea/mongoid-history/issues).
5
-
6
- #### Fork the Project
7
-
8
- Fork the [project on Github](https://github.com/intridea/mongoid-history) and check out your copy.
9
-
10
- ```
11
- git clone https://github.com/contributor/mongoid-history.git
12
- cd mongoid-history
13
- git remote add upstream https://github.com/intridea/mongoid-history.git
14
- ```
15
-
16
- #### Create a Topic Branch
17
-
18
- Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
-
20
- ```
21
- git checkout master
22
- git pull upstream master
23
- git checkout -b my-feature-branch
24
- ```
25
-
26
- #### Bundle Install and Test
27
-
28
- Ensure that you can build the project and run tests.
29
-
30
- ```
31
- bundle install
32
- bundle exec rake
33
- ```
34
-
35
- #### Write Tests
36
-
37
- Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/mongoid-history](spec/mongoid-history).
38
-
39
- We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
40
-
41
- #### Write Code
42
-
43
- Implement your feature or bug fix.
44
-
45
- Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
46
-
47
- Make sure that `bundle exec rake` completes without errors.
48
-
49
- #### Write Documentation
50
-
51
- Document any external behavior in the [README](README.md).
52
-
53
- #### Update Changelog
54
-
55
- Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
56
-
57
- #### Commit Changes
58
-
59
- Make sure git knows your name and email address:
60
-
61
- ```
62
- git config --global user.name "Your Name"
63
- git config --global user.email "contributor@example.com"
64
- ```
65
-
66
- Writing good commit logs is important. A commit log should describe what changed and why.
67
-
68
- ```
69
- git add ...
70
- git commit
71
- ```
72
-
73
- #### Push
74
-
75
- ```
76
- git push origin my-feature-branch
77
- ```
78
-
79
- #### Make a Pull Request
80
-
81
- Go to https://github.com/contributor/mongoid-history and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
82
-
83
- #### Rebase
84
-
85
- If you've been working on a change for a while, rebase with upstream/master.
86
-
87
- ```
88
- git fetch upstream
89
- git rebase upstream/master
90
- git push origin my-feature-branch -f
91
- ```
92
-
93
- #### Update CHANGELOG Again
94
-
95
- Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
-
97
- ```
98
- * [#123](https://github.com/intridea/mongoid-history/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
- ```
100
-
101
- Amend your previous commit and force push the changes.
102
-
103
- ```
104
- git commit --amend
105
- git push origin my-feature-branch -f
106
- ```
107
-
108
- #### Check on Your Pull Request
109
-
110
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
111
-
112
- #### Be Patient
113
-
114
- It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
115
-
116
- #### Thank You
117
-
118
- Please do know that we really appreciate and value your time and work. We love you, really.
1
+ # Contributing to Mongoid-History
2
+
3
+ Mongoid-History is work of [many of contributors](https://github.com/mongoid/mongoid-history/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/mongoid/mongoid-history/pulls), [propose features, ask questions and discuss issues](https://github.com/mongoid/mongoid-history/issues).
4
+
5
+ ### Fork the Project
6
+
7
+ Fork the [project on Github](https://github.com/mongoid/mongoid-history) and check out your copy.
8
+
9
+ ```
10
+ git clone https://github.com/contributor/mongoid-history.git
11
+ cd mongoid-history
12
+ git remote add upstream https://github.com/mongoid/mongoid-history.git
13
+ ```
14
+
15
+ ### Create a Topic Branch
16
+
17
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
18
+
19
+ ```
20
+ git checkout master
21
+ git pull upstream master
22
+ git checkout -b my-feature-branch
23
+ ```
24
+
25
+ ### Bundle Install and Test
26
+
27
+ Ensure that you can build the project and run tests.
28
+
29
+ ```
30
+ bundle install
31
+ bundle exec rake
32
+ ```
33
+
34
+ ### Write Tests
35
+
36
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/mongoid-history](spec/mongoid-history).
37
+
38
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
39
+
40
+ ### Write Code
41
+
42
+ Implement your feature or bug fix.
43
+
44
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
45
+
46
+ Make sure that `bundle exec rake` completes without errors.
47
+
48
+ ### Write Documentation
49
+
50
+ Document any external behavior in the [README](README.md).
51
+
52
+ ### Update Changelog
53
+
54
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
55
+
56
+ ### Commit Changes
57
+
58
+ Make sure git knows your name and email address:
59
+
60
+ ```
61
+ git config --global user.name "Your Name"
62
+ git config --global user.email "contributor@example.com"
63
+ ```
64
+
65
+ Writing good commit logs is important. A commit log should describe what changed and why.
66
+
67
+ ```
68
+ git add ...
69
+ git commit
70
+ ```
71
+
72
+ ### Push
73
+
74
+ ```
75
+ git push origin my-feature-branch
76
+ ```
77
+
78
+ ### Make a Pull Request
79
+
80
+ Go to https://github.com/contributor/mongoid-history and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
81
+
82
+ ### Rebase
83
+
84
+ If you've been working on a change for a while, rebase with upstream/master.
85
+
86
+ ```
87
+ git fetch upstream
88
+ git rebase upstream/master
89
+ git push origin my-feature-branch -f
90
+ ```
91
+
92
+ ### Update CHANGELOG Again
93
+
94
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
95
+
96
+ ```
97
+ * [#123](https://github.com/mongoid/mongoid-history/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
98
+ ```
99
+
100
+ Amend your previous commit and force push the changes.
101
+
102
+ ```
103
+ git commit --amend
104
+ git push origin my-feature-branch -f
105
+ ```
106
+
107
+ ### Check on Your Pull Request
108
+
109
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
110
+
111
+ ### Be Patient
112
+
113
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
114
+
115
+ ### Thank You
116
+
117
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/Dangerfile CHANGED
@@ -1 +1 @@
1
- danger.import_dangerfile(gem: 'mongoid-danger')
1
+ danger.import_dangerfile(gem: 'mongoid-danger')