Skip to content
代码片段 群组 项目
提交 efdcedc0 编辑于 作者: Luke Duncalfe's avatar Luke Duncalfe
浏览文件

Merge branch '418171-shared-example-for-all-graphql-fields' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -22,30 +22,13 @@ ...@@ -22,30 +22,13 @@
context "for a #{report_type} vulnerability" do context "for a #{report_type} vulnerability" do
let_it_be(:vulnerability) { create(:vulnerability, project: project, report_type: report_type) } let_it_be(:vulnerability) { create(:vulnerability, project: project, report_type: report_type) }
it_behaves_like "a working graphql query" it_behaves_like 'a working graphql query that returns data' do
it 'returns the vulnerability' do
it 'contains data' do expect(graphql_data.dig('vulnerability', 'id')).to eq "gid://gitlab/Vulnerability/#{vulnerability.id}"
expect(graphql_data['vulnerability']).not_to be_nil expect(graphql_data['vulnerability'].keys).to match_array(vulnerability_fields.to_h.keys)
end
end end
end end
end end
end end
describe 'hasRemediations' do
let(:vulnerability_fields) { 'hasRemediations' }
subject { graphql_data.dig('vulnerability', 'hasRemediations') }
context 'when remediations exist' do
let(:vulnerability) { create(:vulnerability, :with_remediation, project: project) }
it { is_expected.to be(true) }
end
context 'when remediations do not exist' do
let(:vulnerability) { create(:vulnerability, project: project) }
it { is_expected.to be(false) }
end
end
end end
...@@ -5,11 +5,21 @@ ...@@ -5,11 +5,21 @@
it 'returns a successful response', :aggregate_failures do it 'returns a successful response', :aggregate_failures do
expect(response).to have_gitlab_http_status(:success) expect(response).to have_gitlab_http_status(:success)
expect(graphql_errors).to be_nil expect_graphql_errors_to_be_empty
expect(json_response.keys).to include('data') expect(json_response.keys).to include('data')
end end
end end
RSpec.shared_examples 'a working graphql query that returns data' do
include GraphqlHelpers
it_behaves_like 'a working graphql query'
it 'contains data' do
expect(graphql_data.compact).not_to be_empty
end
end
RSpec.shared_examples 'a working GraphQL mutation' do RSpec.shared_examples 'a working GraphQL mutation' do
include GraphqlHelpers include GraphqlHelpers
...@@ -20,11 +30,7 @@ ...@@ -20,11 +30,7 @@
shared_examples 'allows access to the mutation' do shared_examples 'allows access to the mutation' do
let(:scopes) { ['api'] } let(:scopes) { ['api'] }
it_behaves_like 'a working graphql query' do it_behaves_like 'a working graphql query that returns data'
it 'returns data' do
expect(graphql_data.compact).not_to be_empty
end
end
end end
shared_examples 'prevents access to the mutation' do shared_examples 'prevents access to the mutation' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册