mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Don't count emojis within quotes
This commit is contained in:
parent
56c870cca2
commit
189d70661e
2 changed files with 27 additions and 11 deletions
|
@ -32,12 +32,16 @@ class CookedPostProcessor
|
|||
end
|
||||
end
|
||||
|
||||
def has_emoji?
|
||||
(@doc.css("img.emoji") - @doc.css(".quote img")).size > 0
|
||||
end
|
||||
|
||||
def create_firsts
|
||||
return unless Guardian.new.can_see?(@post)
|
||||
|
||||
created = false
|
||||
|
||||
if @doc.css("img.emoji").size > 0
|
||||
if has_emoji?
|
||||
created |= UserFirst.create_for(@post.user_id, :used_emoji, @post.id)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ describe UserFirst do
|
|||
end
|
||||
end
|
||||
|
||||
it "creates one the first time a user posts an emoji" do
|
||||
context "emoji" do
|
||||
it "logs a user first" do
|
||||
post = PostCreator.create(user, 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
|
||||
|
@ -19,6 +20,17 @@ describe UserFirst do
|
|||
expect(uf.post_id).to eq(post.id)
|
||||
end
|
||||
|
||||
it "doesn't log a user first when in a quote" do
|
||||
PostCreator.create(user,
|
||||
title: "this topic is about candy",
|
||||
raw: "time to eat some sweet [quote]:candy:[/quote] mmmm")
|
||||
|
||||
uf = UserFirst.where(user_id: user.id, first_type: UserFirst.types[:used_emoji]).first
|
||||
expect(uf).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'mentioning' do
|
||||
let(:codinghorror) { Fabricate(:codinghorror) }
|
||||
|
||||
|
@ -34,7 +46,7 @@ describe UserFirst do
|
|||
let(:codinghorror) { Fabricate(:codinghorror) }
|
||||
|
||||
it "doesn't create the userfirst on private posts" do
|
||||
post = PostCreator.create(user,
|
||||
PostCreator.create(user,
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: ['codinghorror'],
|
||||
title: "this topic is about candy",
|
||||
|
|
Loading…
Reference in a new issue