Commit 87111a8c authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'vij-snippet-repo-urls-fix' into 'master'

Resolve missing SnippetType argument

See merge request gitlab-org/gitlab!28673
parents d10ee385 c579480c
......@@ -67,10 +67,12 @@ module Types
field :ssh_url_to_repo, type: GraphQL::STRING_TYPE,
description: 'SSH URL to the snippet repository',
calls_gitaly: true,
null: true
field :http_url_to_repo, type: GraphQL::STRING_TYPE,
description: 'HTTP URL to the snippet repository',
calls_gitaly: true,
null: true
markdown_field :description_html, null: true, method: :description
......
......@@ -310,7 +310,7 @@ class Snippet < ApplicationRecord
end
def versioned_enabled_for?(user)
repository_exists? && ::Feature.enabled?(:version_snippets, user)
::Feature.enabled?(:version_snippets, user) && repository_exists?
end
class << self
......
---
title: Fix GraphQL SnippetType repo urls
merge_request: 28673
author:
type: fixed
......@@ -27,25 +27,9 @@ describe GitlabSchema.types['Snippet'] do
end
end
describe 'Repository URLs' do
let(:query) do
%(
{
snippets {
nodes {
sshUrlToRepo
httpUrlToRepo
}
}
}
)
end
let(:response) { subject.dig('data', 'snippets', 'nodes')[0] }
subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }
shared_examples 'snippets with repositories' do
context 'when snippet has repository' do
let!(:snippet) { create(:personal_snippet, :repository, :public, author: user) }
let_it_be(:snippet) { create(:personal_snippet, :repository, :public, author: user) }
it 'responds with repository URLs' do
expect(response['sshUrlToRepo']).to eq(snippet.ssh_url_to_repo)
......@@ -60,14 +44,44 @@ describe GitlabSchema.types['Snippet'] do
it_behaves_like 'response without repository URLs'
end
end
end
shared_examples 'snippets without repositories' do
context 'when snippet does not have a repository' do
let!(:snippet) { create(:personal_snippet, :public, author: user) }
let_it_be(:snippet) { create(:personal_snippet, :public, author: user) }
it_behaves_like 'response without repository URLs'
end
end
describe 'Repository URLs' do
let(:query) do
%(
{
snippets {
nodes {
sshUrlToRepo
httpUrlToRepo
}
}
}
)
end
let(:response) { subject.dig('data', 'snippets', 'nodes')[0] }
subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }
context 'when RequestStore is disabled' do
it_behaves_like 'snippets with repositories'
it_behaves_like 'snippets without repositories'
end
context 'when RequestStore is enabled', :request_store do
it_behaves_like 'snippets with repositories'
it_behaves_like 'snippets without repositories'
end
end
describe '#blob' do
let(:query_blob) { subject.dig('data', 'snippets', 'edges')[0]['node']['blob'] }
let(:query) do
......
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