diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-10-23 23:05:59 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-10-23 23:17:43 +0200 |
commit | 367e2804a161f8c83c67014fe6209822049a97a8 (patch) | |
tree | ec2989a8d05bc4c50bd28235187ff475e2e1f5b5 | |
parent | 743050cede59d4ffbd45f2ed0dc4d7f20b75c6bd (diff) | |
download | gitlab-ce-fix/add-path-attr-to-wiki-file.tar.gz |
Add path attribute to WikiFile classfix/add-path-attr-to-wiki-file
Fixes #39420
-rw-r--r-- | changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/git/wiki_file.rb | 3 | ||||
-rw-r--r-- | spec/lib/banzai/filter/gollum_tags_filter_spec.rb | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml b/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml new file mode 100644 index 00000000000..0847b5f6733 --- /dev/null +++ b/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml @@ -0,0 +1,5 @@ +--- +title: Fix broken wiki pages that link to a wiki file +merge_request: 15019 +author: +type: fixed diff --git a/lib/gitlab/git/wiki_file.rb b/lib/gitlab/git/wiki_file.rb index 527f2a44dea..84335aca4bc 100644 --- a/lib/gitlab/git/wiki_file.rb +++ b/lib/gitlab/git/wiki_file.rb @@ -1,7 +1,7 @@ module Gitlab module Git class WikiFile - attr_reader :mime_type, :raw_data, :name + attr_reader :mime_type, :raw_data, :name, :path # This class is meant to be serializable so that it can be constructed # by Gitaly and sent over the network to GitLab. @@ -13,6 +13,7 @@ module Gitlab @mime_type = gollum_file.mime_type @raw_data = gollum_file.raw_data @name = gollum_file.name + @path = gollum_file.path end end end diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index 97d612e6347..e4d0ec3dfa7 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -15,9 +15,9 @@ describe Banzai::Filter::GollumTagsFilter do context 'linking internal images' do it 'creates img tag if image exists' do - file = Gollum::File.new(project_wiki.wiki) - expect(file).to receive(:path).and_return('images/image.jpg') - expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(file) + gollum_file_mock = OpenStruct.new(mime_type: 'image/jpeg', name: 'images/image.jpg', path: 'images/image.jpg') + wiki_file = Gitlab::Git::WikiFile.new(gollum_file_mock) + expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(wiki_file) tag = '[[images/image.jpg]]' doc = filter("See #{tag}", project_wiki: project_wiki) |