mongoid-history 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,7 +62,7 @@ describe Mongoid::History do
62
62
  # include Mongoid::Timestamps (see: https://github.com/mongoid/mongoid/issues/3078)
63
63
  include Mongoid::History::Trackable
64
64
 
65
- belongs_to :updated_by, class_name: "User"
65
+ belongs_to :updated_by, class_name: 'User'
66
66
 
67
67
  field :title
68
68
  track_history on: [:title], scope: :post, track_create: true, track_destroy: true, modifier_field: :updated_by
@@ -75,348 +75,348 @@ describe Mongoid::History do
75
75
  end
76
76
 
77
77
  before(:each) { Mongoid::History.trackable_class_options = @persisted_history_options }
78
- let(:user) { User.create(name: "Aaron", email: "aaron@randomemail.com", aliases: ['bob'], country: 'Canada', city: 'Toronto', address: '21 Jump Street') }
79
- let(:another_user) { User.create(name: "Another Guy", email: "anotherguy@randomemail.com") }
80
- let(:post) { Post.create(title: "Test", body: "Post", modifier: user, views: 100) }
81
- let(:comment) { post.comments.create(title: "test", body: "comment", modifier: user) }
82
- let(:tag) { Tag.create(title: "test") }
78
+ let(:user) { User.create(name: 'Aaron', email: 'aaron@randomemail.com', aliases: ['bob'], country: 'Canada', city: 'Toronto', address: '21 Jump Street') }
79
+ let(:another_user) { User.create(name: 'Another Guy', email: 'anotherguy@randomemail.com') }
80
+ let(:post) { Post.create(title: 'Test', body: 'Post', modifier: user, views: 100) }
81
+ let(:comment) { post.comments.create(title: 'test', body: 'comment', modifier: user) }
82
+ let(:tag) { Tag.create(title: 'test') }
83
83
 
84
- describe "track" do
85
- describe "on creation" do
86
- it "should have one history track in comment" do
87
- comment.history_tracks.count.should == 1
84
+ describe 'track' do
85
+ describe 'on creation' do
86
+ it 'should have one history track in comment' do
87
+ expect(comment.history_tracks.count).to eq(1)
88
88
  end
89
89
 
90
- it "should assign title and body on modified" do
91
- comment.history_tracks.first.modified.should == { 't' => "test", 'body' => "comment" }
90
+ it 'should assign title and body on modified' do
91
+ expect(comment.history_tracks.first.modified).to eq('t' => 'test', 'body' => 'comment')
92
92
  end
93
93
 
94
- it "should not assign title and body on original" do
95
- comment.history_tracks.first.original.should == {}
94
+ it 'should not assign title and body on original' do
95
+ expect(comment.history_tracks.first.original).to eq({})
96
96
  end
97
97
 
98
- it "should assign modifier" do
99
- comment.history_tracks.first.modifier.should == user
98
+ it 'should assign modifier' do
99
+ expect(comment.history_tracks.first.modifier).to eq(user)
100
100
  end
101
101
 
102
- it "should assign version" do
103
- comment.history_tracks.first.version.should == 1
102
+ it 'should assign version' do
103
+ expect(comment.history_tracks.first.version).to eq(1)
104
104
  end
105
105
 
106
- it "should assign scope" do
107
- comment.history_tracks.first.scope.should == "post"
106
+ it 'should assign scope' do
107
+ expect(comment.history_tracks.first.scope).to eq('post')
108
108
  end
109
109
 
110
- it "should assign method" do
111
- comment.history_tracks.first.action.should == "create"
110
+ it 'should assign method' do
111
+ expect(comment.history_tracks.first.action).to eq('create')
112
112
  end
113
113
 
114
- it "should assign association_chain" do
114
+ it 'should assign association_chain' do
115
115
  expected = [
116
- { 'id' => post.id, 'name' => "Post" },
117
- { 'id' => comment.id, 'name' => "coms" }
116
+ { 'id' => post.id, 'name' => 'Post' },
117
+ { 'id' => comment.id, 'name' => 'coms' }
118
118
  ]
119
- comment.history_tracks.first.association_chain.should == expected
119
+ expect(comment.history_tracks.first.association_chain).to eq(expected)
120
120
  end
121
121
  end
122
122
 
123
- describe "on destruction" do
124
- it "should have two history track records in post" do
125
- lambda {
123
+ describe 'on destruction' do
124
+ it 'should have two history track records in post' do
125
+ expect do
126
126
  post.destroy
127
- }.should change(Tracker, :count).by(1)
127
+ end.to change(Tracker, :count).by(1)
128
128
  end
129
129
 
130
- it "should assign destroy on track record" do
130
+ it 'should assign destroy on track record' do
131
131
  post.destroy
132
- post.history_tracks.last.action.should == "destroy"
132
+ expect(post.history_tracks.last.action).to eq('destroy')
133
133
  end
134
134
 
135
- it "should return affected attributes from track record" do
135
+ it 'should return affected attributes from track record' do
136
136
  post.destroy
137
- post.history_tracks.last.affected["title"].should == "Test"
137
+ expect(post.history_tracks.last.affected['title']).to eq('Test')
138
138
  end
139
139
  end
140
140
 
141
- describe "on update non-embedded" do
142
- it "should create a history track if changed attributes match tracked attributes" do
143
- lambda {
144
- post.update_attributes(title: "Another Test")
145
- }.should change(Tracker, :count).by(1)
141
+ describe 'on update non-embedded' do
142
+ it 'should create a history track if changed attributes match tracked attributes' do
143
+ expect do
144
+ post.update_attributes(title: 'Another Test')
145
+ end.to change(Tracker, :count).by(1)
146
146
  end
147
147
 
148
- it "should not create a history track if changed attributes do not match tracked attributes" do
149
- lambda {
150
- post.update_attributes(rating: "untracked")
151
- }.should change(Tracker, :count).by(0)
148
+ it 'should not create a history track if changed attributes do not match tracked attributes' do
149
+ expect do
150
+ post.update_attributes(rating: 'untracked')
151
+ end.to change(Tracker, :count).by(0)
152
152
  end
153
153
 
154
- it "should assign modified fields" do
155
- post.update_attributes(title: "Another Test")
156
- post.history_tracks.last.modified.should == {
157
- "title" => "Another Test"
158
- }
154
+ it 'should assign modified fields' do
155
+ post.update_attributes(title: 'Another Test')
156
+ expect(post.history_tracks.last.modified).to eq(
157
+ 'title' => 'Another Test'
158
+ )
159
159
  end
160
160
 
161
- it "should assign method field" do
162
- post.update_attributes(title: "Another Test")
163
- post.history_tracks.last.action.should == "update"
161
+ it 'should assign method field' do
162
+ post.update_attributes(title: 'Another Test')
163
+ expect(post.history_tracks.last.action).to eq('update')
164
164
  end
165
165
 
166
- it "should assign original fields" do
167
- post.update_attributes(title: "Another Test")
168
- post.history_tracks.last.original.should == {
169
- "title" => "Test"
170
- }
166
+ it 'should assign original fields' do
167
+ post.update_attributes(title: 'Another Test')
168
+ expect(post.history_tracks.last.original).to eq(
169
+ 'title' => 'Test'
170
+ )
171
171
  end
172
172
 
173
- it "should assign modifier" do
174
- post.update_attributes(title: "Another Test")
175
- post.history_tracks.first.modifier.should == user
173
+ it 'should assign modifier' do
174
+ post.update_attributes(title: 'Another Test')
175
+ expect(post.history_tracks.first.modifier).to eq(user)
176
176
  end
177
177
 
178
- it "should assign version on history tracks" do
179
- post.update_attributes(title: "Another Test")
180
- post.history_tracks.first.version.should == 1
178
+ it 'should assign version on history tracks' do
179
+ post.update_attributes(title: 'Another Test')
180
+ expect(post.history_tracks.first.version).to eq(1)
181
181
  end
182
182
 
183
- it "should assign version on post" do
184
- post.update_attributes(title: "Another Test")
185
- post.version.should == 1
183
+ it 'should assign version on post' do
184
+ post.update_attributes(title: 'Another Test')
185
+ expect(post.version).to eq(1)
186
186
  end
187
187
 
188
- it "should assign scope" do
189
- post.update_attributes(title: "Another Test")
190
- post.history_tracks.first.scope.should == "post"
188
+ it 'should assign scope' do
189
+ post.update_attributes(title: 'Another Test')
190
+ expect(post.history_tracks.first.scope).to eq('post')
191
191
  end
192
192
 
193
- it "should assign association_chain" do
194
- post.update_attributes(title: "Another Test")
195
- post.history_tracks.last.association_chain.should == [{ 'id' => post.id, 'name' => "Post" }]
193
+ it 'should assign association_chain' do
194
+ post.update_attributes(title: 'Another Test')
195
+ expect(post.history_tracks.last.association_chain).to eq([{ 'id' => post.id, 'name' => 'Post' }])
196
196
  end
197
197
 
198
- it "should exclude defined options" do
198
+ it 'should exclude defined options' do
199
199
  name = user.name
200
- user.update_attributes(name: "Aaron2", email: "aaronsnewemail@randomemail.com")
201
- user.history_tracks.first.original.keys.should == ["n"]
202
- user.history_tracks.first.original["n"].should == name
203
- user.history_tracks.first.modified.keys.should == ["n"]
204
- user.history_tracks.first.modified["n"].should == user.name
200
+ user.update_attributes(name: 'Aaron2', email: 'aaronsnewemail@randomemail.com')
201
+ expect(user.history_tracks.first.original.keys).to eq(['n'])
202
+ expect(user.history_tracks.first.original['n']).to eq(name)
203
+ expect(user.history_tracks.first.modified.keys).to eq(['n'])
204
+ expect(user.history_tracks.first.modified['n']).to eq(user.name)
205
205
  end
206
206
 
207
- it "should undo field changes" do
207
+ it 'should undo field changes' do
208
208
  name = user.name
209
- user.update_attributes(name: "Aaron2", email: "aaronsnewemail@randomemail.com")
209
+ user.update_attributes(name: 'Aaron2', email: 'aaronsnewemail@randomemail.com')
210
210
  user.history_tracks.first.undo! nil
211
- user.reload.name.should == name
211
+ expect(user.reload.name).to eq(name)
212
212
  end
213
213
 
214
- it "should undo non-existing field changes" do
214
+ it 'should undo non-existing field changes' do
215
215
  post = Post.create(modifier: user, views: 100)
216
- post.reload.title.should be_nil
217
- post.update_attributes(title: "Aaron2")
218
- post.reload.title.should == "Aaron2"
216
+ expect(post.reload.title).to be_nil
217
+ post.update_attributes(title: 'Aaron2')
218
+ expect(post.reload.title).to eq('Aaron2')
219
219
  post.history_tracks.first.undo! nil
220
- post.reload.title.should be_nil
220
+ expect(post.reload.title).to be_nil
221
221
  end
222
222
 
223
- it "should track array changes" do
223
+ it 'should track array changes' do
224
224
  aliases = user.aliases
225
- user.update_attributes(aliases: ['bob', 'joe'])
226
- user.history_tracks.first.original["aliases"].should == aliases
227
- user.history_tracks.first.modified["aliases"].should == user.aliases
225
+ user.update_attributes(aliases: %w(bob joe))
226
+ expect(user.history_tracks.first.original['aliases']).to eq(aliases)
227
+ expect(user.history_tracks.first.modified['aliases']).to eq(user.aliases)
228
228
  end
229
229
 
230
- it "should undo array changes" do
230
+ it 'should undo array changes' do
231
231
  aliases = user.aliases
232
- user.update_attributes(aliases: ['bob', 'joe'])
232
+ user.update_attributes(aliases: %w(bob joe))
233
233
  user.history_tracks.first.undo! nil
234
- user.reload.aliases.should == aliases
234
+ expect(user.reload.aliases).to eq(aliases)
235
235
  end
236
236
  end
237
237
 
238
- describe "#tracked_changes" do
239
- context "create action" do
238
+ describe '#tracked_changes' do
239
+ context 'create action' do
240
240
  subject { tag.history_tracks.first.tracked_changes }
241
- it "consider all fields values as :to" do
242
- subject[:title].should == { to: "test" }.with_indifferent_access
241
+ it 'consider all fields values as :to' do
242
+ expect(subject[:title]).to eq({ to: 'test' }.with_indifferent_access)
243
243
  end
244
244
  end
245
- context "destroy action" do
246
- subject {
245
+ context 'destroy action' do
246
+ subject do
247
247
  tag.destroy
248
248
  tag.history_tracks.last.tracked_changes
249
- }
250
- it "consider all fields values as :from" do
251
- subject[:title].should == { from: "test" }.with_indifferent_access
249
+ end
250
+ it 'consider all fields values as :from' do
251
+ expect(subject[:title]).to eq({ from: 'test' }.with_indifferent_access)
252
252
  end
253
253
  end
254
- context "update action" do
254
+ context 'update action' do
255
255
  subject { user.history_tracks.first.tracked_changes }
256
256
  before do
257
- user.update_attributes(name: "Aaron2", email: nil, country: '', city: nil, phone: '867-5309', aliases: ['', 'bill', 'james'])
257
+ user.update_attributes(name: 'Aaron2', email: nil, country: '', city: nil, phone: '867-5309', aliases: ['', 'bill', 'james'])
258
258
  end
259
- it { should be_a HashWithIndifferentAccess }
260
- it "should track changed field" do
261
- subject[:n].should == { from: "Aaron", to: "Aaron2" }.with_indifferent_access
259
+ it { is_expected.to be_a HashWithIndifferentAccess }
260
+ it 'should track changed field' do
261
+ expect(subject[:n]).to eq({ from: 'Aaron', to: 'Aaron2' }.with_indifferent_access)
262
262
  end
263
- it "should track added field" do
264
- subject[:phone].should == { to: "867-5309" }.with_indifferent_access
263
+ it 'should track added field' do
264
+ expect(subject[:phone]).to eq({ to: '867-5309' }.with_indifferent_access)
265
265
  end
266
- it "should track removed field" do
267
- subject[:city].should == { from: "Toronto" }.with_indifferent_access
266
+ it 'should track removed field' do
267
+ expect(subject[:city]).to eq({ from: 'Toronto' }.with_indifferent_access)
268
268
  end
269
- it "should not consider blank as removed" do
270
- subject[:country].should == { from: "Canada", to: '' }.with_indifferent_access
269
+ it 'should not consider blank as removed' do
270
+ expect(subject[:country]).to eq({ from: 'Canada', to: '' }.with_indifferent_access)
271
271
  end
272
- it "should track changed array field" do
273
- subject[:aliases].should == { from: ["bob"], to: ["", "bill", "james"] }.with_indifferent_access
272
+ it 'should track changed array field' do
273
+ expect(subject[:aliases]).to eq({ from: ['bob'], to: ['', 'bill', 'james'] }.with_indifferent_access)
274
274
  end
275
- it "should not track unmodified field" do
276
- subject[:address].should be_nil
275
+ it 'should not track unmodified field' do
276
+ expect(subject[:address]).to be_nil
277
277
  end
278
- it "should not track untracked fields" do
279
- subject[:email].should be_nil
278
+ it 'should not track untracked fields' do
279
+ expect(subject[:email]).to be_nil
280
280
  end
281
281
  end
282
282
  end
283
283
 
284
- describe "#tracked_edits" do
285
- context "create action" do
284
+ describe '#tracked_edits' do
285
+ context 'create action' do
286
286
  subject { tag.history_tracks.first.tracked_edits }
287
- it "consider all edits as ;add" do
288
- subject[:add].should == { title: "test" }.with_indifferent_access
287
+ it 'consider all edits as ;add' do
288
+ expect(subject[:add]).to eq({ title: 'test' }.with_indifferent_access)
289
289
  end
290
290
  end
291
- context "destroy action" do
292
- subject {
291
+ context 'destroy action' do
292
+ subject do
293
293
  tag.destroy
294
294
  tag.history_tracks.last.tracked_edits
295
- }
296
- it "consider all edits as ;remove" do
297
- subject[:remove].should == { title: "test" }.with_indifferent_access
295
+ end
296
+ it 'consider all edits as ;remove' do
297
+ expect(subject[:remove]).to eq({ title: 'test' }.with_indifferent_access)
298
298
  end
299
299
  end
300
- context "update action" do
300
+ context 'update action' do
301
301
  subject { user.history_tracks.first.tracked_edits }
302
302
  before do
303
- user.update_attributes(name: "Aaron2", email: nil, country: '', city: nil, phone: '867-5309', aliases: ['', 'bill', 'james'])
303
+ user.update_attributes(name: 'Aaron2', email: nil, country: '', city: nil, phone: '867-5309', aliases: ['', 'bill', 'james'])
304
304
  end
305
- it { should be_a HashWithIndifferentAccess }
306
- it "should track changed field" do
307
- subject[:modify].should == { n: { from: "Aaron", to: "Aaron2" } }.with_indifferent_access
305
+ it { is_expected.to be_a HashWithIndifferentAccess }
306
+ it 'should track changed field' do
307
+ expect(subject[:modify]).to eq({ n: { from: 'Aaron', to: 'Aaron2' } }.with_indifferent_access)
308
308
  end
309
- it "should track added field" do
310
- subject[:add].should == { phone: "867-5309" }.with_indifferent_access
309
+ it 'should track added field' do
310
+ expect(subject[:add]).to eq({ phone: '867-5309' }.with_indifferent_access)
311
311
  end
312
- it "should track removed field and consider blank as removed" do
313
- subject[:remove].should == { city: "Toronto", country: "Canada" }.with_indifferent_access
312
+ it 'should track removed field and consider blank as removed' do
313
+ expect(subject[:remove]).to eq({ city: 'Toronto', country: 'Canada' }.with_indifferent_access)
314
314
  end
315
- it "should track changed array field" do
316
- subject[:array].should == { aliases: { remove: ["bob"], add: ["", "bill", "james"] } }.with_indifferent_access
315
+ it 'should track changed array field' do
316
+ expect(subject[:array]).to eq({ aliases: { remove: ['bob'], add: ['', 'bill', 'james'] } }.with_indifferent_access)
317
317
  end
318
- it "should not track unmodified field" do
318
+ it 'should not track unmodified field' do
319
319
  %w(add modify remove array).each do |edit|
320
- subject[edit][:address].should be_nil
320
+ expect(subject[edit][:address]).to be_nil
321
321
  end
322
322
  end
323
- it "should not track untracked fields" do
323
+ it 'should not track untracked fields' do
324
324
  %w(add modify remove array).each do |edit|
325
- subject[edit][:email].should be_nil
325
+ expect(subject[edit][:email]).to be_nil
326
326
  end
327
327
  end
328
328
  end
329
- context "with empty values" do
329
+ context 'with empty values' do
330
330
  subject { Tracker.new }
331
- it "should skip empty values" do
332
- subject.stub(:tracked_changes) { { name: { to: '', from: [] }, city: { to: 'Toronto', from: '' } } }
333
- subject.tracked_edits.should == { add: { city: "Toronto" } }.with_indifferent_access
331
+ it 'should skip empty values' do
332
+ allow(subject).to receive(:tracked_changes) { { name: { to: '', from: [] }, city: { to: 'Toronto', from: '' } } }
333
+ expect(subject.tracked_edits).to eq({ add: { city: 'Toronto' } }.with_indifferent_access)
334
334
  end
335
335
  end
336
336
  end
337
337
 
338
- describe "on update non-embedded twice" do
339
- it "should assign version on post" do
340
- post.update_attributes(title: "Test2")
341
- post.update_attributes(title: "Test3")
342
- post.version.should == 2
338
+ describe 'on update non-embedded twice' do
339
+ it 'should assign version on post' do
340
+ post.update_attributes(title: 'Test2')
341
+ post.update_attributes(title: 'Test3')
342
+ expect(post.version).to eq(2)
343
343
  end
344
344
 
345
- it "should create a history track if changed attributes match tracked attributes" do
346
- lambda {
347
- post.update_attributes(title: "Test2")
348
- post.update_attributes(title: "Test3")
349
- }.should change(Tracker, :count).by(2)
345
+ it 'should create a history track if changed attributes match tracked attributes' do
346
+ expect do
347
+ post.update_attributes(title: 'Test2')
348
+ post.update_attributes(title: 'Test3')
349
+ end.to change(Tracker, :count).by(2)
350
350
  end
351
351
 
352
- it "should create a history track of version 2" do
353
- post.update_attributes(title: "Test2")
354
- post.update_attributes(title: "Test3")
355
- post.history_tracks.where(version: 2).first.should_not be_nil
352
+ it 'should create a history track of version 2' do
353
+ post.update_attributes(title: 'Test2')
354
+ post.update_attributes(title: 'Test3')
355
+ expect(post.history_tracks.where(version: 2).first).not_to be_nil
356
356
  end
357
357
 
358
- it "should assign modified fields" do
359
- post.update_attributes(title: "Test2")
360
- post.update_attributes(title: "Test3")
361
- post.history_tracks.where(version: 2).first.modified.should == {
362
- "title" => "Test3"
363
- }
358
+ it 'should assign modified fields' do
359
+ post.update_attributes(title: 'Test2')
360
+ post.update_attributes(title: 'Test3')
361
+ expect(post.history_tracks.where(version: 2).first.modified).to eq(
362
+ 'title' => 'Test3'
363
+ )
364
364
  end
365
365
 
366
- it "should assign original fields" do
367
- post.update_attributes(title: "Test2")
368
- post.update_attributes(title: "Test3")
369
- post.history_tracks.where(version: 2).first.original.should == {
370
- "title" => "Test2"
371
- }
366
+ it 'should assign original fields' do
367
+ post.update_attributes(title: 'Test2')
368
+ post.update_attributes(title: 'Test3')
369
+ expect(post.history_tracks.where(version: 2).first.original).to eq(
370
+ 'title' => 'Test2'
371
+ )
372
372
  end
373
373
 
374
- it "should assign modifier" do
375
- post.update_attributes(title: "Another Test", modifier: another_user)
376
- post.history_tracks.last.modifier.should == another_user
374
+ it 'should assign modifier' do
375
+ post.update_attributes(title: 'Another Test', modifier: another_user)
376
+ expect(post.history_tracks.last.modifier).to eq(another_user)
377
377
  end
378
378
  end
379
379
 
380
- describe "on update embedded 1..N (embeds_many)" do
381
- it "should assign version on comment" do
382
- comment.update_attributes(title: "Test2")
383
- comment.version.should == 2 # first track generated on creation
380
+ describe 'on update embedded 1..N (embeds_many)' do
381
+ it 'should assign version on comment' do
382
+ comment.update_attributes(title: 'Test2')
383
+ expect(comment.version).to eq(2) # first track generated on creation
384
384
  end
385
385
 
386
- it "should create a history track of version 2" do
387
- comment.update_attributes(title: "Test2")
388
- comment.history_tracks.where(version: 2).first.should_not be_nil
386
+ it 'should create a history track of version 2' do
387
+ comment.update_attributes(title: 'Test2')
388
+ expect(comment.history_tracks.where(version: 2).first).not_to be_nil
389
389
  end
390
390
 
391
- it "should assign modified fields" do
392
- comment.update_attributes(t: "Test2")
393
- comment.history_tracks.where(version: 2).first.modified.should == {
394
- "t" => "Test2"
395
- }
391
+ it 'should assign modified fields' do
392
+ comment.update_attributes(t: 'Test2')
393
+ expect(comment.history_tracks.where(version: 2).first.modified).to eq(
394
+ 't' => 'Test2'
395
+ )
396
396
  end
397
397
 
398
- it "should assign original fields" do
399
- comment.update_attributes(title: "Test2")
400
- comment.history_tracks.where(version: 2).first.original.should == {
401
- "t" => "test"
402
- }
398
+ it 'should assign original fields' do
399
+ comment.update_attributes(title: 'Test2')
400
+ expect(comment.history_tracks.where(version: 2).first.original).to eq(
401
+ 't' => 'test'
402
+ )
403
403
  end
404
404
 
405
- it "should be possible to undo from parent" do
406
- comment.update_attributes(title: "Test 2")
405
+ it 'should be possible to undo from parent' do
406
+ comment.update_attributes(title: 'Test 2')
407
407
  user
408
408
  post.history_tracks.last.undo!(user)
409
409
  comment.reload
410
- comment.title.should == "test"
410
+ expect(comment.title).to eq('test')
411
411
  end
412
412
 
413
- it "should assign modifier" do
414
- post.update_attributes(title: "Another Test", modifier: another_user)
415
- post.history_tracks.last.modifier.should == another_user
413
+ it 'should assign modifier' do
414
+ post.update_attributes(title: 'Another Test', modifier: another_user)
415
+ expect(post.history_tracks.last.modifier).to eq(another_user)
416
416
  end
417
417
  end
418
418
 
419
- describe "on update embedded 1..1 (embeds_one)" do
419
+ describe 'on update embedded 1..1 (embeds_one)' do
420
420
  let(:section) { Section.new(title: 'Technology') }
421
421
 
422
422
  before(:each) do
@@ -426,85 +426,85 @@ describe Mongoid::History do
426
426
  post.section
427
427
  end
428
428
 
429
- it "should assign version on create section" do
430
- section.version.should == 1
429
+ it 'should assign version on create section' do
430
+ expect(section.version).to eq(1)
431
431
  end
432
432
 
433
- it "should assign version on section" do
433
+ it 'should assign version on section' do
434
434
  section.update_attributes(title: 'Technology 2')
435
- section.version.should == 2 # first track generated on creation
435
+ expect(section.version).to eq(2) # first track generated on creation
436
436
  end
437
437
 
438
- it "should create a history track of version 2" do
438
+ it 'should create a history track of version 2' do
439
439
  section.update_attributes(title: 'Technology 2')
440
- section.history_tracks.where(version: 2).first.should_not be_nil
440
+ expect(section.history_tracks.where(version: 2).first).not_to be_nil
441
441
  end
442
442
 
443
- it "should assign modified fields" do
443
+ it 'should assign modified fields' do
444
444
  section.update_attributes(title: 'Technology 2')
445
- section.history_tracks.where(version: 2).first.modified.should == {
446
- "t" => "Technology 2"
447
- }
445
+ expect(section.history_tracks.where(version: 2).first.modified).to eq(
446
+ 't' => 'Technology 2'
447
+ )
448
448
  end
449
449
 
450
- it "should assign original fields" do
450
+ it 'should assign original fields' do
451
451
  section.update_attributes(title: 'Technology 2')
452
- section.history_tracks.where(version: 2).first.original.should == {
453
- "t" => "Technology"
454
- }
452
+ expect(section.history_tracks.where(version: 2).first.original).to eq(
453
+ 't' => 'Technology'
454
+ )
455
455
  end
456
456
 
457
- it "should be possible to undo from parent" do
457
+ it 'should be possible to undo from parent' do
458
458
  section.update_attributes(title: 'Technology 2')
459
459
  post.history_tracks.last.undo!(user)
460
460
  section.reload
461
- section.title.should == "Technology"
461
+ expect(section.title).to eq('Technology')
462
462
  end
463
463
 
464
- it "should assign modifier" do
465
- section.update_attributes(title: "Business", modifier: another_user)
466
- post.history_tracks.last.modifier.should == another_user
464
+ it 'should assign modifier' do
465
+ section.update_attributes(title: 'Business', modifier: another_user)
466
+ expect(post.history_tracks.last.modifier).to eq(another_user)
467
467
  end
468
468
  end
469
469
 
470
- describe "on destroy embedded" do
471
- it "should be possible to re-create destroyed embedded" do
470
+ describe 'on destroy embedded' do
471
+ it 'should be possible to re-create destroyed embedded' do
472
472
  comment.destroy
473
473
  comment.history_tracks.last.undo!(user)
474
474
  post.reload
475
- post.comments.first.title.should == "test"
475
+ expect(post.comments.first.title).to eq('test')
476
476
  end
477
477
 
478
- it "should be possible to re-create destroyed embedded from parent" do
478
+ it 'should be possible to re-create destroyed embedded from parent' do
479
479
  comment.destroy
480
480
  post.history_tracks.last.undo!(user)
481
481
  post.reload
482
- post.comments.first.title.should == "test"
482
+ expect(post.comments.first.title).to eq('test')
483
483
  end
484
484
 
485
- it "should be possible to destroy after re-create embedded from parent" do
485
+ it 'should be possible to destroy after re-create embedded from parent' do
486
486
  comment.destroy
487
487
  post.history_tracks.last.undo!(user)
488
488
  post.history_tracks.last.undo!(user)
489
489
  post.reload
490
- post.comments.count.should == 0
490
+ expect(post.comments.count).to eq(0)
491
491
  end
492
492
 
493
- it "should be possible to create with redo after undo create embedded from parent" do
493
+ it 'should be possible to create with redo after undo create embedded from parent' do
494
494
  comment # initialize
495
- post.comments.create!(title: "The second one")
495
+ post.comments.create!(title: 'The second one')
496
496
  track = post.history_tracks.last
497
497
  track.undo!(user)
498
498
  track.redo!(user)
499
499
  post.reload
500
- post.comments.count.should == 2
500
+ expect(post.comments.count).to eq(2)
501
501
  end
502
502
  end
503
503
 
504
- describe "embedded with cascading callbacks" do
504
+ describe 'embedded with cascading callbacks' do
505
505
 
506
- let(:tag_foo) { post.tags.create(title: "foo", updated_by: user) }
507
- let(:tag_bar) { post.tags.create(title: "bar") }
506
+ let(:tag_foo) { post.tags.create(title: 'foo', updated_by: user) }
507
+ let(:tag_bar) { post.tags.create(title: 'bar') }
508
508
 
509
509
  # it "should have cascaded the creation callbacks and set timestamps" do
510
510
  # tag_foo; tag_bar # initialize
@@ -512,167 +512,169 @@ describe Mongoid::History do
512
512
  # tag_foo.updated_at.should_not be_nil
513
513
  # end
514
514
 
515
- it "should allow an update through the parent model" do
516
- update_hash = { "post" => { "tags_attributes" => { "1234" => { "id" => tag_bar.id, "title" => "baz" } } } }
517
- post.update_attributes(update_hash["post"])
518
- post.tags.last.title.should == "baz"
515
+ it 'should allow an update through the parent model' do
516
+ update_hash = { 'post' => { 'tags_attributes' => { '1234' => { 'id' => tag_bar.id, 'title' => 'baz' } } } }
517
+ post.update_attributes(update_hash['post'])
518
+ expect(post.tags.last.title).to eq('baz')
519
519
  end
520
520
 
521
- it "should be possible to destroy through parent model using canoncial _destroy macro" do
521
+ it 'should be possible to destroy through parent model using canoncial _destroy macro' do
522
522
  tag_foo
523
523
  tag_bar # initialize
524
- post.tags.count.should == 2
525
- update_hash = { "post" => { "tags_attributes" => { "1234" => { "id" => tag_bar.id, "title" => "baz", "_destroy" => "true" } } } }
526
- post.update_attributes(update_hash["post"])
527
- post.tags.count.should == 1
528
- post.history_tracks.to_a.last.action.should == "destroy"
524
+ expect(post.tags.count).to eq(2)
525
+ update_hash = { 'post' => { 'tags_attributes' => { '1234' => { 'id' => tag_bar.id, 'title' => 'baz', '_destroy' => 'true' } } } }
526
+ post.update_attributes(update_hash['post'])
527
+ expect(post.tags.count).to eq(1)
528
+ expect(post.history_tracks.to_a.last.action).to eq('destroy')
529
529
  end
530
530
 
531
- it "should write relationship name for association_chain hiearchy instead of class name when using _destroy macro" do
532
- update_hash = { "tags_attributes" => { "1234" => { "id" => tag_foo.id, "_destroy" => "1" } } }
531
+ it 'should write relationship name for association_chain hiearchy instead of class name when using _destroy macro' do
532
+ update_hash = { 'tags_attributes' => { '1234' => { 'id' => tag_foo.id, '_destroy' => '1' } } }
533
533
  post.update_attributes(update_hash)
534
534
 
535
535
  # historically this would have evaluated to 'Tags' and an error would be thrown
536
536
  # on any call that walked up the association_chain, e.g. 'trackable'
