summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/services/issues/move_service.rb3
-rw-r--r--lib/gitlab/gfm/reference_unfolder.rb5
-rw-r--r--spec/lib/gitlab/gfm/reference_unfolder_spec.rb7
-rw-r--r--spec/lib/gitlab/reference_extractor_spec.rb5
4 files changed, 15 insertions, 5 deletions
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index 45b4b50c0f6..892acc8c04d 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -77,7 +77,8 @@ module Issues
end
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)
end
diff --git a/lib/gitlab/gfm/reference_unfolder.rb b/lib/gitlab/gfm/reference_unfolder.rb
index cf8de88b856..94c09761960 100644
--- a/lib/gitlab/gfm/reference_unfolder.rb
+++ b/lib/gitlab/gfm/reference_unfolder.rb
@@ -29,9 +29,10 @@ module Gitlab
# http://gitlab.com/some/link/#1234, and code `puts #1234`'
#
class ReferenceUnfolder
- def initialize(text, project)
+ def initialize(text, project, user)
@text = text
@project = project
+ @user = user
@original = markdown(text)
end
@@ -61,7 +62,7 @@ module Gitlab
def referables
return @referables if @referables
- extractor = Gitlab::ReferenceExtractor.new(@project)
+ extractor = Gitlab::ReferenceExtractor.new(@project, @user)
extractor.analyze(@text)
@referables = extractor.all
end
diff --git a/spec/lib/gitlab/gfm/reference_unfolder_spec.rb b/spec/lib/gitlab/gfm/reference_unfolder_spec.rb
index 40cdb7e1452..2e3b77d9180 100644
--- a/spec/lib/gitlab/gfm/reference_unfolder_spec.rb
+++ b/spec/lib/gitlab/gfm/reference_unfolder_spec.rb
@@ -4,9 +4,14 @@ describe Gitlab::Gfm::ReferenceUnfolder do
let(:text) { 'some text' }
let(:old_project) { create(:project) }
let(:new_project) { create(:project) }
+ let(:user) { create(:user) }
+
+ before { old_project.team << [user, :guest] }
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
let!(:issue_first) { create(:issue, project: old_project) }
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb
index f2922160331..7c617723e6d 100644
--- a/spec/lib/gitlab/reference_extractor_spec.rb
+++ b/spec/lib/gitlab/reference_extractor_spec.rb
@@ -130,7 +130,10 @@ describe Gitlab::ReferenceExtractor, lib: true do
let(:label) { create(:label, project: project) }
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
expect(subject.all).to match_array([issue, label])