FIX: change topic creator wasn't removing the topic from the previous creator's activity stream
This commit is contained in:
parent
548707ba14
commit
3a67c02c7a
|
@ -199,7 +199,7 @@ class PostRevisor
|
||||||
create_or_update_revision
|
create_or_update_revision
|
||||||
end
|
end
|
||||||
|
|
||||||
USER_ACTIONS_TO_REMOVE ||= [UserAction::NEW_TOPIC, UserAction::REPLY, UserAction::RESPONSE]
|
USER_ACTIONS_TO_REMOVE ||= [UserAction::REPLY, UserAction::RESPONSE]
|
||||||
|
|
||||||
def update_post
|
def update_post
|
||||||
if @fields.has_key?("user_id") && @fields["user_id"] != @post.user_id
|
if @fields.has_key?("user_id") && @fields["user_id"] != @post.user_id
|
||||||
|
@ -207,10 +207,18 @@ class PostRevisor
|
||||||
new_owner = User.find(@fields["user_id"])
|
new_owner = User.find(@fields["user_id"])
|
||||||
|
|
||||||
# UserActionObserver will create new UserAction records for the new owner
|
# UserActionObserver will create new UserAction records for the new owner
|
||||||
|
|
||||||
UserAction.where(target_post_id: @post.id)
|
UserAction.where(target_post_id: @post.id)
|
||||||
.where(user_id: prev_owner.id)
|
.where(user_id: prev_owner.id)
|
||||||
.where(action_type: USER_ACTIONS_TO_REMOVE)
|
.where(action_type: USER_ACTIONS_TO_REMOVE)
|
||||||
.destroy_all
|
.destroy_all
|
||||||
|
|
||||||
|
if @post.post_number == 1
|
||||||
|
UserAction.where(target_topic_id: @post.topic_id)
|
||||||
|
.where(user_id: prev_owner.id)
|
||||||
|
.where(action_type: UserAction::NEW_TOPIC)
|
||||||
|
.destroy_all
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
POST_TRACKED_FIELDS.each do |field|
|
POST_TRACKED_FIELDS.each do |field|
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe PostOwnerChanger do
|
||||||
p2user.user_stat.update_attributes(topic_count: 0, post_count: 1, first_post_created_at: p2.created_at, topic_reply_count: 1)
|
p2user.user_stat.update_attributes(topic_count: 0, post_count: 1, first_post_created_at: p2.created_at, topic_reply_count: 1)
|
||||||
|
|
||||||
UserAction.create!( action_type: UserAction::NEW_TOPIC, user_id: p1user.id, acting_user_id: p1user.id,
|
UserAction.create!( action_type: UserAction::NEW_TOPIC, user_id: p1user.id, acting_user_id: p1user.id,
|
||||||
target_post_id: p1.id, target_topic_id: p1.topic_id, created_at: p1.created_at )
|
target_post_id: -1, target_topic_id: p1.topic_id, created_at: p1.created_at )
|
||||||
UserAction.create!( action_type: UserAction::REPLY, user_id: p2user.id, acting_user_id: p2user.id,
|
UserAction.create!( action_type: UserAction::REPLY, user_id: p2user.id, acting_user_id: p2user.id,
|
||||||
target_post_id: p2.id, target_topic_id: p2.topic_id, created_at: p2.created_at )
|
target_post_id: p2.id, target_topic_id: p2.topic_id, created_at: p2.created_at )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue