Skip to content

Commit

Permalink
add touch option on message model
Browse files Browse the repository at this point in the history
  • Loading branch information
sairamsrinivasan committed May 27, 2024
1 parent ef72704 commit 3687747
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spec/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class Message
field :to

if Mongoid::Compatibility::Version.mongoid6_or_newer?
belongs_to :user, optional: true
belongs_to :user, optional: true, touch: true
else
belongs_to :user, touch: true
belongs_to :user
end

validates :identifier, uniqueness: { message: 'uniqueness' }
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/associations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

describe Message do
if Mongoid::Compatibility::Version.mongoid6_or_newer?
it { is_expected.to belong_to(:user).with_optional }
it { is_expected.to belong_to(:user).with_optional.with_touch(true) }
end
end
end

0 comments on commit 3687747

Please sign in to comment.