couchbase-orm 0.1.0 → 0.1.1
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/couchbase-orm/base.rb +5 -2
- data/lib/couchbase-orm/version.rb +1 -1
- data/spec/base_spec.rb +27 -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: 5865b9c3a87fb6300238b0e424626c549eda1b69
|
4
|
+
data.tar.gz: 45e8a389b11a3cb72d3b090f6c0e9c748884af21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c18d3a63d8273e8726daf7fdebf35db797a5573f15712473e516b26189876dfc78acb287da7c0974da0b43301f34db06c23187f4e79231c7374b6882d1d93473
|
7
|
+
data.tar.gz: 469ea894cb417b267224790a70658ace4401e5bed3ada5763823a42d1a8732fbce3cb6d6352cf1d19cd885ffbe7902b8b99525865498dddbcd30575acb2954c3
|
data/lib/couchbase-orm/base.rb
CHANGED
@@ -167,20 +167,23 @@ module CouchbaseOrm
|
|
167
167
|
|
168
168
|
# This ensures that defaults are applied
|
169
169
|
@__attributes__.merge! doc
|
170
|
+
clear_changes_information
|
170
171
|
when CouchbaseOrm::Base
|
172
|
+
clear_changes_information
|
171
173
|
attributes = model.attributes
|
172
174
|
attributes.delete(:id)
|
173
|
-
|
175
|
+
super(attributes)
|
174
176
|
else
|
177
|
+
clear_changes_information
|
175
178
|
super(attributes.merge(Hash(model)))
|
176
179
|
end
|
177
180
|
else
|
181
|
+
clear_changes_information
|
178
182
|
super(attributes)
|
179
183
|
end
|
180
184
|
|
181
185
|
yield self if block_given?
|
182
186
|
|
183
|
-
clear_changes_information
|
184
187
|
run_callbacks :initialize
|
185
188
|
end
|
186
189
|
|
data/spec/base_spec.rb
CHANGED
@@ -64,6 +64,33 @@ describe CouchbaseOrm::Base do
|
|
64
64
|
base.destroy
|
65
65
|
end
|
66
66
|
|
67
|
+
it "should support dirty attributes" do
|
68
|
+
begin
|
69
|
+
base = BaseTest.new
|
70
|
+
expect(base.changes.empty?).to be(true)
|
71
|
+
expect(base.previous_changes.empty?).to be(true)
|
72
|
+
|
73
|
+
base.name = 'change'
|
74
|
+
expect(base.changes.empty?).to be(false)
|
75
|
+
|
76
|
+
base = BaseTest.new({name: 'bob'})
|
77
|
+
expect(base.changes.empty?).to be(false)
|
78
|
+
expect(base.previous_changes.empty?).to be(true)
|
79
|
+
|
80
|
+
# A saved model should have no changes
|
81
|
+
base = BaseTest.create!(name: 'joe')
|
82
|
+
expect(base.changes.empty?).to be(true)
|
83
|
+
expect(base.previous_changes.empty?).to be(false)
|
84
|
+
|
85
|
+
# Attributes are copied from the existing model
|
86
|
+
base = BaseTest.new(base)
|
87
|
+
expect(base.changes.empty?).to be(false)
|
88
|
+
expect(base.previous_changes.empty?).to be(true)
|
89
|
+
ensure
|
90
|
+
base.destroy if base.id
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
67
94
|
it "should try to load a model with nothing but an ID" do
|
68
95
|
begin
|
69
96
|
base = BaseTest.create!(name: 'joe')
|