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-02-25 12:09:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 12:09:10 +0300
commitb98fa9ef3d5bead417ae2f325cb64637883264e9 (patch)
tree409f2002dd056f12d82d3959b3e6f012c4087123 /spec/graphql
parent7e3005967df23a957fe1998c8de4f50b412e69e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r--spec/graphql/types/snippet_type_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb
index a06d372f668..97573f8c46b 100644
--- a/spec/graphql/types/snippet_type_spec.rb
+++ b/spec/graphql/types/snippet_type_spec.rb
@@ -16,4 +16,47 @@ describe GitlabSchema.types['Snippet'] do
describe 'authorizations' do
it { expect(described_class).to require_graphql_authorizations(:read_snippet) }
end
+
+ describe '#blob' do
+ let_it_be(:user) { create(:user) }
+ let(:query_blob) { subject.dig('data', 'snippets', 'edges')[0]['node']['blob'] }
+ let(:query) do
+ %(
+ {
+ snippets {
+ edges {
+ node {
+ blob {
+ name
+ path
+ }
+ }
+ }
+ }
+ }
+ )
+ end
+
+ 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) }
+ let(:blob) { snippet.blobs.first }
+
+ it 'returns blob from the repository' do
+ expect(query_blob['name']).to eq blob.name
+ expect(query_blob['path']).to eq blob.path
+ end
+ end
+
+ context 'when snippet does not have a repository' do
+ let!(:snippet) { create(:personal_snippet, :public, author: user) }
+ let(:blob) { snippet.blob }
+
+ it 'returns SnippetBlob type' do
+ expect(query_blob['name']).to eq blob.name
+ expect(query_blob['path']).to eq blob.path
+ end
+ end
+ end
end