BUGFIX: no reading credit for posts you create
This commit is contained in:
parent
2eac7128dc
commit
c6c412fd45
|
@ -269,13 +269,21 @@ class PostCreator
|
|||
def track_topic
|
||||
return if @opts[:auto_track] == false
|
||||
|
||||
TopicUser.auto_track(@user.id, @topic.id, TopicUser.notification_reasons[:created_post])
|
||||
# Update topic user data
|
||||
TopicUser.change(@post.user.id,
|
||||
@post.topic.id,
|
||||
posted: true,
|
||||
last_read_post_number: @post.post_number,
|
||||
seen_post_count: @post.post_number)
|
||||
|
||||
|
||||
# assume it took us 5 seconds of reading time to make a post
|
||||
PostTiming.record_timing(topic_id: @post.topic_id,
|
||||
user_id: @post.user_id,
|
||||
post_number: @post.post_number,
|
||||
msecs: 5000)
|
||||
|
||||
|
||||
TopicUser.auto_track(@user.id, @topic.id, TopicUser.notification_reasons[:created_post])
|
||||
end
|
||||
|
||||
def enqueue_jobs
|
||||
|
|
|
@ -429,10 +429,22 @@ describe PostCreator do
|
|||
embed_url: embed_url,
|
||||
title: 'Reviews of Science Ovens',
|
||||
raw: 'Did you know that you can use microwaves to cook your dinner? Science!')
|
||||
post = creator.create
|
||||
creator.create
|
||||
TopicEmbed.where(embed_url: embed_url).exists?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "read credit for creator" do
|
||||
it "should give credit to creator" do
|
||||
post = create_post
|
||||
PostTiming.find_by(topic_id: post.topic_id,
|
||||
post_number: post.post_number,
|
||||
user_id: post.user_id).msecs.should be > 0
|
||||
|
||||
TopicUser.find_by(topic_id: post.topic_id,
|
||||
user_id: post.user_id).last_read_post_number.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue