Fix finding wiki file when Gitaly is enabled

Fixes gitaly#1126
This commit is contained in:
Ahmad Sherif 2018-04-11 16:08:23 +02:00
parent 37a5632483
commit f61121225e
4 changed files with 16 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix finding wiki file when Gitaly is enabled
merge_request:
author:
type: fixed

View file

@ -136,7 +136,7 @@ module Gitlab
wiki_file = nil wiki_file = nil
response.each do |message| response.each do |message|
next unless message.name.present? next unless message.name.present? || wiki_file
if wiki_file if wiki_file
wiki_file.raw_data << message.raw_data wiki_file.raw_data << message.raw_data

BIN
spec/fixtures/big-image.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

View file

@ -172,11 +172,12 @@ describe ProjectWiki do
describe '#find_file' do describe '#find_file' do
shared_examples 'finding a wiki file' do shared_examples 'finding a wiki file' do
let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) }
before do before do
file = File.open(Rails.root.join('spec', 'fixtures', 'dk.png'))
subject.wiki # Make sure the wiki repo exists 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 end
it 'returns the latest version of the file if it exists' do 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') file = subject.find_file('image.png')
expect(file).to be_a Gitlab::Git::WikiFile expect(file).to be_a Gitlab::Git::WikiFile
end 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 end
context 'when Gitaly wiki_find_file is enabled' do context 'when Gitaly wiki_find_file is enabled' do