File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 132
132
include_examples 'updates the child'
133
133
include_examples 'updates the parent when :touch is true'
134
134
include_examples 'updates the parent when :touch is not set'
135
+
136
+ context 'when also updating an additional field' do
137
+ it 'persists the update to the additional field' do
138
+ entrance
139
+ update_time
140
+ entrance . touch ( :last_used_at )
141
+
142
+ entrance . reload
143
+ building . reload
144
+
145
+ # This is the assertion we want.
146
+ entrance . last_used_at . should == update_time
147
+
148
+ # Check other timestamps for good measure.
149
+ entrance . updated_at . should == update_time
150
+ building . updated_at . should == update_time
151
+ end
152
+ end
135
153
end
136
154
137
155
context "when the document is referenced" do
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class Entrance
16
16
include Mongoid ::Timestamps
17
17
18
18
embedded_in :building
19
+
20
+ field :last_used_at , type : Time
19
21
end
20
22
21
23
class Floor
You can’t perform that action at this time.
0 commit comments