FIX: Fix ActiveRecord API that was removed in Rails 5.1.
This commit is contained in:
parent
cf9607a0cb
commit
4e5e7dc736
|
@ -473,7 +473,7 @@ class PostAlerter
|
|||
post.topic_links.where(reflection: false).map do |link|
|
||||
linked_post = link.link_post
|
||||
if !linked_post && topic = link.link_topic
|
||||
linked_post = topic.posts(post_number: 1).first
|
||||
linked_post = topic.posts.find_by(post_number: 1)
|
||||
end
|
||||
(linked_post && post.user_id != linked_post.user_id && linked_post.user) || nil
|
||||
end.compact
|
||||
|
|
|
@ -257,7 +257,6 @@ describe PostAlerter do
|
|||
# don't notify on reflection
|
||||
post1.reload
|
||||
expect(PostAlerter.new.extract_linked_users(post1).length).to eq(0)
|
||||
|
||||
end
|
||||
|
||||
it "triggers :before_create_notifications_for_users" do
|
||||
|
@ -606,4 +605,29 @@ describe PostAlerter do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#extract_linked_users' do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:post) { Fabricate(:post, topic: topic) }
|
||||
let(:post2) { Fabricate(:post) }
|
||||
|
||||
describe 'when linked post has been deleted' do
|
||||
let(:topic_link) do
|
||||
TopicLink.create!(
|
||||
url: "/t/#{topic.id}",
|
||||
topic_id: topic.id,
|
||||
link_topic_id: post2.topic.id,
|
||||
link_post_id: nil,
|
||||
post_id: post.id,
|
||||
user: user,
|
||||
domain: 'test.com'
|
||||
)
|
||||
end
|
||||
|
||||
it 'should use the first post of the topic' do
|
||||
topic_link
|
||||
expect(PostAlerter.new.extract_linked_users(post.reload)).to eq([post2.user])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue