Commit f62bce08 authored by charlie ablett's avatar charlie ablett

Refactor tests to use nodes

parent 6285814e
...@@ -124,7 +124,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -124,7 +124,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
end end
describe '#blob' do describe '#blob' do
let(:query_blob) { subject.dig('data', 'snippets', 'edges')[0]['node']['blob'] } let(:query_blob) { subject.dig('data', 'snippets', 'nodes')[0]['blob'] }
subject { GitlabSchema.execute(snippet_query_for(field: 'blob'), context: { current_user: user }).as_json } subject { GitlabSchema.execute(snippet_query_for(field: 'blob'), context: { current_user: user }).as_json }
...@@ -151,21 +151,17 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -151,21 +151,17 @@ RSpec.describe GitlabSchema.types['Snippet'] do
describe '#blobs' do describe '#blobs' do
let_it_be(:snippet) { create(:personal_snippet, :public, author: user) } let_it_be(:snippet) { create(:personal_snippet, :public, author: user) }
let(:query_blobs) { subject.dig('data', 'snippets', 'edges')[0].dig('node', 'blobs', 'edges') } let(:query_blobs) { subject.dig('data', 'snippets', 'nodes')[0].dig('blobs', 'nodes') }
let(:paths) { [] } let(:paths) { [] }
let(:query) do let(:query) do
%( %(
{ {
snippets { snippets {
edges { nodes {
node { blobs(paths: #{paths}) {
blobs(paths: #{paths}) { nodes {
edges { name
node { path
name
path
}
}
} }
} }
} }
...@@ -188,8 +184,8 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -188,8 +184,8 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array' it_behaves_like 'an array'
it 'contains the first blob from the snippet' do it 'contains the first blob from the snippet' do
expect(query_blobs.first['node']['name']).to eq blob.name expect(query_blobs.first['name']).to eq blob.name
expect(query_blobs.first['node']['path']).to eq blob.path expect(query_blobs.first['path']).to eq blob.path
end end
end end
...@@ -200,7 +196,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -200,7 +196,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array' it_behaves_like 'an array'
it 'contains all the blobs from the repository' do it 'contains all the blobs from the repository' do
resulting_blobs_names = query_blobs.map { |b| b['node']['name'] } resulting_blobs_names = query_blobs.map { |b| b['name'] }
expect(resulting_blobs_names).to match_array(blobs.map(&:name)) expect(resulting_blobs_names).to match_array(blobs.map(&:name))
end end
...@@ -211,7 +207,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -211,7 +207,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array' it_behaves_like 'an array'
it 'returns specific files' do it 'returns specific files' do
resulting_blobs_names = query_blobs.map { |b| b['node']['name'] } resulting_blobs_names = query_blobs.map { |b| b['name'] }
expect(resulting_blobs_names).to match(paths) expect(resulting_blobs_names).to match(paths)
end end
...@@ -223,12 +219,10 @@ RSpec.describe GitlabSchema.types['Snippet'] do ...@@ -223,12 +219,10 @@ RSpec.describe GitlabSchema.types['Snippet'] do
%( %(
{ {
snippets { snippets {
edges { nodes {
node { #{field} {
#{field} { name
name path
path
}
} }
} }
} }
......
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