snapshotar 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/snapshotar/core.rb +4 -4
- data/lib/snapshotar/version.rb +1 -1
- data/spec/core_spec.rb +7 -8
- data/spec/models/event.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eead98da02453289ae68ea25f600fa1bfc8ce6aa
|
4
|
+
data.tar.gz: 43f83bf030a85fb47995174b2d306d1e48396496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d531135472e03c551a54fb57014c24fe95ab5c31451fd717c851628bb64f4b555f8c291378230366efc8dc723c7aeb73b63a57e72997a17e059627c468f000d6
|
7
|
+
data.tar.gz: 50bf8d4690cf1333c93e8475ff2e0b528edb8e65d4e5c58b0549289725955ee702ad36b3954463d3e99cf2d0d6841878e050735f6339b89ab43fa9de960183e9
|
data/lib/snapshotar/core.rb
CHANGED
@@ -37,14 +37,14 @@ module Snapshotar
|
|
37
37
|
|
38
38
|
serialized = Jbuilder.encode do |json|
|
39
39
|
Snapshotar.configuration.models.each do |m|
|
40
|
-
|
41
|
-
json.set!
|
40
|
+
model = m.first
|
41
|
+
json.set! model.name do
|
42
42
|
|
43
43
|
# iterate objects
|
44
|
-
json.array!
|
44
|
+
json.array! model.unscoped.all do |itm|
|
45
45
|
|
46
46
|
# support inherited classes
|
47
|
-
json.set! :clazz, itm.class.to_s unless (itm.class.to_s ==
|
47
|
+
json.set! :clazz, itm.class.to_s unless (itm.class.to_s == model.name)
|
48
48
|
|
49
49
|
# iterate attributes
|
50
50
|
m[1..-1].each do |attr|
|
data/lib/snapshotar/version.rb
CHANGED
data/spec/core_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Snapshotar::Core do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# create sample data
|
26
|
-
Event.create({name: "Event 1", date: Date.new})
|
26
|
+
Event.create({name: "Event 1", date: Date.new, published: false})
|
27
27
|
Event.create({name: "Event 2", date: Date.new})
|
28
28
|
|
29
29
|
Artist.create({name: "Artist 1"})
|
@@ -41,8 +41,8 @@ describe Snapshotar::Core do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should have one Event" do
|
44
|
-
expect(Event.count).to eq 2
|
45
|
-
expect(Artist.count).to eq 2
|
44
|
+
expect(Event.unscoped.count).to eq 2
|
45
|
+
expect(Artist.unscoped.count).to eq 2
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should correctly read config models" do
|
@@ -56,7 +56,6 @@ describe Snapshotar::Core do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
# p "serialized: #{serialized}"
|
60
59
|
end
|
61
60
|
|
62
61
|
it "should export models" do
|
@@ -74,14 +73,14 @@ describe Snapshotar::Core do
|
|
74
73
|
# clear db
|
75
74
|
Mongoid.purge!
|
76
75
|
|
77
|
-
expect(Event.count).to eq 0
|
78
|
-
expect(Artist.count).to eq 0
|
76
|
+
expect(Event.unscoped.count).to eq 0
|
77
|
+
expect(Artist.unscoped.count).to eq 0
|
79
78
|
|
80
79
|
# reimport
|
81
80
|
Snapshotar.load(filename)
|
82
81
|
|
83
|
-
expect(Event.count).to eq 2
|
84
|
-
expect(Artist.count).to eq 2
|
82
|
+
expect(Event.unscoped.count).to eq 2
|
83
|
+
expect(Artist.unscoped.count).to eq 2
|
85
84
|
|
86
85
|
# clean up
|
87
86
|
Snapshotar.delete(filename)
|
data/spec/models/event.rb
CHANGED