537
- tag_foo.history_tracks.last.association_chain.last["name"].should == "tags"
538
- lambda { tag_foo.history_tracks.last.trackable }.should_not raise_error
537
+ expect(tag_foo.history_tracks.last.association_chain.last['name']).to eq('tags')
538
+ expect { tag_foo.history_tracks.last.trackable }.not_to raise_error
539
539
  end
540
540
  end
541
541
 
542
- describe "non-embedded" do
543
- it "should undo changes" do
544
- post.update_attributes(title: "Test2")
542
+ describe 'non-embedded' do
543
+ it 'should undo changes' do
544
+ post.update_attributes(title: 'Test2')
545
545
  post.history_tracks.where(version: 1).last.undo!(user)
546
546
  post.reload
547
- post.title.should == "Test"
547
+ expect(post.title).to eq('Test')
548
548
  end
549
549
 
550
- it "should undo destruction" do
550
+ it 'should undo destruction' do
551
551
  post.destroy
552
552
  post.history_tracks.where(version: 1).last.undo!(user)
553
- Post.find(post.id).title.should == "Test"
553
+ expect(Post.find(post.id).title).to eq('Test')
554
554
  end
555
555
 
556
- it "should create a new history track after undo" do
556
+ it 'should create a new history track after undo' do
557
557
  comment # initialize
558
- post.update_attributes(title: "Test2")
558
+ post.update_attributes(title: 'Test2')
559
559
  post.history_tracks.last.undo!(user)
560
560
  post.reload
561
- post.history_tracks.count.should == 3
561
+ expect(post.history_tracks.count).to eq(3)
562
562
  end
563
563
 
564
- it "should assign user as the modifier of the newly created history track" do
565
- post.update_attributes(title: "Test2")
564
+ it 'should assign user as the modifier of the newly created history track' do
565
+ post.update_attributes(title: 'Test2')
566
566
  post.history_tracks.where(version: 1).last.undo!(user)
567
567
  post.reload
568
- post.history_tracks.where(version: 2).last.modifier.should == user
568
+ expect(post.history_tracks.where(version: 2).last.modifier).to eq(user)
569
569
  end
570
570
 
571
- it "should stay the same after undo and redo" do
572
- post.update_attributes(title: "Test2")
571
+ it 'should stay the same after undo and redo' do
572
+ post.update_attributes(title: 'Test2')
573
573
  track = post.history_tracks.last
574
574
  track.undo!(user)
575
575
  track.redo!(user)
576
576
  post2 = Post.where(_id: post.id).first
577
577
 
578
- post.title.should == post2.title
578
+ expect(post.title).to eq(post2.title)
579
579
  end
580
580
 
581
- it "should be destroyed after undo and redo" do
581
+ it 'should be destroyed after undo and redo' do
582
582
  post.destroy
583
583
  track = post.history_tracks.where(version: 1).last
584
584
  track.undo!(user)
585
585
  track.redo!(user)
586
- Post.where(_id: post.id).first.should be_nil
586
+ expect(Post.where(_id: post.id).first).to be_nil
587
587
  end
588
588
  end
589
589
 
590
- describe "embedded" do
591
- it "should undo changes" do
592
- comment.update_attributes(title: "Test2")
590
+ describe 'embedded' do
591
+ it 'should undo changes' do
592
+ comment.update_attributes(title: 'Test2')
593
593
  comment.history_tracks.where(version: 2).first.undo!(user)
594
594
  comment.reload
595
- comment.title.should == "test"
595
+ expect(comment.title).to eq('test')
596
596
  end
597
597
 
598
- it "should create a new history track after undo" do
599
- comment.update_attributes(title: "Test2")
598
+ it 'should create a new history track after undo' do
599
+ comment.update_attributes(title: 'Test2')
600
600
  comment.history_tracks.where(version: 2).first.undo!(user)
601
601
  comment.reload
602
- comment.history_tracks.count.should == 3
602
+ expect(comment.history_tracks.count).to eq(3)
603
603
  end
604
604
 
605
- it "should assign user as the modifier of the newly created history track" do
606
- comment.update_attributes(title: "Test2")
605
+ it 'should assign user as the modifier of the newly created history track' do
606
+ comment.update_attributes(title: 'Test2')
607
607
  comment.history_tracks.where(version: 2).first.undo!(user)
608
608
  comment.reload
609
- comment.history_tracks.where(version: 3).first.modifier.should == user
609
+ expect(comment.history_tracks.where(version: 3).first.modifier).to eq(user)
610
610
  end
611
611
 
612
- it "should stay the same after undo and redo" do
613
- comment.update_attributes(title: "Test2")
612
+ it 'should stay the same after undo and redo' do
613
+ comment.update_attributes(title: 'Test2')
614
614
  track = comment.history_tracks.where(version: 2).first
615
615
  track.undo!(user)
616
616
  track.redo!(user)
617
617
  comment.reload
618
- comment.title.should == "Test2"
618
+ expect(comment.title).to eq('Test2')
619
619
  end
620
620
  end
621
621
 
622
- describe "trackables" do
622
+ describe 'trackables' do
623
623
  before :each do
624
- comment.update_attributes!(title: "Test2") # version == 2
625
- comment.update_attributes!(title: "Test3") # version == 3
626
- comment.update_attributes!(title: "Test4") # version == 4
627
- end
628
-
629
- describe "undo" do
630
- [nil, :reload].each do |method|
631
- context "#{method || 'instance'}" do
632
- it "should recognize :from, :to options" do
633
- comment.undo! user, from: 4, to: 2
634
- comment.send(method) if method
635
- comment.title.should == "test"
636
- end
637
-
638
- it "should recognize parameter as version number" do
639
- comment.undo! user, 3
640
- comment.send(method) if method
641
- comment.title.should == "Test2"
642
- end
643
-
644
- it "should undo last version when no parameter is specified" do
645
- comment.undo! user
646
- comment.send(method) if method
647
- comment.title.should == "Test3"
648
- end
649
-
650
- it "should recognize :last options" do
651
- comment.undo! user, last: 2
652
- comment.send(method) if method
653
- comment.title.should == "Test2"
654
- end
624
+ comment.update_attributes!(title: 'Test2') # version == 2
625
+ comment.update_attributes!(title: 'Test3') # version == 3
626
+ comment.update_attributes!(title: 'Test4') # version == 4
627
+ end
628
+
629
+ describe 'undo' do
630
+ { 'undo' => [nil], 'undo!' => [nil, :reload] }.each do |test_method, methods|
631
+ methods.each do |method|
632
+ context "#{method || 'instance'}" do
633
+ it 'recognizes :from, :to options' do
634
+ comment.send test_method, user, from: 4, to: 2
635
+ comment.send(method) if method
636
+ expect(comment.title).to eq('test')
637
+ end
655
638
 
656
- if Mongoid::History.mongoid3?
657
- context "protected attributes" do
658
- before :each do
659
- Comment.attr_accessible(nil)
660
- end
639
+ it 'recognizes parameter as version number' do
640
+ comment.send test_method, user, 3
641
+ comment.send(method) if method
642
+ expect(comment.title).to eq('Test2')
643
+ end
661
644
 
662
- after :each do
663
- Comment.attr_protected(nil)
664
- end
645
+ it 'should undo last version when no parameter is specified' do
646
+ comment.send test_method, user
647
+ comment.send(method) if method
648
+ expect(comment.title).to eq('Test3')
649
+ end
665
650
 
666
- it "should undo last version when no parameter is specified on protected attributes" do
667
- comment.undo! user
668
- comment.send(method) if method
669
- comment.title.should == "Test3"
670
- end
651
+ it 'recognizes :last options' do
652
+ comment.send test_method, user, last: 2
653
+ comment.send(method) if method
654
+ expect(comment.title).to eq('Test2')
655
+ end
671
656
 
672
- it "should recognize :last options on model with protected attributes" do
673
- comment.undo! user, last: 2
674
- comment.send(method) if method
675
- comment.title.should == "Test2"
657
+ if Mongoid::History.mongoid3?
658
+ context 'protected attributes' do
659
+ before :each do
660
+ Comment.attr_accessible(nil)
661
+ end
662
+
663
+ after :each do
664
+ Comment.attr_protected(nil)
665
+ end
666
+
667
+ it 'should undo last version when no parameter is specified on protected attributes' do
668
+ comment.send test_method, user
669
+ comment.send(method) if method
670
+ expect(comment.title).to eq('Test3')
671
+ end
672
+
673
+ it 'recognizes :last options on model with protected attributes' do
674
+ comment.send test_method, user, last: 2
675
+ comment.send(method) if method
676
+ expect(comment.title).to eq('Test2')
677
+ end
676
678
  end
677
679
  end
678
680
  end
@@ -680,39 +682,39 @@ describe Mongoid::History do
680
682
  end
681
683
  end
682
684
 
683
- describe "redo" do
685
+ describe 'redo' do
684
686
  [nil, :reload].each do |method|
685
687
  context "#{method || 'instance'}" do
686
688
  before :each do
687
- comment.update_attributes(title: "Test5")
689
+ comment.update_attributes(title: 'Test5')
688
690
  end
689
691
 
690
- it "should recognize :from, :to options" do
692
+ it 'should recognize :from, :to options' do
691
693
  comment.redo! user, from: 2, to: 4
692
694
  comment.send(method) if method
693
- comment.title.should == "Test4"
695
+ expect(comment.title).to eq('Test4')
694
696
  end
695
697
 
696
- it "should recognize parameter as version number" do
698
+ it 'should recognize parameter as version number' do
697
699
  comment.redo! user, 2
698
700
  comment.send(method) if method
699
- comment.title.should == "Test2"
701
+ expect(comment.title).to eq('Test2')
700
702
  end
701
703
 
702
- it "should redo last version when no parameter is specified" do
704
+ it 'should redo last version when no parameter is specified' do
703
705
  comment.redo! user
704
706
  comment.send(method) if method
705
- comment.title.should == "Test5"
707
+ expect(comment.title).to eq('Test5')
706
708
  end
707
709
 
708
- it "should recognize :last options" do
710
+ it 'should recognize :last options' do
709
711
  comment.redo! user, last: 1
710
712
  comment.send(method) if method
711
- comment.title.should == "Test5"
713
+ expect(comment.title).to eq('Test5')
712
714
  end
713
715
 
714
716
  if Mongoid::History.mongoid3?
715
- context "protected attributes" do
717
+ context 'protected attributes' do
716
718
  before :each do
717
719
  Comment.attr_accessible(nil)
718
720
  end
@@ -721,16 +723,16 @@ describe Mongoid::History do
721
723
  Comment.attr_protected(nil)
722
724
  end
723
725
 
724
- it "should recognize parameter as version number" do
726
+ it 'should recognize parameter as version number' do
725
727
  comment.redo! user, 2
726
728
  comment.send(method) if method
727
- comment.title.should == "Test2"
729
+ expect(comment.title).to eq('Test2')
728
730
  end
729
731
 
730
- it "should recognize :from, :to options" do
732
+ it 'should recognize :from, :to options' do
731
733
  comment.redo! user, from: 2, to: 4
732
734
  comment.send(method) if method
733
- comment.title.should == "Test4"
735
+ expect(comment.title).to eq('Test4')
734
736
  end
735
737
  end
736
738
  end
@@ -740,7 +742,7 @@ describe Mongoid::History do
740
742
  end
741
743
  end
742
744
 
743
- describe "localized fields" do
745
+ describe 'localized fields' do
744
746
  before :each do
745
747
  class Sausage
746
748
  include Mongoid::Document
@@ -750,66 +752,66 @@ describe Mongoid::History do
750
752
  track_history on: [:flavour], track_destroy: true
751
753
  end
752
754
  end
753
- it "should correctly undo and redo" do
755
+ it 'should correctly undo and redo' do
754
756
  if Sausage.respond_to?(:localized_fields)
755
- sausage = Sausage.create(flavour_translations: { 'en' => "Apple", 'nl' => 'Appel' })
756
- sausage.update_attributes(flavour: "Guinness")
757
+ sausage = Sausage.create(flavour_translations: { 'en' => 'Apple', 'nl' => 'Appel' })
758
+ sausage.update_attributes(flavour: 'Guinness')
757
759
 
758
760
  track = sausage.history_tracks.last
759
761
 
760
762
  track.undo! user
761
- sausage.reload.flavour.should == "Apple"
763
+ expect(sausage.reload.flavour).to eq('Apple')
762
764
 
763
765
  track.redo! user
764
- sausage.reload.flavour.should == "Guinness"
766
+ expect(sausage.reload.flavour).to eq('Guinness')
765
767
 
766
768
  sausage.destroy
767
- sausage.history_tracks.last.action.should == "destroy"
769
+ expect(sausage.history_tracks.last.action).to eq('destroy')
768
770
  sausage.history_tracks.last.undo! user
769
- sausage.reload.flavour.should == "Guinness"
771
+ expect(sausage.reload.flavour).to eq('Guinness')
770
772
  end
771
773
  end
772
774
  end
773
775
 
