diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-15 00:28:46 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-15 00:28:46 +0300 |
commit | ffd164d27f674b554fdffbffa828a9715c93ee60 (patch) | |
tree | fcb940d28e7cf83a853fa802394c2f1b6f12a4fa /spec/lib/gitlab/template | |
parent | 6343964b9c7acac25d946545778c8ae6523773da (diff) |
Fix bugs in Gitlab::Template::Finders preventing instances from BaseTemplate.all from loading content
Diffstat (limited to 'spec/lib/gitlab/template')
-rw-r--r-- | spec/lib/gitlab/template/finders/repo_template_finders_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb new file mode 100644 index 00000000000..2eabccd5dff --- /dev/null +++ b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Gitlab::Template::Finders::RepoTemplateFinder do + set(:project) { create(:project, :repository) } + + let(:categories) { { 'HTML' => 'html' } } + + subject(:finder) { described_class.new(project, 'files/', '.html', categories) } + + describe '#read' do + it 'returns the content of the given path' do + result = finder.read('files/html/500.html') + + expect(result).to be_present + end + + it 'raises an error if the path does not exist' do + expect { finder.read('does/not/exist') }.to raise_error(described_class::FileNotFoundError) + end + end + + describe '#find' do + it 'returns the full path of the found template' do + result = finder.find('500') + + expect(result).to eq('files/html/500.html') + end + end + + describe '#list_files_for' do + it 'returns the full path of the found files' do + result = finder.list_files_for('files/html') + + expect(result).to contain_exactly('files/html/500.html') + end + end +end |