Commit 18f25bc9 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Update reference unfolder according to recent ability changes

Commit 43d8bdb4 introduced additional
checks for permissions to read issue in references extractor.
parent 0115ad66
...@@ -77,7 +77,8 @@ module Issues ...@@ -77,7 +77,8 @@ module Issues
end end
def unfold_references(content) def unfold_references(content)
unfolder = Gitlab::Gfm::ReferenceUnfolder.new(content, @old_project) unfolder = Gitlab::Gfm::ReferenceUnfolder.new(content, @old_project,
@current_user)
unfolder.unfold(@new_project) unfolder.unfold(@new_project)
end end
......
...@@ -29,9 +29,10 @@ module Gitlab ...@@ -29,9 +29,10 @@ module Gitlab
# http://gitlab.com/some/link/#1234, and code `puts #1234`' # http://gitlab.com/some/link/#1234, and code `puts #1234`'
# #
class ReferenceUnfolder class ReferenceUnfolder
def initialize(text, project) def initialize(text, project, user)
@text = text @text = text
@project = project @project = project
@user = user
@original = markdown(text) @original = markdown(text)
end end
...@@ -61,7 +62,7 @@ module Gitlab ...@@ -61,7 +62,7 @@ module Gitlab
def referables def referables
return @referables if @referables return @referables if @referables
extractor = Gitlab::ReferenceExtractor.new(@project) extractor = Gitlab::ReferenceExtractor.new(@project, @user)
extractor.analyze(@text) extractor.analyze(@text)
@referables = extractor.all @referables = extractor.all
end end
......
...@@ -4,9 +4,14 @@ describe Gitlab::Gfm::ReferenceUnfolder do ...@@ -4,9 +4,14 @@ describe Gitlab::Gfm::ReferenceUnfolder do
let(:text) { 'some text' } let(:text) { 'some text' }
let(:old_project) { create(:project) } let(:old_project) { create(:project) }
let(:new_project) { create(:project) } let(:new_project) { create(:project) }
let(:user) { create(:user) }
before { old_project.team << [user, :guest] }
describe '#unfold' do describe '#unfold' do
subject { described_class.new(text, old_project).unfold(new_project) } subject do
described_class.new(text, old_project, user).unfold(new_project)
end
context 'multiple issues and merge requests referenced' do context 'multiple issues and merge requests referenced' do
let!(:issue_first) { create(:issue, project: old_project) } let!(:issue_first) { create(:issue, project: old_project) }
......
...@@ -130,7 +130,10 @@ describe Gitlab::ReferenceExtractor, lib: true do ...@@ -130,7 +130,10 @@ describe Gitlab::ReferenceExtractor, lib: true do
let(:label) { create(:label, project: project) } let(:label) { create(:label, project: project) }
let(:text) { "Ref. #{issue.to_reference} and #{label.to_reference}" } let(:text) { "Ref. #{issue.to_reference} and #{label.to_reference}" }
before { subject.analyze(text) } before do
project.team << [project.creator, :developer]
subject.analyze(text)
end
it 'returns all referables' do it 'returns all referables' do
expect(subject.all).to match_array([issue, label]) expect(subject.all).to match_array([issue, label])
......
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