mongoid-history 0.6.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d92239564a7df075b3a55eb68c9f7f22666e24ef
4
- data.tar.gz: 13f5bb15f7102d5b0957b569cb880af4249a0c75
3
+ metadata.gz: d77abcedc5d3a8dd4dc76cc8d6320fbce3aaa1da
4
+ data.tar.gz: 7ea0951e39d1ce44841a92dacd55d576c6542612
5
5
  SHA512:
6
- metadata.gz: e9b09271720419ebbd843f78954d182430e4a3e5f020cc6b835993154c08fa55e6c8627beaef64f8813632ce15118186057d39771ddb863cf40f28a68c6ce7d3
7
- data.tar.gz: 8d337e3008f6468a42b01c0babafa649685237f686e255bd620d380bf8d91bf77d56888445ca20b043ee6f2e7398d4821709fb877bafe11765948fc38ee6ddad
6
+ metadata.gz: 332314784de0fa89013bab41d9586eeae0e72ee743ce964561d384df270a255970fe23abbc6081f7b0a592085bba8d7cf4f056a3bf24e4deff0099a23628d2b2
7
+ data.tar.gz: '0228bacf2516b4da7bd57db5171d3e92bc4b418c0df3fcc49fc366d783ed3bf789b2487abb9c32036996fb8ad975dd4adcfad1edeecfff72671bb3da5384b200'
data/.rubocop_todo.yml CHANGED
@@ -1,92 +1,101 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-09-17 17:43:47 -0400 using RuboCop version 0.34.1.
3
+ # on 2017-12-08 18:06:04 +0530 using RuboCop version 0.48.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 6
10
+ # Configuration parameters: Include.
11
+ # Include: **/Gemfile, **/gems.rb
12
+ Bundler/DuplicatedGem:
13
+ Exclude:
14
+ - 'Gemfile'
15
+
9
16
  # Offense count: 3
10
17
  Lint/HandleExceptions:
11
18
  Exclude:
12
19
  - 'spec/unit/trackable_spec.rb'
13
20
 
14
- Metrics/ClassLength:
15
- Max: 103
21
+ # Offense count: 2
22
+ Lint/ParenthesesAsGroupedExpression:
23
+ Exclude:
24
+ - 'spec/integration/integration_spec.rb'
16
25
 
17
- # Offense count: 12
26
+ # Offense count: 21
18
27
  Metrics/AbcSize:
19
- Max: 60
28
+ Max: 50
29
+
30
+ # Offense count: 111
31
+ # Configuration parameters: CountComments, ExcludedMethods.
32
+ Metrics/BlockLength:
33
+ Max: 807
20
34
 
21
- # Offense count: 4
35
+ # Offense count: 1
36
+ # Configuration parameters: CountComments.
37
+ Metrics/ClassLength:
38
+ Max: 126
39
+
40
+ # Offense count: 5
22
41
  Metrics/CyclomaticComplexity:
23
42
  Max: 10
24
43
 
25
- # Offense count: 199
26
- # Configuration parameters: AllowURI, URISchemes.
44
+ # Offense count: 462
45
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
46
+ # URISchemes: http, https
27
47
  Metrics/LineLength:
28
48
  Max: 688
29
49
 
30
- # Offense count: 7
50
+ # Offense count: 15
31
51
  # Configuration parameters: CountComments.
32
52
  Metrics/MethodLength:
33
- Max: 33
53
+ Max: 23
34
54
 
35
55
  # Offense count: 2
36
56
  # Configuration parameters: CountComments.
37
57
  Metrics/ModuleLength:
38
- Max: 223
58
+ Max: 180
39
59
 
40
- # Offense count: 4
60
+ # Offense count: 5
41
61
  Metrics/PerceivedComplexity:
42
62
  Max: 12
43
63
 
44
- # Offense count: 44
64
+ # Offense count: 12
45
65
  Style/Documentation:
46
66
  Exclude:
67
+ - 'spec/**/*'
68
+ - 'test/**/*'
47
69
  - 'lib/mongoid/history.rb'
48
- - 'lib/mongoid/history/options.rb'
49
- - 'lib/mongoid/history/trackable.rb'
50
- - 'lib/mongoid/history/tracker.rb'
51
- - 'lib/mongoid/history/version.rb'
52
70
  - 'lib/mongoid/history/attributes/base.rb'
53
71
  - 'lib/mongoid/history/attributes/create.rb'
54
72
  - 'lib/mongoid/history/attributes/destroy.rb'
55
73
  - 'lib/mongoid/history/attributes/update.rb'
56
- - 'spec/integration/embedded_in_polymorphic_spec.rb'
57
- - 'spec/integration/integration_spec.rb'
58
- - 'spec/integration/multi_relation_spec.rb'
59
- - 'spec/integration/nested_embedded_documents_spec.rb'
60
- - 'spec/integration/nested_embedded_polymorphic_documents_spec.rb'
61
- - 'spec/integration/subclasses_spec.rb'
62
- - 'spec/support/mongoid_history.rb'
63
- - 'spec/unit/options_spec.rb'
64
- - 'spec/unit/singleton_methods_spec.rb'
65
- - 'spec/unit/trackable_spec.rb'
66
- - 'spec/unit/tracker_spec.rb'
67
- - 'spec/unit/attributes/base_spec.rb'
68
- - 'spec/unit/attributes/create_spec.rb'
69
- - 'spec/unit/attributes/destroy_spec.rb'
70
- - 'spec/unit/attributes/update_spec.rb'
74
+ - 'lib/mongoid/history/options.rb'
75
+ - 'lib/mongoid/history/trackable.rb'
76
+ - 'lib/mongoid/history/tracker.rb'
71
77
 
72
- # Offense count: 6
78
+ # Offense count: 3
79
+ # Cop supports --auto-correct.
73
80
  Style/EachWithObject:
74
81
  Exclude:
75
82
  - 'lib/mongoid/history/trackable.rb'
76
83
  - 'lib/mongoid/history/tracker.rb'
77
84
 
78
- # Offense count: 1
79
- # Configuration parameters: Exclude.
85
+ # Offense count: 2
86
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
87
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
80
88
  Style/FileName:
81
89
  Exclude:
90
+ - 'Dangerfile'
82
91
  - 'lib/mongoid-history.rb'
83
92
 
84
- # Offense count: 3
85
- Style/MultilineBlockChain:
93
+ # Offense count: 1
94
+ Style/IfInsideElse:
86
95
  Exclude:
87
96
  - 'lib/mongoid/history/trackable.rb'
88
- - 'lib/mongoid/history/tracker.rb'
89
97
 
90
- Style/ClassLength:
98
+ # Offense count: 1
99
+ Style/MultilineBlockChain:
91
100
  Exclude:
92
- - 'lib/mongoid/history/options.rb'
101
+ - 'lib/mongoid/history/tracker.rb'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
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
+
1
15
  ### 0.6.1 (2017/01/04)
2
16
 
