FIX: Don't create user first records on private posts

This commit is contained in:
Robin Ward 2016-04-05 16:13:10 -04:00
parent 50fbda1ab7
commit 64a1a44c4b
2 changed files with 15 additions and 0 deletions

View file

@ -33,6 +33,8 @@ class CookedPostProcessor
end end
def create_firsts def create_firsts
return unless Guardian.new.can_see?(@post)
created = false created = false
if @doc.css("img.emoji").size > 0 if @doc.css("img.emoji").size > 0

View file

@ -30,4 +30,17 @@ describe UserFirst do
end end
end end
context "privacy" do
let(:codinghorror) { Fabricate(:codinghorror) }
it "doesn't create the userfirst on private posts" do
post = PostCreator.create(user,
target_usernames: ['codinghorror'],
title: "this topic is about candy",
raw: "time to eat some sweet :candy: mmmm")
uf = UserFirst.where(user_id: user.id, first_type: UserFirst.types[:used_emoji]).first
expect(uf).to be_blank
end
end
end end