diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-07-06 22:21:08 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-07 00:19:10 +0300 |
commit | d195db17e9ff62c3dbfb8ba03dacadf965b1fb8b (patch) | |
tree | 58157f1909c4f04306d10be5b842f99a79f9b809 /spec/models/blob_viewer | |
parent | bb918a2fd98136c232baa34104c357f3716f8842 (diff) |
Don't show auxiliary blob viewer for README when there is no wiki
Diffstat (limited to 'spec/models/blob_viewer')
-rw-r--r-- | spec/models/blob_viewer/readme_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/models/blob_viewer/readme_spec.rb b/spec/models/blob_viewer/readme_spec.rb new file mode 100644 index 00000000000..02679dbb544 --- /dev/null +++ b/spec/models/blob_viewer/readme_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe BlobViewer::Readme, model: true do + include FakeBlobHelpers + + let(:project) { create(:project, :repository) } + let(:blob) { fake_blob(path: 'README.md') } + 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 + WikiPages::CreateService.new(project, project.owner, title: 'home', content: 'Home page').execute + end + + it 'returns nil' do + expect(subject.render_error).to be_nil + end + end + end + end +end |