3
17
  * [#182](https://github.com/mongoid/mongoid-history/pull/182): No-op on repeated calls to destroy - [@msaffitz](https://github.com/msaffitz).
data/Gemfile CHANGED
@@ -18,18 +18,20 @@ when /3/
18
18
  else
19
19
  gem 'mongoid', version
20
20
  end
21
+ gem 'mongoid-compatibility'
21
22
 
22
23
  group :development, :test do
23
- gem 'rake', '< 11.0'
24
24
  gem 'bundler'
25
+ gem 'pry'
26
+ gem 'rake', '< 11.0'
25
27
  end
26
28
 
27
29
  group :test do
30
+ gem 'coveralls'
31
+ gem 'gem-release'
28
32
  gem 'mongoid-danger', '~> 0.1.0', require: false
33
+ gem 'request_store'
29
34
  gem 'rspec', '~> 3.1'
30
- gem 'rubocop', '0.34.1'
35
+ gem 'rubocop', '0.48.1'
31
36
  gem 'yard'
32
- gem 'gem-release'
33
- gem 'coveralls'
34
- gem 'request_store'
35
37
  end
data/README.md CHANGED
@@ -37,8 +37,8 @@ end
37
37
  **Set default tracker class name (Optional)**
38
38
 
39
39
  Mongoid::History will use the first loaded class to include Mongoid::History::Tracker as the
40
- default history tracker. If you are using multiple Tracker classes and would like to set
41
- a global default you may do so in a Rails initializer:
40
+ default history tracker. If you are using multiple Tracker classes, you should set a global
41
+ default in a Rails initializer:
42
42
 
43
43
  ```ruby
44
44
  # config/initializers/mongoid_history.rb
@@ -66,12 +66,13 @@ class Post
66
66
  # telling Mongoid::History how you want to track changes
67
67
  # dynamic fields will be tracked automatically (for MongoId 4.0+ you should include Mongoid::Attributes::Dynamic to your model)
68
68
  track_history :on => [:title, :body], # track title and body fields only, default is :all
69
- :modifier_field => :modifier, # adds "belongs_to :modifier" to track who made the change, default is :modifier
69
+ :modifier_field => :modifier, # adds "belongs_to :modifier" to track who made the change, default is :modifier, set to nil to not create modifier_field
70
70
  :modifier_field_inverse_of => :nil, # adds an ":inverse_of" option to the "belongs_to :modifier" relation, default is not set
71
+ :modifier_field_optional => true, # marks the modifier relationship as optional (requires Mongoid 6 or higher)
71
72
  :version_field => :version, # adds "field :version, :type => Integer" to track current version, default is :version
72
- :track_create => false, # track document creation, default is false
73
- :track_update => true, # track document updates, default is true
74
- :track_destroy => false # track document destruction, default is false
73
+ :track_create => true, # track document creation, default is true
74
+ :track_update => true, # track document updates, default is true
75
+ :track_destroy => true # track document destruction, default is true
75
76
  end
76
77
 
77
78
  class Comment
@@ -429,6 +430,18 @@ Or perhaps you are namespacing to a module:
429
430
  Mongoid::History.modifier_class_name = 'CMS::Author'
430
431
  ```
431
432
 
433
+ **Conditional :if and :unless options**
434
+
435
+ The `track_history` method supports `:if` and `:unless` options which will skip generating
436
+ the history tracker unless they are satisfied. These options can take either a method
437
+ `Symbol` or a `Proc`. They behave identical to how `:if` and `:unless` behave in Rails model callbacks.
438
+
439
+ ```ruby
440
+ track_history on: [:ip],
441
+ if: :should_i_track_history?,
442
+ unless: ->(obj){ obj.method_to_skip_history }
443
+ ```
444
+
432
445
  **Using an alternate changes method**
433
446
 
434
447
  Sometimes you may wish to provide an alternate method for determining which changes should be tracked. For example, if you are using embedded documents
@@ -509,6 +522,57 @@ end
509
522
 
510
523
  For more examples, check out [spec/integration/integration_spec.rb](spec/integration/integration_spec.rb).
511
524
 
525
+ **Multiple Trackers**
526
+
527
+ You can have different trackers for different classes like so.
528
+
529
+ ```
530
+ class First
531
+ include Mongoid::Document
532
+ include Mongoid::History::Trackable
533
+
534
+ field :text, type: String
535
+ track_history on: [:text],
536
+ tracker_class_name: :first_history_tracker
537
+ end
538
+
539
+ class Second
540
+ include Mongoid::Document
541
+ include Mongoid::History::Trackable
542
+
543
+ field :text, type: String
544
+ track_history on: [:text],
545
+ tracker_class_name: :second_history_tracker
546
+ end
547
+
548
+ class FirstHistoryTracker
549
+ include Mongoid::History::Tracker
550
+ end
551
+
552
+ class SecondHistoryTracker
553
+ include Mongoid::History::Tracker
554
+ end
555
+ ```
556
+
557
+ Note that if you are using a tracker for an embedded object that is different
558
+ from the parent's tracker, redos and undos will not work. You have to use the
559
+ same tracker for these to work across embedded relationships.
560
+
561
+ If you are using multiple trackers and the `tracker_class_name` parameter is
562
+ not specified, Mongoid::History will use the default tracker configured in the
563
+ initializer file or whatever the first tracker was loaded.
564
+
565
+
566
+ **Dependent Restrict Associations**
567
+
568
+ When `dependent: :restrict` is used on an association, a call to `destroy` on
569
+ the model will raise `Mongoid::Errors::DeleteRestriction` when the dependency
570
+ is violated. Just be aware that this gem will create a history track document
571
+ before the `destroy` call and then remove if an error is raised. This applies
572
+ to all persistence calls: create, update and destroy.
573
+
574
+ See [spec/integration/validation_failure_spec.rb](spec/integration/validation_failure_spec.rb)
575
+ for examples.
512
576
 
513
577
  **Thread Safety**
514
578
 
data/RELEASING.md ADDED
@@ -0,0 +1,67 @@
1
+ Releasing Mongoid::History
2
+ ========================
3
+
4
+ There're no particular rules about when to release mongoid-history. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
5
+
6
+ ### Release
7
+
8
+ Run tests, check that all tests succeed locally.
9
+
10
+ ```
11
+ bundle install
12
+ bundle exec rake
13
+ ```
14
+
15
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/mongoid/mongoid-history) for all supported platforms.
16
+
17
+ Increment the version, modify [lib/mongoid/history/version.rb](lib/mongoid/history/version.rb).
18
+
19
+ * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.5.1` to `0.5.2`).
20
+ * Increment the second number if the release contains major features or breaking API changes (eg. change `0.5.1` to `0.4.0`).
21
+
22
+ Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
23
+
24
+ ```
25
+ ### 0.4.0 (2014-01-27)
26
+ ```
27
+
28
+ Remove the line with "Your contribution here.", since there will be no more contributions to this release.
29
+
30
+ Commit your changes.
31
+
32
+ ```
33
+ git add CHANGELOG.md lib/mongoid/history/version.rb
34
+ git commit -m "Preparing for release, 0.4.0."
35
+ git push origin master
36
+ ```
37
+
38
+ Release.
39
+
40
+ ```
41
+ $ rake release
42
+
43
+ mongoid-history 0.4.0 built to pkg/mongoid-history-0.4.0.gem.
44
+ Tagged v0.4.0.
45
+ Pushed git commits and tags.
46
+ Pushed mongoid-history 0.4.0 to rubygems.org.
47
+ ```
48
+
49
+ ### Prepare for the Next Version
50
+
51
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
52
+
53
+ ```
54
+ ### 0.4.1 (Next)
55
+
56
+ * Your contribution here.
57
+ ```
58
+
59
+ Increment the minor version, modify [lib/mongoid/history/version.rb](lib/mongoid/history/version.rb).
60
+
61
+ Commit your changes.
62
+
63
+ ```
64
+ git add CHANGELOG.md lib/mongoid/history/version.rb
65
+ git commit -m "Preparing for next release, 0.4.1."
66
+ git push origin master
67
+ ```
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ end
18
18
  require 'rubocop/rake_task'
19
19
  RuboCop::RakeTask.new(:rubocop)
20
20
 
21
- task default: [:rubocop, :spec]
21
+ task default: %i[rubocop spec]
22
22
 
23
23
  require 'yard'
24
24
  YARD::Rake::YardocTask.new
data/UPGRADING.md ADDED
@@ -0,0 +1,34 @@
1
+ ## Upgrading Mongoid History
2
+
3
+ ### Upgrading to 0.8.0
4
+
5
+ #### History is now tracked on create and destroy by default
6
+
7
+ By default, Mongoid History will now track all actions (create, update, and destroy.)
8
+ Previously, only update actions were tracked by default.
9
+
10
+ To preserve the old behavior, please modify your call to `track_history` as follows:
11
+
12
+ ```ruby
13
+ track_history ...
14
+ track_create: false,
15
+ track_destroy: false
16
+ ```
17
+
18
+ See [#207](https://github.com/mongoid/mongoid-history/pull/207) for more information.
19
+
20
+ ### Upgrading to 0.7.0
21
+
22
+ #### Remove history track when create, update or destroy raises an error
23
+
24
+ When an error is raised in a call to create, update or destroy a tracked model, any history track
25
+ created before the call will now be deleted. In the past this was a problem for associations marked
26
+ `dependent: :restrict`.
27
+
28
+ See [#202](https://github.com/mongoid/mongoid-history/pull/202) for more information.
29
+
30
+ # Main Changes / Upgrading Notes
31
+
32
+ See [#189](https://github.com/mongoid/mongoid-history/pull/189) for more information.
33
+
34
+ * Currently, the `:all` option behaves identically to `:fields`. Future versions will track all fields and relations of trackable class when using `:all`.
@@ -40,8 +40,8 @@ module Mongoid
40
40
  rel = aliased_fields.key(rel) || rel
41
41
  @attributes[rel] = [nil,
42
42
  trackable.send(rel)
43
- .reject { |obj| obj.respond_to?(paranoia_field) && obj.public_send(paranoia_field).present? }
44
- .map { |obj| format_embeds_many_relation(rel, obj.attributes) }]
43
+ .reject { |obj| obj.respond_to?(paranoia_field) && obj.public_send(paranoia_field).present? }
44
+ .map { |obj| format_embeds_many_relation(rel, obj.attributes) }]
45
45
  end
46
46
  end
47
47
  end
@@ -14,19 +14,19 @@ module Mongoid
14
14
 
15
15
  def insert_embeds_one_changes
16
16
  trackable_class.tracked_embeds_one
17
- .map { |rel| aliased_fields.key(rel) || rel }
18
- .each do |rel|
19
- obj = trackable.send(rel)
20
- @attributes[rel] = [format_embeds_one_relation(rel, obj.attributes), nil] if obj
21
- end
17
+ .map { |rel| aliased_fields.key(rel) || rel }
18
+ .each do |rel|
19
+ obj = trackable.send(rel)
20
+ @attributes[rel] = [format_embeds_one_relation(rel, obj.attributes), nil] if obj
21
+ end
22
22
  end
23
23
 
24
24
  def insert_embeds_many_changes
25
25
  trackable_class.tracked_embeds_many
26
- .map { |rel| aliased_fields.key(rel) || rel }
27
- .each do |rel|
28
- @attributes[rel] = [trackable.send(rel).map { |obj| format_embeds_many_relation(rel, obj.attributes) }, nil]
29
- end
26
+ .map { |rel| aliased_fields.key(rel) || rel }
27
+ .each do |rel|
28
+ @attributes[rel] = [trackable.send(rel).map { |obj| format_embeds_many_relation(rel, obj.attributes) }, nil]
29
+ end
30
30
  end
31
31
  end
32
32
  end
@@ -10,7 +10,7 @@ module Mongoid
10
10
  elsif trackable_class.tracked_embeds_many?(k)
11
11
  insert_embeds_many_changes(k, v)
12
12
  elsif trackable_class.tracked?(k, :update)
13
- @attributes[k] = format_field(k, v)
13
+ @attributes[k] = format_field(k, v) unless v.all?(&:blank?)
14
14
  end
15
15
  end
16
16
  @attributes
@@ -22,20 +22,22 @@ module Mongoid
22
22
  relation = trackable_class.database_field_name(relation)
23
23
  relation_class = trackable_class.embeds_one_class(relation)
24
24
  paranoia_field = Mongoid::History.trackable_class_settings(relation_class)[:paranoia_field]
25
- @attributes[relation] = []
26
- @attributes[relation][0] = value[0][paranoia_field].present? ? {} : format_embeds_one_relation(relation, value[0])
27
- @attributes[relation][1] = value[1][paranoia_field].present? ? {} : format_embeds_one_relation(relation, value[1])
25
+ original_value = value[0][paranoia_field].present? ? {} : format_embeds_one_relation(relation, value[0])
26
+ modified_value = value[1][paranoia_field].present? ? {} : format_embeds_one_relation(relation, value[1])
27
+ return if original_value == modified_value
28
+ @attributes[relation] = [original_value, modified_value]
28
29
  end
29
30
 
30
31
  def insert_embeds_many_changes(relation, value)
31
32
  relation = trackable_class.database_field_name(relation)
32
33
  relation_class = trackable_class.embeds_many_class(relation)
33
34
  paranoia_field = Mongoid::History.trackable_class_settings(relation_class)[:paranoia_field]
34
- @attributes[relation] = []
35
- @attributes[relation][0] = value[0].reject { |rel| rel[paranoia_field].present? }
36
- .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) }
37
- @attributes[relation][1] = value[1].reject { |rel| rel[paranoia_field].present? }
38
- .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) }
35
+ original_value = value[0].reject { |rel| rel[paranoia_field].present? }
36
+ .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) }
37
+ modified_value = value[1].reject { |rel| rel[paranoia_field].present? }
38
+ .map { |v_attrs| format_embeds_many_relation(relation, v_attrs) }
39
+ return if original_value == modified_value
40
+ @attributes[relation] = [original_value, modified_value]
39
41
  end
40
42
  end
41
43
  end
@@ -3,20 +3,22 @@ module Mongoid
3
3
  class Options
4
4
  attr_reader :trackable, :options
5
5
 
6
- def initialize(trackable)
6
+ def initialize(trackable, opts = {})
7
7
  @trackable = trackable
8
+ @options = default_options.merge(opts)
8
9
  end
9
10
 
10
11
  def scope
11
12
  trackable.collection_name.to_s.singularize.to_sym
12
13
  end
13
14
 
14
- def parse(options = {})
15
- @options = default_options.merge(options)
16
- prepare_skipped_fields
17
- prepare_formatted_fields
18
- parse_tracked_fields_and_relations
19
- @options
15
+ def prepared
16
+ @prepared ||= begin
17
+ prepare_skipped_fields
18
+ prepare_formatted_fields
19
+ parse_tracked_fields_and_relations
20
+ options
21
+ end
20
22
  end
21
23
 
22
24
  private
@@ -24,15 +26,15 @@ module Mongoid
24
26
  def default_options
25
27
  @default_options ||=
26
28
  { on: :all,
27
- except: [:created_at, :updated_at],
29
+ except: %i[created_at updated_at],
28
30
  tracker_class_name: nil,
29
31
  modifier_field: :modifier,
30
32
  version_field: :version,
31
33
  changes_method: :changes,
32
34
  scope: scope,
33
- track_create: false,
35
+ track_create: true,
34
36
  track_update: true,
35
- track_destroy: false,
37
+ track_destroy: true,
36
38
  format: nil }
37
39
  end
38
40
 
@@ -76,14 +78,7 @@ module Mongoid
76
78
  # when `[:foo, { posts: [:id, :title] }]`, then return as is
77
79
  @options[:on] = Array(options[:on])
78
80
 
79
- # # :all is just an alias to :fields for now, to support existing users of `mongoid-history`
80
- # # In future, :all will track all the fields and relations of trackable class
81
- if options[:on].include?(:all)
82
- warn "[DEPRECATION] Use :fields instead of :all to track all fields in class #{trackable}.\n\
83
- Going forward, :all will track all the fields and relations for the class"
84
- end
85
-
86
- @options[:on] = options[:on].map { |opt| (opt == :all) ? :fields : opt }
81
+ @options[:on] = options[:on].map { |opt| opt == :all ? :fields : opt }
87
82
 
88
83
  if options[:on].include?(:fields)
89
84
  @options[:on] = options[:on].reject { |opt| opt == :fields }
@@ -163,7 +158,7 @@ module Mongoid
163
158
  @options[:relations][:embeds_one][field] = if field_options.blank?
164
159
  relation_class.fields.keys
165
160
  else
166
- %w(_id) | field_options.map { |opt| relation_class.database_field_name(opt) }
161
+ %w[_id] | field_options.map { |opt| relation_class.database_field_name(opt) }
167
162
  end
168
163
  end
169
164
 
@@ -172,7 +167,7 @@ module Mongoid
172
167
  @options[:relations][:embeds_many][field] = if field_options.blank?
173
168
  relation_class.fields.keys
174
169
  else
175
- %w(_id) | field_options.map { |opt| relation_class.database_field_name(opt) }
170
+ %w[_id] | field_options.map { |opt| relation_class.database_field_name(opt) }
176
171
  end
177
172
  end
178
173