mongoid-history 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module Mongoid
19
19
  index(scope: 1)
20
20
  index(association_chain: 1)
21
21
 
22
- Mongoid::History.tracker_class_name = name.tableize.singularize.to_sym
22
+ Mongoid::History.tracker_class_name ||= name.tableize.singularize.to_sym
23
23
  end
24
24
 
25
25
  def undo!(modifier = nil)
@@ -180,7 +180,7 @@ module Mongoid
180
180
  elsif trackable_parent.class.embeds_many?(name)
181
181
  trackable_parent.get_embedded(name).create!(localize_keys(original))
182
182
  else
183
- fail 'This should never happen. Please report bug!'
183
+ raise 'This should never happen. Please report bug!'
184
184
  end
185
185
  end
186
186
 
@@ -205,7 +205,7 @@ module Mongoid
205
205
  elsif doc.class.embeds_many?(name)
206
206
  doc.get_embedded(name).unscoped.where(_id: node['id']).first
207
207
  else
208
- fail 'This should never happen. Please report bug.'
208
+ raise 'This should never happen. Please report bug.'
209
209
  end
210
210
  documents << doc
211
211
  break if chain.empty?
@@ -215,9 +215,11 @@ module Mongoid
215
215
 
216
216
  def localize_keys(hash)
217
217
  klass = association_chain.first['name'].constantize
218
- klass.localized_fields.keys.each do |name|
219
- hash["#{name}_translations"] = hash.delete(name) if hash[name].present?
220
- end if klass.respond_to?(:localized_fields)
218
+ if klass.respond_to?(:localized_fields)
219
+ klass.localized_fields.keys.each do |name|
220
+ hash["#{name}_translations"] = hash.delete(name) if hash[name].present?
221
+ end
222
+ end
221
223
  hash
222
224
  end
223
225
 
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module History
3
- VERSION = '0.6.1'
3
+ VERSION = '0.7.0'.freeze
4
4
  end
5
5
  end
@@ -68,7 +68,7 @@ describe Mongoid::History::Tracker do
68
68
  track_create: true, # track document creation, default is false
69
69
  track_update: true, # track document updates, default is true
70
70
  track_destroy: false, # track document destruction, default is false
71
- scope: [:real_state, :company]
71
+ scope: %i[real_state company]
72
72
  end
73
73
 
74
74
  class User
@@ -18,7 +18,7 @@ describe Mongoid::History do
18
18
 
19
19
  accepts_nested_attributes_for :tags, allow_destroy: true
20
20
 
21
- track_history on: [:title, :body], track_destroy: true
21
+ track_history on: %i[title body], track_destroy: true
22
22
  end
23
23
 
24
24
  class Comment
@@ -29,7 +29,7 @@ describe Mongoid::History do
29
29
  field :t, as: :title
30
30
  field :body
31
31
  embedded_in :commentable, polymorphic: true
32
- track_history on: [:title, :body], scope: :post, track_create: true, track_destroy: true
32
+ track_history on: %i[title body], scope: :post, track_create: true, track_destroy: true
33
33
  end
34
34
 
35
35
  class Section
@@ -54,7 +54,7 @@ describe Mongoid::History do
54
54
  field :city
55
55
  field :country
56
56
  field :aliases, type: Array
57
- track_history except: [:email, :updated_at]
57
+ track_history except: %i[email updated_at]
58
58
  end
59
59
 
60
60
  class Tag
@@ -229,14 +229,14 @@ describe Mongoid::History do
229
229
 
230
230
  it 'should track array changes' do
231
231
  aliases = user.aliases
232
- user.update_attributes(aliases: %w(bob joe))
232
+ user.update_attributes(aliases: %w[bob joe])
233
233
  expect(user.history_tracks.first.original['aliases']).to eq(aliases)
234
234
  expect(user.history_tracks.first.modified['aliases']).to eq(user.aliases)
235
235
  end
236
236
 
237
237
  it 'should undo array changes' do
238
238
  aliases = user.aliases
239
- user.update_attributes(aliases: %w(bob joe))
239
+ user.update_attributes(aliases: %w[bob joe])
240
240
  user.history_tracks.first.undo! nil
241
241
  expect(user.reload.aliases).to eq(aliases)
242
242
  end
@@ -323,12 +323,12 @@ describe Mongoid::History do
323
323
  expect(subject[:array]).to eq({ aliases: { remove: ['bob'], add: ['', 'bill', 'james'] } }.with_indifferent_access)
324
324
  end
325
325
  it 'should not track unmodified field' do
326
- %w(add modify remove array).each do |edit|
326
+ %w[add modify remove array].each do |edit|
327
327
  expect(subject[edit][:address]).to be_nil
328
328
  end
329
329
  end
330
330
  it 'should not track untracked fields' do
331
- %w(add modify remove array).each do |edit|
331
+ %w[add modify remove array].each do |edit|
332
332
  expect(subject[edit][:email]).to be_nil
333
333
  end
334
334
  end
@@ -639,7 +639,7 @@ describe Mongoid::History do
639
639
  describe 'undo' do
640
640
  { 'undo' => [nil], 'undo!' => [nil, :reload] }.each do |test_method, methods|
641
641
  methods.each do |method|
642
- context "#{method || 'instance'}" do
642
+ context (method || 'instance').to_s do
643
643
  it 'recognizes :from, :to options' do
644
644
  comment.send test_method, user, from: 4, to: 2
645
645
  comment.send(method) if method
@@ -694,7 +694,7 @@ describe Mongoid::History do
694
694
 
695
695
  describe 'redo' do
696
696
  [nil, :reload].each do |method|
697
- context "#{method || 'instance'}" do
697
+ context (method || 'instance').to_s do
698
698
  before :each do
699
699
  comment.update_attributes(title: 'Test5')
700
700
  end
@@ -919,7 +919,7 @@ describe Mongoid::History do
919
919
  track_history on: [:foo], changes_method: :my_changes
920
920
 
921
921
  def my_changes
922
- { foo: %w(bar baz) }
922
+ { foo: %w[bar baz] }
923
923
  end
924
924
  end
925
925
  end
@@ -10,7 +10,7 @@ describe Mongoid::History::Tracker do
10
10
  belongs_to :user, inverse_of: :models
11
11
  has_and_belongs_to_many :external_users, class_name: 'User', inverse_of: :external_models
12
12
 
13
- track_history on: [:name, :user, :external_user_ids], # track title and body fields only, default is :all
13
+ track_history on: %i[name user external_user_ids], # track title and body fields only, default is :all
14
14
  modifier_field: :modifier, # adds "referenced_in :modifier" to track who made the change, default is :modifier
15
15
  modifier_field_inverse_of: nil, # no inverse modifier relationship
16
16
  version_field: :version, # adds "field :version, :type => Integer" to track current version, default is :version
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::History do
4
+ before :all do
5
+ Mongoid::History.tracker_class_name = nil
6
+
7
+ module MultipleTrackersSpec
8
+ class First
9
+ include Mongoid::Document
10
+ include Mongoid::History::Trackable
11
+
12
+ field :text, type: String
13
+ track_history on: [:text],
14
+ track_create: true,
15
+ track_update: true,
16
+ track_destroy: true,
17
+ tracker_class_name: :first_history_tracker
18
+ end
19
+
20
+ class Second
21
+ include Mongoid::Document
22
+ include Mongoid::History::Trackable
23
+
24
+ field :text, type: String
25
+ track_history on: [:text],
26
+ track_create: true,
27
+ track_update: true,
28
+ track_destroy: true,
29
+ tracker_class_name: :second_history_tracker
30
+ end
31
+ end
32
+
33
+ class FirstHistoryTracker
34
+ include Mongoid::History::Tracker
35
+ end
36
+
37
+ class SecondHistoryTracker
38
+ include Mongoid::History::Tracker
39
+ end
40
+ end
41
+
42
+ it 'should be possible to have different trackers for each class' do
43
+ expect(FirstHistoryTracker.count).to eq(0)
44
+ expect(SecondHistoryTracker.count).to eq(0)
45
+ expect(MultipleTrackersSpec::First.tracker_class).to be FirstHistoryTracker
46
+ expect(MultipleTrackersSpec::Second.tracker_class).to be SecondHistoryTracker
47
+
48
+ foo = MultipleTrackersSpec::First.new
49
+ foo.save
50
+
51
+ bar = MultipleTrackersSpec::Second.new
52
+ bar.save
53
+
54
+ expect(FirstHistoryTracker.count).to eq 1
55
+ expect(SecondHistoryTracker.count).to eq 1
56
+
57
+ foo.text = "I'm foo"
58
+ foo.save
59
+ bar.text = "I'm bar"
60
+ bar.save
61
+
62
+ expect(FirstHistoryTracker.count).to eq 2
63
+ expect(SecondHistoryTracker.count).to eq 2
64
+
65
+ foo.destroy
66
+ bar.destroy
67
+
68
+ expect(FirstHistoryTracker.count).to eq 3
69
+ expect(SecondHistoryTracker.count).to eq 3
70
+ end
71
+ end
@@ -48,7 +48,7 @@ describe Mongoid::History::Tracker do
48
48
  track_create: true,
