Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-19 12:09:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-19 12:09:27 +0300
commit2af90cef2e2e9c776eae4394a43dba3be7f33d1e (patch)
treebb4bc691caa6cc74b45720ecd779517f9c8c2cd3 /spec/graphql
parentcf58004721ee715dd3884476f6fa0c62a7e7f247 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/types/snippet_type_spec.rb56
1 files changed, 53 insertions, 3 deletions
diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb
index afac480d06b..ba0152ae983 100644
--- a/spec/graphql/types/snippet_type_spec.rb
+++ b/spec/graphql/types/snippet_type_spec.rb
@@ -3,12 +3,15 @@
require 'spec_helper'
describe GitlabSchema.types['Snippet'] do
+ let_it_be(:user) { create(:user) }
+
it 'has the correct fields' do
expected_fields = [:id, :title, :project, :author,
:file_name, :description,
:visibility_level, :created_at, :updated_at,
- :web_url, :raw_url, :notes, :discussions,
- :user_permissions, :description_html, :blob]
+ :web_url, :raw_url, :ssh_url_to_repo, :http_url_to_repo,
+ :notes, :discussions, :user_permissions,
+ :description_html, :blob]
expect(described_class).to have_graphql_fields(*expected_fields)
end
@@ -17,8 +20,55 @@ describe GitlabSchema.types['Snippet'] do
it { expect(described_class).to require_graphql_authorizations(:read_snippet) }
end
+ shared_examples 'response without repository URLs' do
+ it 'does not respond with repository URLs' do
+ expect(response['sshUrlToRepo']).to be_nil
+ expect(response['httpUrlToRepo']).to be_nil
+ 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 snippet has repository' do
+ let!(:snippet) { create(:personal_snippet, :repository, :public, author: user) }
+
+ it 'responds with repository URLs' do
+ expect(response['sshUrlToRepo']).to eq(snippet.ssh_url_to_repo)
+ expect(response['httpUrlToRepo']).to eq(snippet.http_url_to_repo)
+ end
+
+ context 'when version_snippets feature is disabled' do
+ before do
+ stub_feature_flags(version_snippets: false)
+ end
+
+ it_behaves_like 'response without repository URLs'
+ end
+ end
+
+ context 'when snippet does not have a repository' do
+ let!(:snippet) { create(:personal_snippet, :public, author: user) }
+
+ it_behaves_like 'response without repository URLs'
+ end
+ end
+
describe '#blob' do
- let_it_be(:user) { create(:user) }
let(:query_blob) { subject.dig('data', 'snippets', 'edges')[0]['node']['blob'] }
let(:query) do
%(