FIX: Moving a post should also update its TopicLink records
This commit is contained in:
parent
22e6b3f466
commit
05fe33111e
|
@ -79,6 +79,9 @@ class PostMover
|
|||
id: post.id,
|
||||
topic_id: original_topic.id
|
||||
)
|
||||
|
||||
# Move any links from the post to the new topic
|
||||
post.topic_links.update_all(topic_id: destination_topic.id)
|
||||
end
|
||||
|
||||
def update_statistics
|
||||
|
|
|
@ -234,7 +234,7 @@ describe Topic do
|
|||
let(:category) { Fabricate(:category, user: user) }
|
||||
let!(:topic) { Fabricate(:topic, user: user, category: category) }
|
||||
let!(:p1) { Fabricate(:post, topic: topic, user: user) }
|
||||
let!(:p2) { Fabricate(:post, topic: topic, user: another_user)}
|
||||
let!(:p2) { Fabricate(:post, topic: topic, user: another_user, raw: "Has a link to [evil trout](http://eviltrout.com) which is a cool site.")}
|
||||
let!(:p3) { Fabricate(:post, topic: topic, user: user)}
|
||||
let!(:p4) { Fabricate(:post, topic: topic, user: user)}
|
||||
|
||||
|
@ -279,6 +279,7 @@ describe Topic do
|
|||
before do
|
||||
topic.expects(:add_moderator_post)
|
||||
TopicUser.update_last_read(user, topic.id, p4.post_number, 0)
|
||||
TopicLink.extract_from(p2)
|
||||
end
|
||||
|
||||
context "to a new topic" do
|
||||
|
@ -303,6 +304,7 @@ describe Topic do
|
|||
p2.reload
|
||||
p2.sort_order.should == 1
|
||||
p2.post_number.should == 1
|
||||
p2.topic_links.first.topic_id.should == new_topic.id
|
||||
|
||||
p4.reload
|
||||
p4.post_number.should == 2
|
||||
|
|
Loading…
Reference in New Issue