Also test against external-issue for deleted projects

This is based on:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10841
This commit is contained in:
Lin Jen-Shin 2017-04-21 16:02:03 +08:00
parent b43cabaf49
commit 31ea72b62e

View file

@ -43,12 +43,24 @@ describe Banzai::Redactor do
end end
context 'when project is in pending delete' do 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 it 'redacts an issue attached' do
project.pending_delete = true doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-issue='#{issue.id}'>foo</a>")
project.save
issue = create(:issue, project: project) redactor.redact([doc])
redactor = described_class.new(project, user)
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-project=\"#{project.id}\" data-issue=\"#{issue.id}\">foo</a>") 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]) redactor.redact([doc])
expect(doc.to_html).to eq('foo') expect(doc.to_html).to eq('foo')