Test type of README file without extension

This commit is contained in:
Achilleas Pipinellis 2018-11-02 11:15:04 +01:00
parent 133c1a7cc3
commit be0af5e69f
No known key found for this signature in database
GPG key ID: A0996FBD3E92C17B
2 changed files with 4 additions and 3 deletions

View file

@ -8,7 +8,7 @@ module Gitlab
module FileDetector module FileDetector
PATTERNS = { PATTERNS = {
# Project files # Project files
readme: %r{\A(readme|index)[^\/]*\z}i, readme: %r{\A(readme|index)[^/]*\z}i,
changelog: %r{\A(changelog|history|changes|news)[^/]*\z}i, changelog: %r{\A(changelog|history|changes|news)[^/]*\z}i,
license: %r{\A((un)?licen[sc]e|copying)(\.[^/]+)?\z}i, license: %r{\A((un)?licen[sc]e|copying)(\.[^/]+)?\z}i,
contributing: %r{\Acontributing[^/]*\z}i, contributing: %r{\Acontributing[^/]*\z}i,

View file

@ -15,8 +15,9 @@ describe Gitlab::FileDetector do
describe '.type_of' do describe '.type_of' do
it 'returns the type of a README file' do it 'returns the type of a README file' do
%w(README readme INDEX index).each do |filename| %w[README readme INDEX index].each do |filename|
%w(.md .adoc).each do |extname| expect(described_class.type_of(filename)).to eq(:readme)
%w[.md .adoc .rst].each do |extname|
expect(described_class.type_of(filename + extname)).to eq(:readme) expect(described_class.type_of(filename + extname)).to eq(:readme)
end end
end end