Commit d3a788da authored by Douwe Maan's avatar Douwe Maan

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
parents 38c52ab1 67d38013
......@@ -199,7 +199,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