mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
Trigger UserActionObserver when tracking visit
This commit is contained in:
parent
685f4960f1
commit
d0bc8c95d3
@ -100,6 +100,8 @@ class TopicUser < ActiveRecord::Base
|
||||
rows = TopicUser.update_all({last_visited_at: now}, {topic_id: topic.id, user_id: user.id})
|
||||
if rows == 0
|
||||
TopicUser.create(topic_id: topic.id, user_id: user.id, last_visited_at: now, first_visited_at: now)
|
||||
else
|
||||
observe_after_save_callbacks_for topic.id, user.id
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -107,6 +107,10 @@ describe TopicUser do
|
||||
topic_user.last_visited_at.to_i.should == today.to_i
|
||||
end
|
||||
|
||||
it 'triggers the observer callbacks when updating' do
|
||||
UserActionObserver.instance.expects(:after_save).twice
|
||||
2.times { TopicUser.track_visit!(topic, user) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'read tracking' do
|
||||
|
Loading…
Reference in New Issue
Block a user