mongoid-versioning 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/Gemfile +0 -6
- data/README.md +4 -3
- data/lib/mongoid/versioning/version.rb +1 -1
- data/mongoid-versioning.gemspec +4 -1
- data/spec/mongoid/errors/versioning_not_on_root_spec.rb +3 -3
- data/spec/mongoid/relations/metadata_spec.rb +3 -3
- data/spec/mongoid/versioning_spec.rb +44 -44
- metadata +48 -8
- data/gemfiles/mongoid_master.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46474f928419c4372f2beeb6d5b2a63dff74b42f
|
4
|
+
data.tar.gz: bedfa1cb96865a658317fb64d20c5420eca5137d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0aca13cbe1f76a96cc20a9e5c4325132fa5e0f6c65ea4a68acaa4ce67e96cb00e7263a5348a9db800e41f2f247c4715bdd131810f3ec2ab39ed2ed9d4090e7e
|
7
|
+
data.tar.gz: 6be363e0faa694cb0613a7d3a58ab7ea5ab59a33c30b8efe8d65f8554447132d75f059b60fb0bb817fbe4c6f78a7b8a2e512e8a24eaf558d7f415943ee524b05
|
data/.travis.yml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
language: ruby
|
2
|
+
services: mongodb
|
2
3
|
|
3
4
|
rvm:
|
4
5
|
- 1.9.3
|
5
6
|
- 2.0.0
|
6
7
|
- 2.1.0
|
7
|
-
- ruby-head
|
8
8
|
|
9
9
|
gemfile:
|
10
10
|
- Gemfile
|
11
|
-
- gemfiles/mongoid_master.gemfile
|
12
11
|
|
13
12
|
branches:
|
14
13
|
only:
|
@@ -17,4 +16,3 @@ branches:
|
|
17
16
|
matrix:
|
18
17
|
allow_failures:
|
19
18
|
- rvm: ruby-head
|
20
|
-
- gemfile: gemfiles/mongoid_master.gemfile
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# mongoid-versioning [![Build Status](https://travis-ci.org/haihappen/mongoid-versioning.png)](https://travis-ci.org/haihappen/mongoid-versioning)
|
2
2
|
|
3
|
-
**Important:** This gem is an extraction of [Mongoid::Versioning](http://mongoid.org/en/mongoid/
|
3
|
+
**Important:** This gem is an extraction of [Mongoid::Versioning](http://mongoid.org/en/mongoid/v3/extras.html#versioning) from the official [mongoid](http://mongoid.org) gem.
|
4
|
+
Since Mongoid::Versioning was removed in the `4.0.0` release of Mongoid, this gem re-enables the functionality of versioned documents.
|
4
5
|
|
5
|
-
**Please submit only bug and security fixes**. Neighter I will accept new features nor changes to
|
6
|
+
**Please submit only bug and security fixes**. Neighter I will accept new features nor changes to existing APIs. Please consider forking the project if you want new features to appear! :)
|
6
7
|
|
7
8
|
---
|
8
9
|
|
@@ -57,7 +58,7 @@ end
|
|
57
58
|
|
58
59
|
(The MIT license)
|
59
60
|
|
60
|
-
Copyright (c) 2013 Mario Uher
|
61
|
+
Copyright (c) 2013-2014 Mario Uher
|
61
62
|
|
62
63
|
Permission is hereby granted, free of charge, to any person obtaining
|
63
64
|
a copy of this software and associated documentation files (the
|
data/mongoid-versioning.gemspec
CHANGED
@@ -14,5 +14,8 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.require_path = 'lib'
|
15
15
|
|
16
16
|
gem.add_dependency 'activesupport'
|
17
|
-
gem.add_dependency 'mongoid', '4.0.0
|
17
|
+
gem.add_dependency 'mongoid', '~> 4.0.0'
|
18
|
+
gem.add_development_dependency 'mongoid-paranoia', '1.0.0.beta2'
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
18
21
|
end
|
@@ -9,19 +9,19 @@ describe Mongoid::Errors::VersioningNotOnRoot do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "contains the problem in the message" do
|
12
|
-
error.message.
|
12
|
+
expect(error.message).to include(
|
13
13
|
"Versioning not allowed on embedded document: Address."
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "contains the summary in the message" do
|
18
|
-
error.message.
|
18
|
+
expect(error.message).to include(
|
19
19
|
"Mongoid::Versioning behaviour is only allowed on documents"
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "contains the resolution in the message" do
|
24
|
-
error.message.
|
24
|
+
expect(error.message).to include(
|
25
25
|
"Remove the versioning from the embedded Address"
|
26
26
|
)
|
27
27
|
end
|
@@ -14,7 +14,7 @@ describe Mongoid::Relations::Metadata do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "returns true" do
|
17
|
-
metadata.
|
17
|
+
expect(metadata).to be_versioned
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -29,7 +29,7 @@ describe Mongoid::Relations::Metadata do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns false" do
|
32
|
-
metadata.
|
32
|
+
expect(metadata).not_to be_versioned
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -43,7 +43,7 @@ describe Mongoid::Relations::Metadata do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns false" do
|
46
|
-
metadata.
|
46
|
+
expect(metadata).not_to be_versioned
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -15,7 +15,7 @@ describe Mongoid::Versioning do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "sets the class version max" do
|
18
|
-
WikiPage.version_max.
|
18
|
+
expect(WikiPage.version_max).to eq(10)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,7 +30,7 @@ describe Mongoid::Versioning do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "sets the class version max" do
|
33
|
-
WikiPage.version_max.
|
33
|
+
expect(WikiPage.version_max).to eq(10)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -42,7 +42,7 @@ describe Mongoid::Versioning do
|
|
42
42
|
context "when the document is new" do
|
43
43
|
|
44
44
|
it "returns 1" do
|
45
|
-
WikiPage.new.version.
|
45
|
+
expect(WikiPage.new.version).to eq(1)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -53,7 +53,7 @@ describe Mongoid::Versioning do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "returns 1" do
|
56
|
-
page.version.
|
56
|
+
expect(page.version).to eq(1)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -68,7 +68,7 @@ describe Mongoid::Versioning do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "returns the number of versions" do
|
71
|
-
page.version.
|
71
|
+
expect(page.version).to eq(4)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -85,7 +85,7 @@ describe Mongoid::Versioning do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it "returns the number of versions" do
|
88
|
-
page.version.
|
88
|
+
expect(page.version).to eq(11)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -103,7 +103,7 @@ describe Mongoid::Versioning do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
it "does not increment the version number" do
|
106
|
-
page.version.
|
106
|
+
expect(page.version).to eq(1)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -123,7 +123,7 @@ describe Mongoid::Versioning do
|
|
123
123
|
context "when the document is new" do
|
124
124
|
|
125
125
|
it "returns 1" do
|
126
|
-
WikiPage.new.version.
|
126
|
+
expect(WikiPage.new.version).to eq(1)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -134,7 +134,7 @@ describe Mongoid::Versioning do
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it "returns 1" do
|
137
|
-
page.version.
|
137
|
+
expect(page.version).to eq(1)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -149,7 +149,7 @@ describe Mongoid::Versioning do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
it "returns the number of versions" do
|
152
|
-
page.version.
|
152
|
+
expect(page.version).to eq(4)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -166,7 +166,7 @@ describe Mongoid::Versioning do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
it "returns the number of versions" do
|
169
|
-
page.version.
|
169
|
+
expect(page.version).to eq(11)
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -184,7 +184,7 @@ describe Mongoid::Versioning do
|
|
184
184
|
end
|
185
185
|
|
186
186
|
it "does not increment the version number" do
|
187
|
-
page.version.
|
187
|
+
expect(page.version).to eq(1)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -200,7 +200,7 @@ describe Mongoid::Versioning do
|
|
200
200
|
context "when the document is persisted once" do
|
201
201
|
|
202
202
|
it "returns 1" do
|
203
|
-
page.version.
|
203
|
+
expect(page.version).to eq(1)
|
204
204
|
end
|
205
205
|
|
206
206
|
it "does not persist to default database" do
|
@@ -210,7 +210,7 @@ describe Mongoid::Versioning do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
it "persists to specified database" do
|
213
|
-
WikiPage.with(database: "mongoid_test_alt").find_by(title: title).
|
213
|
+
expect(WikiPage.with(database: "mongoid_test_alt").find_by(title: title)).not_to be_nil
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
@@ -221,15 +221,15 @@ describe Mongoid::Versioning do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
it "returns the number of versions" do
|
224
|
-
page.version.
|
224
|
+
expect(page.version).to eq(4)
|
225
225
|
end
|
226
226
|
|
227
227
|
it "persists to specified database" do
|
228
|
-
WikiPage.with(database: "mongoid_test_alt").find_by(:title => title).
|
228
|
+
expect(WikiPage.with(database: "mongoid_test_alt").find_by(:title => title)).not_to be_nil
|
229
229
|
end
|
230
230
|
|
231
231
|
it "persists the versions to specified database" do
|
232
|
-
WikiPage.with(database: "mongoid_test_alt").find_by(:title => title).version.
|
232
|
+
expect(WikiPage.with(database: "mongoid_test_alt").find_by(:title => title).version).to eq(4)
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -245,7 +245,7 @@ describe Mongoid::Versioning do
|
|
245
245
|
|
246
246
|
it "sets versionless to true" do
|
247
247
|
page.versionless do |doc|
|
248
|
-
doc.
|
248
|
+
expect(doc.send(:versionless?)).to be_truthy
|
249
249
|
end
|
250
250
|
end
|
251
251
|
end
|
@@ -254,7 +254,7 @@ describe Mongoid::Versioning do
|
|
254
254
|
|
255
255
|
it "sets versionless to false" do
|
256
256
|
page.versionless
|
257
|
-
page.
|
257
|
+
expect(page.send(:versionless?)).to be_falsy
|
258
258
|
end
|
259
259
|
end
|
260
260
|
end
|
@@ -280,23 +280,23 @@ describe Mongoid::Versioning do
|
|
280
280
|
end
|
281
281
|
|
282
282
|
it "creates a new version" do
|
283
|
-
version.title.
|
283
|
+
expect(version.title).to eq("1")
|
284
284
|
end
|
285
285
|
|
286
286
|
it "properly versions the localized fields" do
|
287
|
-
version.description.
|
287
|
+
expect(version.description).to eq("test")
|
288
288
|
end
|
289
289
|
|
290
290
|
it "only creates 1 new version" do
|
291
|
-
page.versions.count.
|
291
|
+
expect(page.versions.count).to eq(1)
|
292
292
|
end
|
293
293
|
|
294
294
|
it "does not version the _id" do
|
295
|
-
version._id.
|
295
|
+
expect(version._id).to be_nil
|
296
296
|
end
|
297
297
|
|
298
298
|
it "does version the updated_at timestamp" do
|
299
|
-
version.updated_at.
|
299
|
+
expect(version.updated_at).not_to be_nil
|
300
300
|
end
|
301
301
|
|
302
302
|
context "when only updated_at was changed" do
|
@@ -306,16 +306,16 @@ describe Mongoid::Versioning do
|
|
306
306
|
end
|
307
307
|
|
308
308
|
it "does not generate another version" do
|
309
|
-
page.versions.count.
|
309
|
+
expect(page.versions.count).to eq(1)
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
313
|
it "does not embed versions within versions" do
|
314
|
-
version.versions.
|
314
|
+
expect(version.versions).to be_empty
|
315
315
|
end
|
316
316
|
|
317
317
|
it "versions protected fields" do
|
318
|
-
version.author.
|
318
|
+
expect(version.author).to eq("woodchuck")
|
319
319
|
end
|
320
320
|
|
321
321
|
context "when saving multiple times" do
|
@@ -325,11 +325,11 @@ describe Mongoid::Versioning do
|
|
325
325
|
end
|
326
326
|
|
327
327
|
it "does not embed versions within versions" do
|
328
|
-
version.versions.
|
328
|
+
expect(version.versions).to be_empty
|
329
329
|
end
|
330
330
|
|
331
331
|
it "does not embed versions multiple levels deep" do
|
332
|
-
page.versions.last.versions.
|
332
|
+
expect(page.versions.last.versions).to be_empty
|
333
333
|
end
|
334
334
|
end
|
335
335
|
end
|
@@ -345,7 +345,7 @@ describe Mongoid::Versioning do
|
|
345
345
|
end
|
346
346
|
|
347
347
|
it "does not create a new version" do
|
348
|
-
version.
|
348
|
+
expect(version).to be_nil
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
@@ -364,11 +364,11 @@ describe Mongoid::Versioning do
|
|
364
364
|
end
|
365
365
|
|
366
366
|
it "only versions the maximum amount" do
|
367
|
-
post.versions.target.size.
|
367
|
+
expect(post.versions.target.size).to eq(2)
|
368
368
|
end
|
369
369
|
|
370
370
|
it "persists the changes" do
|
371
|
-
post.reload.versions.target.size.
|
371
|
+
expect(post.reload.versions.target.size).to eq(2)
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
@@ -385,15 +385,15 @@ describe Mongoid::Versioning do
|
|
385
385
|
end
|
386
386
|
|
387
387
|
it "only versions the maximum amount" do
|
388
|
-
versions.count.
|
388
|
+
expect(versions.count).to eq(5)
|
389
389
|
end
|
390
390
|
|
391
391
|
it "shifts the versions in order" do
|
392
|
-
versions.last.title.
|
392
|
+
expect(versions.last.title).to eq("8")
|
393
393
|
end
|
394
394
|
|
395
395
|
it "persists the version shifts" do
|
396
|
-
page.reload.versions.last.title.
|
396
|
+
expect(page.reload.versions.last.title).to eq("8")
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -416,7 +416,7 @@ describe Mongoid::Versioning do
|
|
416
416
|
end
|
417
417
|
|
418
418
|
it "only versions the maximum amount" do
|
419
|
-
versions.count.
|
419
|
+
expect(versions.count).to eq(5)
|
420
420
|
end
|
421
421
|
end
|
422
422
|
end
|
@@ -428,7 +428,7 @@ describe Mongoid::Versioning do
|
|
428
428
|
end
|
429
429
|
|
430
430
|
it "does not version the document" do
|
431
|
-
page.versions.count.
|
431
|
+
expect(page.versions.count).to eq(0)
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
@@ -458,23 +458,23 @@ describe Mongoid::Versioning do
|
|
458
458
|
end
|
459
459
|
|
460
460
|
it "does not perform dependent cascading" do
|
461
|
-
from_db.
|
461
|
+
expect(from_db).to eq(comment)
|
462
462
|
end
|
463
463
|
|
464
464
|
it "does not delete related orphans" do
|
465
|
-
Comment.find(orphaned.id).
|
465
|
+
expect(Comment.find(orphaned.id)).to eq(orphaned)
|
466
466
|
end
|
467
467
|
|
468
468
|
it "deletes the version" do
|
469
|
-
page.versions.
|
469
|
+
expect(page.versions).to be_empty
|
470
470
|
end
|
471
471
|
|
472
472
|
it "persists the deletion" do
|
473
|
-
page.reload.versions.
|
473
|
+
expect(page.reload.versions).to be_empty
|
474
474
|
end
|
475
475
|
|
476
476
|
it "retains the root relation" do
|
477
|
-
page.reload.comments.
|
477
|
+
expect(page.reload.comments).to eq([ comment ])
|
478
478
|
end
|
479
479
|
end
|
480
480
|
end
|
@@ -496,11 +496,11 @@ describe Mongoid::Versioning do
|
|
496
496
|
end
|
497
497
|
|
498
498
|
it "allows the document to be added" do
|
499
|
-
page.child_pages.
|
499
|
+
expect(page.child_pages).to eq([ child ])
|
500
500
|
end
|
501
501
|
|
502
502
|
it "persists the changes" do
|
503
|
-
page.reload.child_pages.
|
503
|
+
expect(page.reload.child_pages).to eq([ child ])
|
504
504
|
end
|
505
505
|
end
|
506
506
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-versioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Uher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -28,16 +28,58 @@ dependencies:
|
|
28
28
|
name: mongoid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.0.0
|
33
|
+
version: 4.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mongoid-paranoia
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
45
|
- - '='
|
39
46
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
47
|
+
version: 1.0.0.beta2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0.beta2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
41
83
|
description: Mongoid supports simple versioning through inclusion of the Mongoid::Versioning
|
42
84
|
module.
|
43
85
|
email: uher.mario@gmail.com
|
@@ -51,7 +93,6 @@ files:
|
|
51
93
|
- Gemfile
|
52
94
|
- README.md
|
53
95
|
- Rakefile
|
54
|
-
- gemfiles/mongoid_master.gemfile
|
55
96
|
- lib/mongoid/config/locales/en.yml
|
56
97
|
- lib/mongoid/core_ext/errors/versioning_not_on_root.rb
|
57
98
|
- lib/mongoid/core_ext/fields/standard.rb
|
@@ -277,9 +318,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
318
|
version: 1.3.1
|
278
319
|
requirements: []
|
279
320
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.2.
|
321
|
+
rubygems_version: 2.2.2
|
281
322
|
signing_key:
|
282
323
|
specification_version: 4
|
283
324
|
summary: Extraction of mongoid-versioning into its own gem.
|
284
325
|
test_files: []
|
285
|
-
has_rdoc:
|