Commit 9ff51129 authored by James Lopez's avatar James Lopez

Merge branch '235176_add_feature_flag_for_erb_support' into 'master'

Add `sse_erb_support` feature flag

Closes #235176

See merge request gitlab-org/gitlab!39195
parents 0803dc94 2f49dd66
---
name: sse_erb_support
introduced_by_url:
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235460
group: group::static site editor
type: development
default_enabled: false
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Gitlab module Gitlab
module StaticSiteEditor module StaticSiteEditor
class Config class Config
SUPPORTED_EXTENSIONS = %w[.md .md.erb].freeze SUPPORTED_EXTENSIONS = %w[.md].freeze
def initialize(repository, ref, file_path, return_url) def initialize(repository, ref, file_path, return_url)
@repository = repository @repository = repository
...@@ -42,6 +42,8 @@ module Gitlab ...@@ -42,6 +42,8 @@ module Gitlab
end end
def extension_supported? def extension_supported?
return true if file_path.end_with?('.md.erb') && Feature.enabled?(:sse_erb_support, project)
SUPPORTED_EXTENSIONS.any? { |ext| file_path.end_with?(ext) } SUPPORTED_EXTENSIONS.any? { |ext| file_path.end_with?(ext) }
end end
......
...@@ -46,8 +46,6 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do ...@@ -46,8 +46,6 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do
end end
context 'when file has .md.erb extension' do context 'when file has .md.erb extension' do
let(:file_path) { 'README.md.erb' }
before do before do
repository.create_file( repository.create_file(
project.creator, project.creator,
...@@ -58,9 +56,27 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do ...@@ -58,9 +56,27 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do
) )
end end
context 'when feature flag is enabled' do
let(:file_path) { 'FEATURE_ON.md.erb' }
before do
stub_feature_flags(sse_erb_support: project)
end
it { is_expected.to include(is_supported_content: 'true') } it { is_expected.to include(is_supported_content: 'true') }
end end
context 'when feature flag is disabled' do
let(:file_path) { 'FEATURE_OFF.md.erb' }
before do
stub_feature_flags(sse_erb_support: false)
end
it { is_expected.to include(is_supported_content: 'false') }
end
end
context 'when file path is nested' do context 'when file path is nested' do
let(:file_path) { 'lib/README.md' } 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