774
- describe "embedded with a polymorphic trackable" do
776
+ describe 'embedded with a polymorphic trackable' do
775
777
  let(:foo) { Foo.new(title: 'a title', body: 'a body') }
776
778
  before :each do
777
779
  post.comments << foo
778
780
  post.save
779
781
  end
780
- it "should assign interface name in association chain" do
782
+ it 'should assign interface name in association chain' do
781
783
  foo.update_attribute(:body, 'a changed body')
782
- expected_root = { "name" => "Post", "id" => post.id }
783
- expected_node = { "name" => "coms", "id" => foo.id }
784
- foo.history_tracks.first.association_chain.should == [expected_root, expected_node]
784
+ expected_root = { 'name' => 'Post', 'id' => post.id }
785
+ expected_node = { 'name' => 'coms', 'id' => foo.id }
786
+ expect(foo.history_tracks.first.association_chain).to eq([expected_root, expected_node])
785
787
  end
786
788
  end
787
789
 
788
- describe "#trackable_parent_class" do
789
- context "a non-embedded model" do
790
- it "should return the trackable parent class" do
791
- tag.history_tracks.first.trackable_parent_class.should == Tag
790
+ describe '#trackable_parent_class' do
791
+ context 'a non-embedded model' do
792
+ it 'should return the trackable parent class' do
793
+ expect(tag.history_tracks.first.trackable_parent_class).to eq(Tag)
792
794
  end
793
- it "should return the parent class even if the trackable is deleted" do
795
+ it 'should return the parent class even if the trackable is deleted' do
794
796
  tracker = tag.history_tracks.first
795
797
  tag.destroy
796
- tracker.trackable_parent_class.should == Tag
798
+ expect(tracker.trackable_parent_class).to eq(Tag)
797
799
  end
798
800
  end
799
- context "an embedded model" do
800
- it "should return the trackable parent class" do
801
- comment.update_attributes(title: "Foo")
802
- comment.history_tracks.first.trackable_parent_class.should == Post
801
+ context 'an embedded model' do
802
+ it 'should return the trackable parent class' do
803
+ comment.update_attributes(title: 'Foo')
804
+ expect(comment.history_tracks.first.trackable_parent_class).to eq(Post)
803
805
  end
804
- it "should return the parent class even if the trackable is deleted" do
806
+ it 'should return the parent class even if the trackable is deleted' do
805
807
  tracker = comment.history_tracks.first
806
808
  comment.destroy
807
- tracker.trackable_parent_class.should == Post
809
+ expect(tracker.trackable_parent_class).to eq(Post)
808
810
  end
809
811
  end
810
812
  end
811
813
 
812
- describe "when default scope is present" do
814
+ describe 'when default scope is present' do
813
815
  before do
814
816
  class Post
815
817
  default_scope -> { where(title: nil) }
@@ -825,77 +827,77 @@ describe Mongoid::History do
825
827
  end
826
828
  end
827
829
 
828
- describe "post" do
830
+ describe 'post' do
829
831
 
830
- it "should correctly undo and redo" do
832
+ it 'should correctly undo and redo' do
831
833
  post.update_attributes(title: 'a new title')
832
834
  track = post.history_tracks.last
833
835
  track.undo! user
834
- post.reload.title.should == 'Test'
836
+ expect(post.reload.title).to eq('Test')
835
837
  track.redo! user
836
- post.reload.title.should == 'a new title'
838
+ expect(post.reload.title).to eq('a new title')
837
839
  end
838
840
 
839
- it "should stay the same after undo and redo" do
841
+ it 'should stay the same after undo and redo' do
840
842
  post.update_attributes(title: 'testing')
841
843
  track = post.history_tracks.last
842
844
  track.undo! user
843
845
  track.redo! user
844
- post.reload.title.should == 'testing'
846
+ expect(post.reload.title).to eq('testing')
845
847
  end
846
848
  end
847
- describe "comment" do
848
- it "should correctly undo and redo" do
849
+ describe 'comment' do
850
+ it 'should correctly undo and redo' do
849
851
  comment.update_attributes(title: 'a new title')
850
852
  track = comment.history_tracks.last
851
853
  track.undo! user
852
- comment.reload.title.should == 'test'
854
+ expect(comment.reload.title).to eq('test')
853
855
  track.redo! user
854
- comment.reload.title.should == 'a new title'
856
+ expect(comment.reload.title).to eq('a new title')
855
857
  end
856
858
 
857
- it "should stay the same after undo and redo" do
859
+ it 'should stay the same after undo and redo' do
858
860
  comment.update_attributes(title: 'testing')
859
861
  track = comment.history_tracks.last
860
862
  track.undo! user
861
863
  track.redo! user
862
- comment.reload.title.should == 'testing'
864
+ expect(comment.reload.title).to eq('testing')
863
865
  end
864
866
  end
865
- describe "user" do
866
- it "should correctly undo and redo" do
867
+ describe 'user' do
868
+ it 'should correctly undo and redo' do
867
869
  user.update_attributes(name: 'a new name')
868
870
  track = user.history_tracks.last
869
871
  track.undo! user
870
- user.reload.name.should == 'Aaron'
872
+ expect(user.reload.name).to eq('Aaron')
871
873
  track.redo! user
872
- user.reload.name.should == 'a new name'
874
+ expect(user.reload.name).to eq('a new name')
873
875
  end
874
876
 
875
- it "should stay the same after undo and redo" do
877
+ it 'should stay the same after undo and redo' do
876
878
  user.update_attributes(name: 'testing')
877
879
  track = user.history_tracks.last
878
880
  track.undo! user
879
881
  track.redo! user
880
- user.reload.name.should == 'testing'
882
+ expect(user.reload.name).to eq('testing')
881
883
  end
882
884
  end
883
- describe "tag" do
884
- it "should correctly undo and redo" do
885
+ describe 'tag' do
886
+ it 'should correctly undo and redo' do
885
887
  tag.update_attributes(title: 'a new title')
886
888
  track = tag.history_tracks.last
887
889
  track.undo! user
888
- tag.reload.title.should == 'test'
890
+ expect(tag.reload.title).to eq('test')
889
891
  track.redo! user
890
- tag.reload.title.should == 'a new title'
892
+ expect(tag.reload.title).to eq('a new title')
891
893
  end
892
894
 
893
- it "should stay the same after undo and redo" do
895
+ it 'should stay the same after undo and redo' do
894
896
  tag.update_attributes(title: 'testing')
895
897
  track = tag.history_tracks.last
896
898
  track.undo! user
897
899
  track.redo! user
898
- tag.reload.title.should == 'testing'
900
+ expect(tag.reload.title).to eq('testing')
899
901
  end
900
902
  end
901
903
  end