From 49dfae87ab1913b161aaa9455a9ac89a091faed3 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 6 Feb 2025 17:08:22 +0000 Subject: [PATCH 1/2] Add a test for viewing a note opened by a deleted user --- test/controllers/notes_controller_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 71dfa42ba..024380de1 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -152,6 +152,15 @@ class NotesControllerTest < ActionDispatch::IntegrationTest assert_select "div.note-comments ul li", :count => 1 end + def test_read_note_hidden_opener + hidden_user = create(:user, :deleted) + note_with_hidden_opener = create(:note) + create(:note_comment, :author => hidden_user, :note => note_with_hidden_opener) + + sidebar_browse_check :note_path, note_with_hidden_opener.id, "notes/show" + assert_select "div.note-comments ul li", :count => 0 + end + def test_read_closed_note user = create(:user) closed_note = create(:note_with_comments, :closed, :closed_by => user, :comments_count => 2) From cb51f46a4ff913985d535afed0fd8d7d1d955126 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 6 Feb 2025 17:08:44 +0000 Subject: [PATCH 2/2] Correct test for notes opened by inactive users --- app/controllers/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 574c9b8b7..5d817c9c6 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -43,7 +43,7 @@ class NotesController < ApplicationController @note_includes_anonymous = @note.author.nil? || @note_comments.find { |comment| comment.author.nil? } - @note_comments = @note_comments.drop(1) unless !@note.author.nil? && @note.author.status == "deleted" + @note_comments = @note_comments.drop(1) if @note.author.nil? || @note.author.active? rescue ActiveRecord::RecordNotFound render :template => "browse/not_found", :status => :not_found end