Commit 3b02ef75 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '262626-rescue-error' into 'master'

Handle empty project within Security Configuration

See merge request gitlab-org/gitlab!47226
parents 6145858e 5c22b119
...@@ -98,6 +98,8 @@ module Projects ...@@ -98,6 +98,8 @@ module Projects
end end
def gitlab_ci_history_path def gitlab_ci_history_path
return '' if project.empty_repo?
gitlab_ci = Gitlab::FileDetector::PATTERNS[:gitlab_ci] gitlab_ci = Gitlab::FileDetector::PATTERNS[:gitlab_ci]
Gitlab::Routing.url_helpers.project_blame_path(project, File.join(project.default_branch, gitlab_ci)) Gitlab::Routing.url_helpers.project_blame_path(project, File.join(project.default_branch, gitlab_ci))
end end
......
---
title: Handle empty project within Security Configuration
merge_request: 47226
author:
type: fixed
...@@ -6,6 +6,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do ...@@ -6,6 +6,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
include Gitlab::Routing.url_helpers include Gitlab::Routing.url_helpers
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:project_with_no_repo) { create(:project) }
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
it 'presents the given project' do it 'presents the given project' do
...@@ -41,6 +42,14 @@ RSpec.describe Projects::Security::ConfigurationPresenter do ...@@ -41,6 +42,14 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
expect(subject[:gitlab_ci_history_path]).to eq(project_blame_path(project, 'master/.gitlab-ci.yml')) expect(subject[:gitlab_ci_history_path]).to eq(project_blame_path(project, 'master/.gitlab-ci.yml'))
end end
context 'when the project is empty' do
subject { described_class.new(project_with_no_repo, auto_fix_permission: true, current_user: current_user).to_html_data_attribute }
it 'includes a blank gitlab_ci history path' do
expect(subject[:gitlab_ci_history_path]).to eq('')
end
end
context "when the latest default branch pipeline's source is auto devops" do context "when the latest default branch pipeline's source is auto devops" do
before do before do
pipeline = create( pipeline = create(
......
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