FIX: Incorrect scope when checking for existing topic link.

This commit is contained in:
Guo Xiang Tan 2016-06-15 13:45:07 +08:00
parent e1cfe7536c
commit bf64280661
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
2 changed files with 11 additions and 1 deletions

View File

@ -161,7 +161,7 @@ class TopicLink < ActiveRecord::Base
added_urls << url
topic_link = TopicLink.find_by(topic_id: post.topic_id,
user_id: post.user_id,
post_id: post.id,
url: url)
unless topic_link

View File

@ -121,6 +121,16 @@ http://b.com/#{'a'*500}
expect(reflection.user_id).to eq(link.user_id)
end
PostOwnerChanger.new(
post_ids: [linked_post.id],
topic_id: topic.id,
acting_user: user,
new_owner: Fabricate(:user)
).change_owner!
TopicLink.extract_from(linked_post)
expect(topic.topic_links.first.url).to eq(url)
linked_post.revise(post.user, { raw: "no more linkies https://eviltrout.com" })
expect(other_topic.topic_links.where(link_post_id: linked_post.id)).to be_blank
end