49
49
  track_update: true,
50
50
  track_destroy: true,
51
- scope: [:modelone, :modeltwo]
51
+ scope: %i[modelone modeltwo]
52
52
  end
53
53
 
54
54
  class EmbeddedTwo
@@ -64,7 +64,7 @@ describe Mongoid::History::Tracker do
64
64
  track_create: true,
65
65
  track_update: true,
66
66
  track_destroy: true,
67
- scope: [:modelone, :modeltwo]
67
+ scope: %i[modelone modeltwo]
68
68
  end
69
69
 
70
70
  class User
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::History::Tracker do
4
+ before :all do
5
+ class Element
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+ include Mongoid::History::Trackable
9
+
10
+ field :title
11
+ field :body
12
+
13
+ validates :title, presence: true
14
+
15
+ has_many :items, dependent: :restrict
16
+
17
+ track_history on: [:body], track_create: true, track_update: true, track_destroy: true
18
+ end
19
+
20
+ class Item
21
+ include Mongoid::Document
22
+ include Mongoid::Timestamps
23
+
24
+ belongs_to :element
25
+ end
26
+
27
+ class Prompt < Element
28
+ end
29
+
30
+ @persisted_history_options = Mongoid::History.trackable_class_options
31
+ end
32
+
33
+ before(:each) { Mongoid::History.trackable_class_options = @persisted_history_options }
34
+
35
+ it 'does not track delete when parent class validation fails' do
36
+ prompt = Prompt.new(title: 'first')
37
+ expect { prompt.save! }.to change(Tracker, :count).by(1)
38
+ expect do
39
+ expect { prompt.update_attributes!(title: nil, body: 'one') }
40
+ .to raise_error(Mongoid::Errors::Validations)
41
+ end.to change(Tracker, :count).by(0)
42
+ end
43
+
44
+ it 'does not track delete when parent class restrict dependency fails' do
45
+ prompt = Prompt.new(title: 'first')
46
+ prompt.items << Item.new
47
+ expect { prompt.save! }.to change(Tracker, :count).by(1)
48
+ expect(prompt.version).to eq(1)
49
+ expect do
50
+ expect { prompt.destroy }.to raise_error(Mongoid::Errors::DeleteRestriction)
51
+ end.to change(Tracker, :count).by(0)
52
+ end
53
+
54
+ it 'does not track delete when restrict dependency fails' do
55
+ elem = Element.new(title: 'first')
56
+ elem.items << Item.new
57
+ expect { elem.save! }.to change(Tracker, :count).by(1)
58
+ expect(elem.version).to eq(1)
59
+ expect do
60
+ expect { elem.destroy }.to raise_error(Mongoid::Errors::DeleteRestriction)
61
+ end.to change(Tracker, :count).by(0)
62
+ end
63
+ end
@@ -19,7 +19,7 @@ RSpec.configure do |config|
19
19
  config.raise_errors_for_deprecations!
20
20
  config.before :all do
21
21
  Mongoid.logger.level = Logger::INFO
22
- Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5?
22
+ Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6?
23
23
  Mongoid.belongs_to_required_by_default = false if Mongoid::Compatibility::Version.mongoid6?
24
24
  end
25
25
  end
@@ -108,7 +108,7 @@ describe Mongoid::History::Attributes::Base do
108
108
 
109
109
  context 'with permitted attributes' do
110
110
  before do
111
- model_one.track_history on: { model_two: %i(foo) }
111
+ model_one.track_history on: { model_two: %i[foo] }
112
112
  end
113
113
 
114
114
  it 'should select only permitted attributes' do
@@ -119,7 +119,7 @@ describe Mongoid::History::Attributes::Base do
119
119
 
120
120
  context 'with attributes formatted via string' do
121
121
  before do
122
- model_one.track_history on: { model_two: %i(foo) }, format: { model_two: { foo: '&%s&' } }
122
+ model_one.track_history on: { model_two: %i[foo] }, format: { model_two: { foo: '&%s&' } }
123
123
  end
124
124
 
125
125
  it 'should select obfuscate permitted attributes' do
@@ -130,7 +130,7 @@ describe Mongoid::History::Attributes::Base do
130
130
 
131
131
  context 'with attributes formatted via proc' do
132
132
  before do
133
- model_one.track_history on: { model_two: %i(foo) }, format: { model_two: { foo: ->(v) { v.to_s * 2 } } }
133
+ model_one.track_history on: { model_two: %i[foo] }, format: { model_two: { foo: ->(v) { v.to_s * 2 } } }
134
134
  end
135
135
 
136
136
  it 'should select obfuscate permitted attributes' do
@@ -45,7 +45,7 @@ describe Mongoid::History::Trackable do
45
45
  embedded_in :model_one
46
46
  end
47
47
 
48
- ModelOne.track_history(on: %i(foo emb_one emb_threes))
48
+ ModelOne.track_history(on: %i[foo emb_one emb_threes])
49
49
  @persisted_history_options = Mongoid::History.trackable_class_options
50
50
  end
51
51
  before(:each) { Mongoid::History.trackable_class_options = @persisted_history_options }
@@ -61,7 +61,7 @@ describe Mongoid::History::Options do
61
61
  describe '#default_options' do
62
62
  let(:expected_options) do
63
63
  { on: :all,
64
- except: [:created_at, :updated_at],
64
+ except: %i[created_at updated_at],
65
65
  tracker_class_name: nil,
66
66
  modifier_field: :modifier,
67
67
  version_field: :version,
@@ -81,27 +81,27 @@ describe Mongoid::History::Options do
81
81
 
82
82
  context 'with field' do
83
83
  let(:value) { :foo }
84
- it { expect(subject[:except]).to eq %w(foo) }
84
+ it { expect(subject[:except]).to eq %w[foo] }
85
85
  end
86
86
 
87
87
  context 'with array of fields' do
88
- let(:value) { %i(foo) }
89
- it { expect(subject[:except]).to eq %w(foo) }
88
+ let(:value) { %i[foo] }
89
+ it { expect(subject[:except]).to eq %w[foo] }
90
90
  end
91
91
 
92
92
  context 'with field alias' do
93
- let(:value) { %i(foo bar) }
94
- it { expect(subject[:except]).to eq %w(foo b) }
93
+ let(:value) { %i[foo bar] }
94
+ it { expect(subject[:except]).to eq %w[foo b] }
95
95
  end
96
96
 
97
97
  context 'with duplicate values' do
98
- let(:value) { %i(foo bar b) }
99
- it { expect(subject[:except]).to eq %w(foo b) }
98
+ let(:value) { %i[foo bar b] }
99
+ it { expect(subject[:except]).to eq %w[foo b] }
100
100
  end
101
101
 
102
102
  context 'with blank values' do
103
- let(:value) { %i(foo) | [nil] }
104
- it { expect(subject[:except]).to eq %w(foo) }
103
+ let(:value) { %i[foo] | [nil] }
104
+ it { expect(subject[:except]).to eq %w[foo] }
105
105
  end
106
106
  end
107
107
 
@@ -128,8 +128,8 @@ describe Mongoid::History::Options do
128
128
  describe '#parse_tracked_fields_and_relations' do
129
129
  context 'when options not passed' do
130
130
  let(:expected_options) do
131
- { on: %i(foo b),
132
- except: %w(created_at updated_at),
131
+ { on: %i[foo b],
132
+ except: %w[created_at updated_at],
133
133
  tracker_class_name: nil,
134
134
  modifier_field: :modifier,
135
135
  version_field: :version,
@@ -138,7 +138,7 @@ describe Mongoid::History::Options do
138
138
  track_create: false,
139
139
  track_update: true,
140
140
  track_destroy: false,
141
- fields: %w(foo b),
141
+ fields: %w[foo b],
142
142
  dynamic: [],
143
143
  relations: { embeds_one: {}, embeds_many: {} },
144
144
  format: {} }
@@ -154,114 +154,114 @@ describe Mongoid::History::Options do
154
154
 
155
155
  context 'with field' do
156
156
  let(:value) { :foo }
157
- it { expect(subject[:on]).to eq %i(foo) }
158
- it { expect(subject[:fields]).to eq %w(foo) }
157
+ it { expect(subject[:on]).to eq %i[foo] }
158
+ it { expect(subject[:fields]).to eq %w[foo] }
159
159
  end
160
160
 
161
161
  context 'with array of fields' do
162
- let(:value) { %i(foo) }
163
- it { expect(subject[:on]).to eq %i(foo) }
164
- it { expect(subject[:fields]).to eq %w(foo) }
162
+ let(:value) { %i[foo] }
163
+ it { expect(subject[:on]).to eq %i[foo] }
164
+ it { expect(subject[:fields]).to eq %w[foo] }
165
165
  end
166
166
 
167
167
  context 'with embeds_one relation attributes' do
168
- let(:value) { { emb_one: %i(f_em_foo) } }
169
- it { expect(subject[:on]).to eq [[:emb_one, %i(f_em_foo)]] }
168
+ let(:value) { { emb_one: %i[f_em_foo] } }
169
+ it { expect(subject[:on]).to eq [[:emb_one, %i[f_em_foo]]] }
170
170
  end
171
171
 
172
172
  context 'with fields and embeds_one relation attributes' do
173
- let(:value) { [:foo, emb_one: %i(f_em_foo)] }
174
- it { expect(subject[:on]).to eq [:foo, emb_one: %i(f_em_foo)] }
173
+ let(:value) { [:foo, emb_one: %i[f_em_foo]] }
174
+ it { expect(subject[:on]).to eq [:foo, emb_one: %i[f_em_foo]] }
175
175
  end
176
176
 
177
177
  context 'with :all' do
178
178
  let(:value) { :all }
179
- it { expect(subject[:on]).to eq %i(foo b) }
179
+ it { expect(subject[:on]).to eq %i[foo b] }
180
180
  end
181
181
 
182
182
  context 'with :fields' do
183
183
  let(:value) { :fields }
184
- it { expect(subject[:on]).to eq %i(foo b) }
184
+ it { expect(subject[:on]).to eq %i[foo b] }
185
185
  end
186
186
 
187
187
  describe '#categorize_tracked_option' do
188
188
  context 'with skipped field' do
189
- let(:options) { { on: %i(foo bar), except: :foo } }
190
- it { expect(subject[:fields]).to eq %w(b) }
189
+ let(:options) { { on: %i[foo bar], except: :foo } }
190
+ it { expect(subject[:fields]).to eq %w[b] }
191
191
  end
192
192
 
193
193
  context 'with skipped embeds_one relation' do
194
- let(:options) { { on: %i(fields emb_one emb_two), except: :emb_one } }
195
- it { expect(subject[:relations][:embeds_one]).to eq('emtw' => %w(_id f_em_baz)) }
194
+ let(:options) { { on: %i[fields emb_one emb_two], except: :emb_one } }
195
+ it { expect(subject[:relations][:embeds_one]).to eq('emtw' => %w[_id f_em_baz]) }
196
196
  end
197
197
 
198
198
  context 'with skipped embeds_many relation' do
199
- let(:options) { { on: %i(fields emb_threes emb_fours), except: :emb_threes } }
200
- it { expect(subject[:relations][:embeds_many]).to eq('emfs' => %w(_id f_em_baz)) }
199
+ let(:options) { { on: %i[fields emb_threes emb_fours], except: :emb_threes } }
200
+ it { expect(subject[:relations][:embeds_many]).to eq('emfs' => %w[_id f_em_baz]) }
201
201
  end
202
202
 
203
203
  context 'with reserved field' do
204
- let(:options) { { on: %i(_id _type foo deleted_at) } }
205
- it { expect(subject[:fields]).to eq %w(foo) }
204
+ let(:options) { { on: %i[_id _type foo deleted_at] } }
205
+ it { expect(subject[:fields]).to eq %w[foo] }
206
206
  end
207
207
 
208
208
  context 'when embeds_one attribute passed' do
209
209
  let(:options) { { on: { emb_one: :f_em_foo } } }
210
- it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w(_id f_em_foo)) }
210
+ it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w[_id f_em_foo]) }
211
211
  end
212
212
 
213
213
  context 'when embeds_one attributes array passed' do
214
- let(:options) { { on: { emb_one: %i(f_em_foo) } } }
215
- it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w(_id f_em_foo)) }
214
+ let(:options) { { on: { emb_one: %i[f_em_foo] } } }
215
+ it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w[_id f_em_foo]) }
216
216
  end
217
217
 
218
218
  context 'when embeds_many attribute passed' do
219
219
  let(:options) { { on: { emb_threes: :f_em_foo } } }
220
- it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w(_id f_em_foo)) }
220
+ it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w[_id f_em_foo]) }
221
221
  end
222
222
 
223
223
  context 'when embeds_many attributes array passed' do
224
- let(:options) { { on: { emb_threes: %i(f_em_foo) } } }
225
- it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w(_id f_em_foo)) }
224
+ let(:options) { { on: { emb_threes: %i[f_em_foo] } } }
225
+ it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w[_id f_em_foo]) }
226
226
  end
227
227
 
228
228
  context 'when embeds_one attributes not passed' do
229
229
  let(:options) { { on: :emb_one } }
230
- it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w(_id f_em_foo fmb)) }
230
+ it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w[_id f_em_foo fmb]) }
231
231
  end
232
232
 
233
233
  context 'when embeds_many attributes not passed' do
234
234
  let(:options) { { on: :emb_threes } }
235
- it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w(_id f_em_foo fmb)) }
235
+ it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w[_id f_em_foo fmb]) }
236
236
  end
237
237
 
238
238
  context 'when embeds_one attribute alias passed' do
239
- let(:options) { { on: { emb_one: %i(f_em_bar) } } }
240
- it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w(_id fmb)) }
239
+ let(:options) { { on: { emb_one: %i[f_em_bar] } } }
240
+ it { expect(subject[:relations][:embeds_one]).to eq('emb_one' => %w[_id fmb]) }
241
241
  end
242
242
 
243
243
  context 'when embeds_many attribute alias passed' do
244
- let(:options) { { on: { emb_threes: %i(f_em_bar) } } }
245
- it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w(_id fmb)) }
244
+ let(:options) { { on: { emb_threes: %i[f_em_bar] } } }
245
+ it { expect(subject[:relations][:embeds_many]).to eq('emb_threes' => %w[_id fmb]) }
246
246
  end
247
247
 
248
248
  context 'with field alias' do
249
249
  let(:options) { { on: :bar } }
250
- it { expect(subject[:fields]).to eq %w(b) }
250
+ it { expect(subject[:fields]).to eq %w[b] }
251
251
  end
252
252
 
253
253
  context 'with dynamic field name' do
254
254
  let(:options) { { on: :my_field } }
255
- it { expect(subject[:dynamic]).to eq %w(my_field) }
255
+ it { expect(subject[:dynamic]).to eq %w[my_field] }
256
256
  end
257
257
 
258
258
  context 'with relations' do
259
259
  let(:options) { { on: :embedded_relations } }
260
260
  it do
261
- expect(subject[:relations]).to eq(embeds_many: { 'emb_threes' => %w(_id f_em_foo fmb),
262
- 'emfs' => %w(_id f_em_baz) },
263
- embeds_one: { 'emb_one' => %w(_id f_em_foo fmb),
264
- 'emtw' => %w(_id f_em_baz) })
261
+ expect(subject[:relations]).to eq(embeds_many: { 'emb_threes' => %w[_id f_em_foo fmb],
262
+ 'emfs' => %w[_id f_em_baz] },
263
+ embeds_one: { 'emb_one' => %w[_id f_em_foo fmb],
264
+ 'emtw' => %w[_id f_em_baz] })
265
265
  end
266
266
  end
267
267
  end
@@ -308,8 +308,8 @@ describe Mongoid::History::Options do
308
308
  end
309
309
 
310
310
  describe '#remove_reserved_fields' do
311
- let(:options) { { on: [:_id, :_type, :foo, :version, :modifier_id] } }
312
- it { expect(subject[:fields]).to eq %w(foo) }
311
+ let(:options) { { on: %i[_id _type foo version modifier_id] } }
312
+ it { expect(subject[:fields]).to eq %w[foo] }
313
313
  it { expect(subject[:dynamic]).to eq [] }
314
314
  end
315
315
  end