BigW Consortium Gitlab

Commit 70fece35 by Douwe Maan Committed by Lin Jen-Shin

Merge branch 'sh-fix-issue-31215-2' into 'master'

Based on !10841 Fix Error 500 when referencing issue with project in pending delete Closes #31215 See merge request !10843
parent b5e9b8f8
......@@ -201,7 +201,7 @@ class Issue < ActiveRecord::Base
# Returns `true` if the current issue can be viewed by either a logged in User
# or an anonymous user.
def visible_to_user?(user = nil)
return false unless project.feature_available?(:issues, user)
return false unless project && project.feature_available?(:issues, user)
user ? readable_by?(user) : publicly_visible?
end
......
---
title: Fix error when an issue reference has a pending deleting project
merge_request: 10843
author:
......@@ -42,6 +42,31 @@ describe Banzai::Redactor do
end
end
context 'when project is in pending delete' do
let!(:issue) { create(:issue, project: project) }
let(:redactor) { described_class.new(project, user) }
before do
project.update(pending_delete: true)
end
it 'redacts an issue attached' do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-issue='#{issue.id}'>foo</a>")
redactor.redact([doc])
expect(doc.to_html).to eq('foo')
end
it 'redacts an external issue' do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-external-issue='#{issue.id}' data-project='#{project.id}'>foo</a>")
redactor.redact([doc])
expect(doc.to_html).to eq('foo')
end
end
context 'when reference visible to user' do
it 'does not redact an array of documents' do
doc1_html = '<a class="gfm" data-reference-type="issue">foo</a>'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment