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 132132 include_examples 'updates the child'
133133 include_examples 'updates the parent when :touch is true'
134134 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
135153 end
136154
137155 context "when the document is referenced" do
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class Entrance
1616 include Mongoid ::Timestamps
1717
1818 embedded_in :building
19+
20+ field :last_used_at , type : Time
1921 end
2022
2123 class Floor
You can’t perform that action at this time.
0 commit comments