Commit b82f6d4c authored by Doug Stull's avatar Doug Stull

Check for file existance in source branch

parent 7fc6a442
......@@ -96,8 +96,8 @@ class MergeRequestWidgetEntity < Grape::Entity
def can_add_ci_config_path?(merge_request)
merge_request.source_project&.uses_default_ci_config? &&
merge_request.all_pipelines.none? &&
merge_request.commits_count.positive? &&
!merge_request.source_project.repository.blob_at(merge_request.source_branch, Gitlab::FileDetector::PATTERNS[:gitlab_ci]) &&
can?(current_user, :read_build, merge_request.source_project) &&
can?(current_user, :create_pipeline, merge_request.source_project)
end
......
......@@ -58,11 +58,11 @@ describe MergeRequestWidgetEntity do
project.add_role(user, role)
end
context 'when there are pipelines' do
context 'when there is a standard ci config file in the source project' do
let(:role) { :developer }
before do
create(:ci_empty_pipeline, project: project, sha: resource.all_commit_shas.first, ref: resource.source_branch)
project.repository.create_file(user, Gitlab::FileDetector::PATTERNS[:gitlab_ci], 'CONTENT', message: 'Add .gitlab-ci.yml', branch_name: 'master')
end
it 'no ci config path' do
......@@ -70,7 +70,7 @@ describe MergeRequestWidgetEntity do
end
end
context 'when there are no pipelines' do
context 'when there is no standard ci config file in the source project' do
context 'when user has permissions' do
let(:role) { :developer }
......
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