couchbase-orm 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcfde58cff1d73cb5c06b636e946f0dfebc64c6d
4
- data.tar.gz: 0062e73a8e321bae098ddca86d841d3a29b22071
3
+ metadata.gz: 5865b9c3a87fb6300238b0e424626c549eda1b69
4
+ data.tar.gz: 45e8a389b11a3cb72d3b090f6c0e9c748884af21
5
5
  SHA512:
6
- metadata.gz: d4542142c00446e685e475586ef6d18fc73d1e74f9ea5dec98c6c38c125d21579e24b037a17d015a2b24b82398a36331f939439ff5174f870c20f2f61daba9df
7
- data.tar.gz: e2cf0e2089143115321a74ea8d1623bc48f7d79492cf42c8312ba42c79cb2645688023085b55bb1959f99f11f47c028f7abc3f9ef4d89a00f9e8abb97432f8dd
6
+ metadata.gz: c18d3a63d8273e8726daf7fdebf35db797a5573f15712473e516b26189876dfc78acb287da7c0974da0b43301f34db06c23187f4e79231c7374b6882d1d93473
7
+ data.tar.gz: 469ea894cb417b267224790a70658ace4401e5bed3ada5763823a42d1a8732fbce3cb6d6352cf1d19cd885ffbe7902b8b99525865498dddbcd30575acb2954c3
@@ -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
- @__attributes__ = attributes
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true, encoding: ASCII-8BIT
2
2
 
3
3
  module CouchbaseOrm
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-orm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach