debian-mirror-gitlab/spec/models/blob_viewer/readme_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe BlobViewer::Readme do
2017-09-10 17:25:29 +05:30
include FakeBlobHelpers
2018-10-15 14:42:47 +05:30
let(:project) { create(:project, :repository, :wiki_repo) }
2017-09-10 17:25:29 +05:30
let(:blob) { fake_blob(path: 'README.md') }
2020-03-09 13:42:32 +05:30
2017-09-10 17:25:29 +05:30
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
2020-05-24 23:13:21 +05:30
create(:wiki_page, wiki: project.wiki, title: 'home', content: 'Home page')
2017-09-10 17:25:29 +05:30
end
it 'returns nil' do
expect(subject.render_error).to be_nil
end
end
end
end
end