Skip to content
代码片段 群组 项目
提交 956421dc 编辑于 作者: Laura Montemayor's avatar Laura Montemayor
浏览文件

Merge branch '26169-refactor-2-blob-viewer' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -7,9 +7,14 @@ class GitlabCiYml < Base ...@@ -7,9 +7,14 @@ class GitlabCiYml < Base
self.partial_name = 'gitlab_ci_yml' self.partial_name = 'gitlab_ci_yml'
self.loading_partial_name = 'gitlab_ci_yml_loading' self.loading_partial_name = 'gitlab_ci_yml_loading'
self.file_types = %i[gitlab_ci]
self.binary = false self.binary = false
# rubocop:disable Lint/UnusedMethodArgument -- The keyword argument is required by the parent class but not here.
def self.can_render?(blob, verify_binary: true)
blob.path == blob.project.ci_config_path_or_default
end
# rubocop:enable Lint/UnusedMethodArgument
def validation_message(opts) def validation_message(opts)
return @validation_message if defined?(@validation_message) return @validation_message if defined?(@validation_message)
......
...@@ -387,6 +387,36 @@ ...@@ -387,6 +387,36 @@
expect(blob.auxiliary_viewer).to be_a(BlobViewer::License) expect(blob.auxiliary_viewer).to be_a(BlobViewer::License)
end end
end end
context 'when the blob is GitlabCiYml' do
it 'returns a matching viewer for .gitlab-ci.yml' do
blob = fake_blob(path: '.gitlab-ci.yml')
expect(blob.auxiliary_viewer).to be_a(BlobViewer::GitlabCiYml)
end
it 'returns nil for non .gitlab-ci.yml' do
blob = fake_blob(path: 'custom-ci.yml')
expect(blob.auxiliary_viewer).to be_nil
end
context 'when the project has a custom CI config path' do
let(:project) { build(:project, ci_config_path: 'custom-ci.yml') }
it 'returns a matching viewer for the custom CI file' do
blob = fake_blob(path: 'custom-ci.yml')
expect(blob.auxiliary_viewer).to be_a(BlobViewer::GitlabCiYml)
end
it 'returns nil for the incorrect CI file' do
blob = fake_blob(path: '.gitlab-ci.yml')
expect(blob.auxiliary_viewer).to be_nil
end
end
end
end end
describe '#rendered_as_text?' do describe '#rendered_as_text?' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册