Commit 08bec52a authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '223171_allow_erb_extension_for_sse' into 'master'

Allow files with `.md.erb` extension in the Static Site Editor

Closes #223171

See merge request gitlab-org/gitlab!35136
parents b210a501 39fc235a
---
title: Allow files with .md.erb extension for the Static Site Editor
merge_request: 35136
author:
type: added
......@@ -3,7 +3,7 @@
module Gitlab
module StaticSiteEditor
class Config
SUPPORTED_EXTENSIONS = %w[.md].freeze
SUPPORTED_EXTENSIONS = %w[.md .md.erb].freeze
def initialize(repository, ref, file_path, return_url)
@repository = repository
......@@ -42,11 +42,11 @@ module Gitlab
end
def extension_supported?
File.extname(file_path).in?(SUPPORTED_EXTENSIONS)
SUPPORTED_EXTENSIONS.any? { |ext| file_path.end_with?(ext) }
end
def file_exists?
commit_id.present? && repository.blob_at(commit_id, file_path).present?
commit_id.present? && !repository.blob_at(commit_id, file_path).nil?
end
def full_path
......
......@@ -30,6 +30,22 @@ describe Gitlab::StaticSiteEditor::Config do
)
end
context 'when file has .md.erb extension' do
let(:file_path) { 'README.md.erb' }
before do
repository.create_file(
project.creator,
file_path,
'',
message: 'message',
branch_name: 'master'
)
end
it { is_expected.to include(is_supported_content: 'true') }
end
context 'when file path is nested' do
let(:file_path) { 'lib/README.md' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment