Skip to content
Snippets Groups Projects
Commit 0d81ab40 authored by Luke Duncalfe's avatar Luke Duncalfe :two:
Browse files

Refactor specs to use new GraphQL shared examples

parent 43d66cce
No related branches found
No related tags found
1 merge request!128419Refactor specs to use new GraphQL shared examples
......@@ -43,9 +43,7 @@
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
specify { expect(integrations).to be_nil }
it_behaves_like 'a working graphql query that returns no data'
end
context 'with project permissions' do
......@@ -54,7 +52,7 @@
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
it_behaves_like 'a working graphql query that returns data'
specify { expect(integrations.size).to eq(3) }
......
......@@ -27,9 +27,7 @@
post_graphql(query, current_user: user)
end
it_behaves_like 'a working graphql query'
specify { expect(settings_data).to be nil }
it_behaves_like 'a working graphql query that returns no data'
end
context 'with admin permissions' do
......@@ -39,7 +37,7 @@
post_graphql(query, current_user: user)
end
it_behaves_like 'a working graphql query'
it_behaves_like 'a working graphql query that returns data'
it 'fetches the settings data' do
# assert against hash to ensure no additional fields are exposed
......
......@@ -40,7 +40,7 @@
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
it_behaves_like 'a working graphql query that returns data'
it 'contains the expected ids' do
is_expected.to contain_exactly(
......
......@@ -25,7 +25,7 @@
context 'when there is a current_user' do
let_it_be(:current_user) { create(:user) }
it_behaves_like 'a working graphql query'
it_behaves_like 'a working graphql query that returns data'
it { is_expected.to include('name' => current_user.name, 'namespace' => { 'id' => current_user.namespace.to_global_id.to_s }) }
end
......@@ -33,8 +33,6 @@
context 'when there is no current_user' do
let(:current_user) { nil }
it_behaves_like 'a working graphql query'
it { is_expected.to be_nil }
it_behaves_like 'a working graphql query that returns no data'
end
end
......@@ -23,7 +23,7 @@
it 'includes the project', :use_clean_rails_memory_store_caching, :request_store do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']).not_to be_nil
expect(graphql_data['project']).to include('id' => global_id_of(project).to_s)
end
end
......@@ -35,10 +35,10 @@
it 'includes the project' do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']).not_to be_nil
expect(graphql_data['project']).to include('id' => global_id_of(project).to_s)
end
it_behaves_like 'a working graphql query' do
it_behaves_like 'a working graphql query that returns data' do
before do
post_graphql(query, current_user: current_user)
end
......@@ -239,13 +239,7 @@
end
context 'when the user does not have access to the project' do
it 'returns an empty field' do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']).to be_nil
end
it_behaves_like 'a working graphql query' do
it_behaves_like 'a working graphql query that returns no data' do
before do
post_graphql(query, current_user: current_user)
end
......
......@@ -10,6 +10,16 @@
end
end
RSpec.shared_examples 'a working graphql query that returns no data' do
include GraphqlHelpers
it_behaves_like 'a working graphql query'
it 'contains no data' do
expect(graphql_data.compact).to be_empty
end
end
RSpec.shared_examples 'a working graphql query that returns data' do
include GraphqlHelpers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment