2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-06 15:21:08 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe BlobViewer::Readme do
|
2017-07-06 15:21:08 -04:00
|
|
|
include FakeBlobHelpers
|
|
|
|
|
2018-05-04 05:45:16 -04:00
|
|
|
let(:project) { create(:project, :repository, :wiki_repo) }
|
2017-07-06 15:21:08 -04:00
|
|
|
let(:blob) { fake_blob(path: 'README.md') }
|
2019-12-18 19:08:01 -05:00
|
|
|
|
2017-07-06 15:21:08 -04:00
|
|
|
subject { described_class.new(blob) }
|
|
|
|
|
|
|
|
describe '#render_error' do
|
|
|
|
context 'when there is no wiki' do
|
|
|
|
it 'returns :no_wiki' do
|
|
|
|
expect(subject.render_error).to eq(:no_wiki)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is an external wiki' do
|
|
|
|
before do
|
|
|
|
project.has_external_wiki = true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(subject.render_error).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a local wiki' do
|
|
|
|
before do
|
|
|
|
project.wiki_enabled = true
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the wiki is empty' do
|
|
|
|
it 'returns :no_wiki' do
|
|
|
|
expect(subject.render_error).to eq(:no_wiki)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the wiki is not empty' do
|
|
|
|
before do
|
2017-10-12 08:53:46 -04:00
|
|
|
create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' })
|
2017-07-06 15:21:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(subject.render_error).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|