summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 03:07:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 03:07:51 +0000
commitb8e30b446d9cb91b94d2b55e5c81303c8f2d1b25 (patch)
treea68cf61f2840805d943d94b32ecbb6535119d1cb /spec
parent01226c755d607c39e102dcac4b0c292c416c2aeb (diff)
downloadgitlab-ce-b8e30b446d9cb91b94d2b55e5c81303c8f2d1b25.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/repository/utils/readme_spec.js6
-rw-r--r--spec/helpers/markup_helper_spec.rb2
-rw-r--r--spec/lib/gitlab/file_detector_spec.rb23
3 files changed, 22 insertions, 9 deletions
diff --git a/spec/frontend/repository/utils/readme_spec.js b/spec/frontend/repository/utils/readme_spec.js
index 1b275de86c3..985d947a0af 100644
--- a/spec/frontend/repository/utils/readme_spec.js
+++ b/spec/frontend/repository/utils/readme_spec.js
@@ -31,6 +31,12 @@ describe('readmeFile', () => {
});
});
+ it('recognizes Readme.txt as a plain text README', () => {
+ expect(readmeFile([{ name: 'Readme.txt' }])).toEqual({
+ name: 'Readme.txt',
+ });
+ });
+
it('returns undefined when there are no appropriate files', () => {
expect(readmeFile([{ name: 'index.js' }, { name: 'md.README' }])).toBe(undefined);
expect(readmeFile([])).toBe(undefined);
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index fce0b5bd7e3..66d461a871c 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -410,7 +410,7 @@ describe MarkupHelper do
end
context 'when file has an unknown type' do
- let(:file_name) { 'foo' }
+ let(:file_name) { 'foo.tex' }
it 'returns html (rendered by Gitlab::OtherMarkup)' do
expected_html = 'Noël'
diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb
index 23f7deba7f7..3972bd24e80 100644
--- a/spec/lib/gitlab/file_detector_spec.rb
+++ b/spec/lib/gitlab/file_detector_spec.rb
@@ -16,23 +16,30 @@ describe Gitlab::FileDetector do
end
describe '.type_of' do
- it 'returns the type of a README file' do
- filenames = Gitlab::MarkupHelper::PLAIN_FILENAMES + Gitlab::MarkupHelper::PLAIN_FILENAMES.map(&:upcase)
- extensions = Gitlab::MarkupHelper::EXTENSIONS + Gitlab::MarkupHelper::EXTENSIONS.map(&:upcase)
+ it 'returns the type of a README without extension' do
+ expect(described_class.type_of('README')).to eq(:readme)
+ expect(described_class.type_of('INDEX')).to eq(:readme)
+ end
- filenames.each do |filename|
- expect(described_class.type_of(filename)).to eq(:readme)
+ it 'returns the type of a README file with a recognized extension' do
+ extensions = ['txt', *Gitlab::MarkupHelper::EXTENSIONS]
- extensions.each do |extname|
- expect(described_class.type_of("#{filename}.#{extname}")).to eq(:readme)
+ extensions.each do |ext|
+ %w(index readme).each do |file|
+ expect(described_class.type_of("#{file}.#{ext}")).to eq(:readme)
end
end
end
- it 'returns nil for a README.rb file' do
+ it 'returns nil for a README with unrecognized extension' do
expect(described_class.type_of('README.rb')).to be_nil
end
+ it 'is case insensitive' do
+ expect(described_class.type_of('ReadMe')).to eq(:readme)
+ expect(described_class.type_of('index.TXT')).to eq(:readme)
+ end
+
it 'returns nil for a README file in a directory' do
expect(described_class.type_of('foo/README.md')).to be_nil
end