Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions engine/app/views/coplan/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%# Per-viewer affordances (Delete) are hidden client-side by the
comment_actions Stimulus controller — broadcasts render once with no
comment_actions Stimulus controller — one broadcast is shared with every
`current_user`, so we ship the button on every human comment and let
the browser remove it for non-authors. Server still enforces auth. %>
<div class="comment <%= 'comment--deleted' if comment.deleted? %>"
Expand All @@ -24,7 +24,8 @@
· <%= time_ago_in_words(comment.created_at) %> ago
</div>
<div class="comment__body">
<%= cache(comment) do %>
<%# The record version invalidates edits; bump this namespace when Markdown rendering changes. %>
<%= cache(["comment-body-v1", comment], skip_digest: true) do %>
<%= render_markdown(comment.body_markdown) %>
<% end %>
</div>
Expand Down
16 changes: 16 additions & 0 deletions spec/requests/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
expect(comment.author_id).to eq(alice.id)
end

it "does not calculate a template digest while broadcasting a reply" do
original_perform_caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = true
allow(ActionView::Digestor).to receive(:digest).and_call_original
allow(Rails.cache).to receive(:read).and_call_original

post plan_comment_thread_comments_path(plan, thread_record), params: {
comment: { body_markdown: "This should return without digesting the partial." }
}

expect(Rails.cache).to have_received(:read)
expect(ActionView::Digestor).not_to have_received(:digest)
ensure
ActionController::Base.perform_caching = original_perform_caching
end

describe "DELETE destroy" do
let!(:comment) do
create(:comment, comment_thread: thread_record, author_type: "human", author_id: alice.id, body_markdown: "to be deleted")
Expand Down
Loading