debian-mirror-gitlab/spec/requests/api/graphql/ci/groups_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.6 KiB
Ruby
Raw Permalink Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Query.project.pipeline.stages.groups', feature_category: :continuous_integration do
2020-10-24 23:57:45 +05:30
include GraphqlHelpers
2021-04-29 21:17:54 +05:30
let_it_be(:project) { create(:project, :repository, :public) }
let_it_be(:user) { create(:user) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:group_graphql_data) { graphql_data_at(:project, :pipeline, :stages, :nodes, 0, :groups, :nodes) }
let_it_be(:ref) { 'master' }
2023-04-23 21:23:45 +05:30
let_it_be(:stage) { create(:ci_stage, pipeline: pipeline) }
let_it_be(:job_a) { create(:commit_status, pipeline: pipeline, name: 'rspec 0 2', ref: ref, ci_stage: stage) }
let_it_be(:job_b) { create(:ci_build, pipeline: pipeline, name: 'rspec 0 1', ref: ref, ci_stage: stage) }
2021-04-29 21:17:54 +05:30
let_it_be(:job_c) { create(:ci_bridge, pipeline: pipeline, name: 'spinach 0 1', ref: ref) }
2020-10-24 23:57:45 +05:30
let(:params) { {} }
let(:fields) do
<<~QUERY
nodes {
#{all_graphql_fields_for('CiGroup')}
}
QUERY
end
let(:query) do
%(
query {
project(fullPath: "#{project.full_path}") {
pipeline(iid: "#{pipeline.iid}") {
stages {
nodes {
groups {
#{fields}
}
}
}
}
}
}
)
end
before do
post_graphql(query, current_user: user)
end
it_behaves_like 'a working graphql query'
it 'returns a array of jobs belonging to a pipeline' do
2021-04-29 21:17:54 +05:30
expect(group_graphql_data).to contain_exactly(
a_hash_including('name' => 'rspec', 'size' => 2),
a_hash_including('name' => 'spinach', 'size' => 1)
)
2020-10-24 23:57:45 +05:30
end
end