Skip to content

Commit 54905ff

Browse files
committed
5136
1 parent 28e2d40 commit 54905ff

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spec/mongoid/touchable_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,24 @@
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

spec/mongoid/touchable_spec_models.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)