From 64a1a44c4bcf94d96463e34d1b39783baed5dc58 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 5 Apr 2016 16:13:10 -0400 Subject: [PATCH] FIX: Don't create user first records on private posts --- lib/cooked_post_processor.rb | 2 ++ spec/models/user_firsts_spec.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 58c599b75eb..bab2cee5164 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -33,6 +33,8 @@ class CookedPostProcessor end def create_firsts + return unless Guardian.new.can_see?(@post) + created = false if @doc.css("img.emoji").size > 0 diff --git a/spec/models/user_firsts_spec.rb b/spec/models/user_firsts_spec.rb index 69bc5996d28..d956875bc3f 100644 --- a/spec/models/user_firsts_spec.rb +++ b/spec/models/user_firsts_spec.rb @@ -30,4 +30,17 @@ describe UserFirst do 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