Commit 8ece15a6 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'lm-fix-editor' into 'master'

Adds safe op for commit sha etag pipeline path

See merge request gitlab-org/gitlab!60656
parents a607c990 cbbc4c8b
...@@ -18,7 +18,7 @@ module Ci ...@@ -18,7 +18,7 @@ module Ci
"initial-branch-name": params[:branch_name], "initial-branch-name": params[:branch_name],
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => namespace_project_new_merge_request_path, "new-merge-request-path" => namespace_project_new_merge_request_path,
"pipeline_etag" => graphql_etag_pipeline_sha_path(project.commit.sha), "pipeline_etag" => project.commit ? graphql_etag_pipeline_sha_path(commit_sha) : '',
"project-path" => project.path, "project-path" => project.path,
"project-full-path" => project.full_path, "project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path, "project-namespace" => project.namespace.full_path,
......
...@@ -36,21 +36,44 @@ RSpec.describe Ci::PipelineEditorHelper do ...@@ -36,21 +36,44 @@ RSpec.describe Ci::PipelineEditorHelper do
subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) } subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) }
it 'returns pipeline editor data' do context 'with a project with commits' do
expect(pipeline_editor_data).to eq({ it 'returns pipeline editor data' do
"ci-config-path": project.ci_config_path_or_default, expect(pipeline_editor_data).to eq({
"commit-sha" => project.commit.sha, "ci-config-path": project.ci_config_path_or_default,
"default-branch" => project.default_branch, "commit-sha" => project.commit.sha,
"empty-state-illustration-path" => 'foo', "default-branch" => project.default_branch,
"initial-branch-name": nil, "empty-state-illustration-path" => 'foo',
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), "initial-branch-name": nil,
"new-merge-request-path" => '/mock/project/-/merge_requests/new', "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"pipeline_etag" => graphql_etag_pipeline_sha_path(project.commit.sha), "new-merge-request-path" => '/mock/project/-/merge_requests/new',
"project-path" => project.path, "pipeline_etag" => graphql_etag_pipeline_sha_path(project.commit.sha),
"project-full-path" => project.full_path, "project-path" => project.path,
"project-namespace" => project.namespace.full_path, "project-full-path" => project.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README') "project-namespace" => project.namespace.full_path,
}) "yml-help-page-path" => help_page_path('ci/yaml/README')
})
end
end
context 'with an empty project' do
let(:project) { create(:project, :empty_repo) }
it 'returns pipeline editor data' do
expect(pipeline_editor_data).to eq({
"ci-config-path": project.ci_config_path_or_default,
"commit-sha" => '',
"default-branch" => project.default_branch,
"empty-state-illustration-path" => 'foo',
"initial-branch-name": nil,
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => '/mock/project/-/merge_requests/new',
"pipeline_etag" => '',
"project-path" => project.path,
"project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README')
})
end
end end
end end
end end
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