diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-11-10 01:55:09 +0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-11-13 22:54:40 +0300 |
commit | 5a38a9d86dd897e71dbb43e4db18623164fe65b8 (patch) | |
tree | 64e18c3c306f0ff0a0f8e4d8ae3e885a2db1f1f2 /spec | |
parent | f24a78f2801608be7c3b9d3a0dad90656880f097 (diff) |
Add spec examples for Gitlab::Gitaly::WikiService
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/wiki_service_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb new file mode 100644 index 00000000000..a9653027587 --- /dev/null +++ b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe Gitlab::GitalyClient::WikiService do + let(:project) { create(:project) } + let(:storage_name) { project.repository_storage } + let(:relative_path) { project.disk_path + '.git' } + let(:client) { described_class.new(project.repository) } + let(:commit) { create(:gitaly_commit) } + let(:page_version) { Gitaly::WikiPageVersion.new(format: 'markdown', commit: commit) } + let(:page_info) { { title: 'My Page', raw_data: 'a', version: page_version } } + + describe '#find_page' do + let(:response) do + [ + Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(page_info)), + Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(raw_data: 'b')) + ] + end + let(:wiki_page) { subject.first } + let(:wiki_page_version) { subject.last } + + subject { client.find_page(title: 'My Page', version: 'master', dir: '') } + + it 'sends a wiki_find_page message' do + expect_any_instance_of(Gitaly::WikiService::Stub) + .to receive(:wiki_find_page) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([].each) + + subject + end + + it 'concatenates the raw data and returns a pair of WikiPage and WikiPageVersion' do + expect_any_instance_of(Gitaly::WikiService::Stub) + .to receive(:wiki_find_page) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return(response.each) + + expect(wiki_page.title).to eq('My Page') + expect(wiki_page.raw_data).to eq('ab') + expect(wiki_page_version.format).to eq('markdown') + end + end +end |