Render op markers for coauthors (#11294)
This commit is contained in:
parent
47be7ea322
commit
0b8f28e1c8
3 changed files with 21 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ module CommentsHelper
|
|||
[
|
||||
commentable.user_id,
|
||||
commentable.co_author_ids,
|
||||
].any? { |id| id == comment.user_id }
|
||||
].flatten.any? { |id| id == comment.user_id }
|
||||
end
|
||||
|
||||
def get_ama_or_op_banner(commentable)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ FactoryBot.define do
|
|||
with_title { true }
|
||||
with_collection { nil }
|
||||
end
|
||||
co_author_ids { [] }
|
||||
association :user, factory: :user, strategy: :create
|
||||
description { Faker::Hipster.paragraph(sentence_count: 1)[0..100] }
|
||||
main_image { with_main_image ? Faker::Avatar.image : nil }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe "Views an article", type: :system, js: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:article) { create(:article, user: user) }
|
||||
let(:co_author) { create(:user) }
|
||||
let(:article) { create(:article, user: user, co_author_ids: [co_author.id]) }
|
||||
let(:ama_article) { create(:article, user: user, tags: "ama") }
|
||||
|
||||
let!(:comment) { create(:comment, commentable: article) }
|
||||
let!(:child_comment) { create(:comment, parent: comment, commentable: article) }
|
||||
|
|
@ -12,6 +14,22 @@ RSpec.describe "Views an article", type: :system, js: true do
|
|||
visit "#{article.path}/comments"
|
||||
|
||||
expect(page).to have_selector(".single-comment-node", visible: :visible, count: 3)
|
||||
expect(page).not_to have_selector(".op-marker")
|
||||
end
|
||||
|
||||
it "shows op marker on author and co-author comments" do
|
||||
create(:comment, user: user, commentable: article)
|
||||
create(:comment, user: co_author, commentable: article)
|
||||
visit "#{article.path}/comments"
|
||||
|
||||
expect(page).to have_selector(".op-marker", visible: :visible, text: "Author", count: 2)
|
||||
end
|
||||
|
||||
it "shows special op marker on ama articles" do
|
||||
create(:comment, user: user, commentable: ama_article)
|
||||
visit "#{ama_article.path}/comments"
|
||||
|
||||
expect(page).to have_selector(".op-marker", visible: :visible, text: "Ask Me Anything")
|
||||
end
|
||||
|
||||
it "shows a thread" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue