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
end
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 }
......@@ -151,17 +151,15 @@ RSpec.describe GitlabSchema.types['Snippet'] do
describe '#blobs' do
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(:query) do
%(
{
snippets {
edges {
node {
nodes {
blobs(paths: #{paths}) {
edges {
node {
nodes {
name
path
}
......@@ -169,8 +167,6 @@ RSpec.describe GitlabSchema.types['Snippet'] do
}
}
}
}
}
)
end
......@@ -188,8 +184,8 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array'
it 'contains the first blob from the snippet' do
expect(query_blobs.first['node']['name']).to eq blob.name
expect(query_blobs.first['node']['path']).to eq blob.path
expect(query_blobs.first['name']).to eq blob.name
expect(query_blobs.first['path']).to eq blob.path
end
end
......@@ -200,7 +196,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array'
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))
end
......@@ -211,7 +207,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like 'an array'
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)
end
......@@ -223,8 +219,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
%(
{
snippets {
edges {
node {
nodes {
#{field} {
name
path
......@@ -232,7 +227,6 @@ RSpec.describe GitlabSchema.types['Snippet'] do
}
}
}
}
)
end
end
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