summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-04-11 19:19:29 +0000
committerRobert Speicher <robert@gitlab.com>2018-04-11 19:19:29 +0000
commit947ed8b88281a618530ae30bc0fe1e3d61a3c1d9 (patch)
tree33efbf5e22ba9afe623d0e2fa4347282e31b7196
parent84c70f4335e1b4f496f29cb99cc7fdaf926a5571 (diff)
parentf61121225ebaf9dc425d0e2ad550cf368add8f6e (diff)
downloadgitlab-ce-947ed8b88281a618530ae30bc0fe1e3d61a3c1d9.tar.gz
Merge branch 'fix/wiki-find-file-gitaly' into 'master'
Fix finding wiki file when Gitaly is enabled Closes gitaly#1126 See merge request gitlab-org/gitlab-ce!18317
-rw-r--r--changelogs/unreleased/fix-wiki-find-file-gitaly.yml5
-rw-r--r--lib/gitlab/gitaly_client/wiki_service.rb2
-rw-r--r--spec/fixtures/big-image.pngbin0 -> 324444 bytes
-rw-r--r--spec/models/project_wiki_spec.rb12
4 files changed, 16 insertions, 3 deletions
diff --git a/changelogs/unreleased/fix-wiki-find-file-gitaly.yml b/changelogs/unreleased/fix-wiki-find-file-gitaly.yml
new file mode 100644
index 00000000000..5c536be7ae5
--- /dev/null
+++ b/changelogs/unreleased/fix-wiki-find-file-gitaly.yml
@@ -0,0 +1,5 @@
+---
+title: Fix finding wiki file when Gitaly is enabled
+merge_request:
+author:
+type: fixed
diff --git a/lib/gitlab/gitaly_client/wiki_service.rb b/lib/gitlab/gitaly_client/wiki_service.rb
index 0d8dd5cb8f4..7a698e4b3f3 100644
--- a/lib/gitlab/gitaly_client/wiki_service.rb
+++ b/lib/gitlab/gitaly_client/wiki_service.rb
@@ -136,7 +136,7 @@ module Gitlab
wiki_file = nil
response.each do |message|
- next unless message.name.present?
+ next unless message.name.present? || wiki_file
if wiki_file
wiki_file.raw_data << message.raw_data
diff --git a/spec/fixtures/big-image.png b/spec/fixtures/big-image.png
new file mode 100644
index 00000000000..a333363ac36
--- /dev/null
+++ b/spec/fixtures/big-image.png
Binary files differ
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index d87c1ca14f0..374a157bec0 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -172,11 +172,12 @@ describe ProjectWiki do
describe '#find_file' do
shared_examples 'finding a wiki file' do
+ let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) }
+
before do
- file = File.open(Rails.root.join('spec', 'fixtures', 'dk.png'))
subject.wiki # Make sure the wiki repo exists
- BareRepoOperations.new(subject.repository.path_to_repo).commit_file(file, 'image.png')
+ BareRepoOperations.new(subject.repository.path_to_repo).commit_file(image, 'image.png')
end
it 'returns the latest version of the file if it exists' do
@@ -192,6 +193,13 @@ describe ProjectWiki do
file = subject.find_file('image.png')
expect(file).to be_a Gitlab::Git::WikiFile
end
+
+ it 'returns the whole file' do
+ file = subject.find_file('image.png')
+ image.rewind
+
+ expect(file.raw_data.b).to eq(image.read.b)
+ end
end
context 'when Gitaly wiki_find_file is enabled' do