Commit 446476fa authored by Laura Montemayor's avatar Laura Montemayor Committed by lauraMon

Refactors a bit and updates

parent e9b94670
......@@ -4,7 +4,11 @@ module Mutations
module Commits
class Create < BaseMutation
include FindsProject
include GitlabRoutingHelper
class UrlHelpers
include GitlabRoutingHelper
include Gitlab::Routing
end
graphql_name 'CommitCreate'
......@@ -56,7 +60,7 @@ module Mutations
{
commit: (project.repository.commit(result[:result]) if result[:status] == :success),
commit_pipeline_path: graphql_etag_pipeline_sha_path(result[:result]),
commit_pipeline_path: UrlHelpers.new.graphql_etag_pipeline_sha_path(result[:result]),
errors: Array.wrap(result[:message])
}
end
......
......@@ -365,7 +365,7 @@ module GitlabRoutingHelper
end
def graphql_etag_pipeline_sha_path(sha)
[Gitlab::Routing.url_helpers.api_graphql_path, "pipelines/sha/#{sha}"].join(':')
[api_graphql_path, "pipelines/sha/#{sha}"].join(':')
end
private
......
......@@ -76,11 +76,11 @@ module Ci
each_pipelines_merge_request_path(pipeline) do |path|
store.touch(path)
end
store.touch(graphql_pipeline_sha_path(pipeline.sha))
pipeline.self_with_ancestors_and_descendants.each do |relative_pipeline|
store.touch(project_pipeline_path(relative_pipeline.project, relative_pipeline))
store.touch(graphql_pipeline_path(relative_pipeline))
store.touch(graphql_pipeline_sha_path(relative_pipeline.sha))
end
end
......
......@@ -14,7 +14,7 @@ module Gitlab
'continuous_integration'
],
[
%r(\Apipelines/sha/\w+\z),
%r(\Apipelines/sha/\w{7,40}\z),
'ci_editor',
'pipeline_authoring'
]
......
......@@ -237,7 +237,7 @@ FactoryBot.define do
trait :merged_result_pipeline do
detached_merge_request_pipeline
sha { 'testMergeSha12312' }
sha { 'testMergeShaWithFortyCharacters123456' }
ref { merge_request.merge_ref_path }
source_sha { merge_request.source_branch_sha }
target_sha { merge_request.target_branch_sha }
......
......@@ -279,7 +279,7 @@ FactoryBot.define do
trait :with_merge_request_pipeline do
transient do
merge_sha { 'testmergesha123' }
merge_sha { 'testmergeshawithfortycharacters123456' }
source_sha { source_branch_sha }
target_sha { target_branch_sha }
end
......
......@@ -24,7 +24,7 @@ RSpec.describe Gitlab::EtagCaching::Router do
end
it 'matches pipeline sha endpoint' do
result = match_route('/api/graphql', 'pipelines/sha/4asda2jiwjdqw0')
result = match_route('/api/graphql', 'pipelines/sha/4asd12lla2jiwjdqw9as32glm8is8hiu8s2c5jsw')
expect(result).to be_present
expect(result.name).to eq 'ci_editor'
......
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