summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql/ci
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/graphql/ci')
-rw-r--r--spec/requests/api/graphql/ci/config_spec.rb62
-rw-r--r--spec/requests/api/graphql/ci/jobs_spec.rb8
2 files changed, 42 insertions, 28 deletions
diff --git a/spec/requests/api/graphql/ci/config_spec.rb b/spec/requests/api/graphql/ci/config_spec.rb
index 8154f132430..5f43a0806f3 100644
--- a/spec/requests/api/graphql/ci/config_spec.rb
+++ b/spec/requests/api/graphql/ci/config_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe 'Query.ciConfig', feature_category: :continuous_integration do
include GraphqlHelpers
include StubRequests
+ include RepoHelpers
subject(:post_graphql_query) { post_graphql(query, current_user: user) }
@@ -245,17 +246,22 @@ RSpec.describe 'Query.ciConfig', feature_category: :continuous_integration do
)
end
- before do
- allow_next_instance_of(Repository) do |repository|
- allow(repository).to receive(:blob_data_at).with(an_instance_of(String), 'other_file.yml') do
- YAML.dump(
- build: {
- script: 'build'
- }
- )
- end
+ let(:project_files) do
+ {
+ 'other_file.yml' => <<~YAML
+ build:
+ script: build
+ YAML
+ }
+ end
+
+ around do |example|
+ create_and_delete_files(project, project_files) do
+ example.run
end
+ end
+ before do
post_graphql_query
end
@@ -370,25 +376,33 @@ RSpec.describe 'Query.ciConfig', feature_category: :continuous_integration do
)
end
- before do
- allow_next_instance_of(Repository) do |repository|
- allow(repository).to receive(:blob_data_at).with(an_instance_of(String), 'other_file.yml') do
- YAML.dump(
- build: {
- script: 'build'
- }
- )
- end
+ let(:project_files) do
+ {
+ 'other_file.yml' => <<~YAML
+ build:
+ script: build
+ YAML
+ }
+ end
- allow(repository).to receive(:blob_data_at).with(an_instance_of(String), 'other_project_file.yml') do
- YAML.dump(
- other_project_test: {
- script: 'other_project_test'
- }
- )
+ let(:other_project_files) do
+ {
+ 'other_project_file.yml' => <<~YAML
+ other_project_test:
+ script: other_project_test
+ YAML
+ }
+ end
+
+ around do |example|
+ create_and_delete_files(project, project_files) do
+ create_and_delete_files(other_project, other_project_files) do
+ example.run
end
end
+ end
+ before do
stub_full_request('https://gitlab.com/gitlab-org/gitlab/raw/1234/.hello.yml').to_return(body: remote_file_content)
post_graphql_query
diff --git a/spec/requests/api/graphql/ci/jobs_spec.rb b/spec/requests/api/graphql/ci/jobs_spec.rb
index 7a1dc614dcf..131cdb77107 100644
--- a/spec/requests/api/graphql/ci/jobs_spec.rb
+++ b/spec/requests/api/graphql/ci/jobs_spec.rb
@@ -88,10 +88,10 @@ RSpec.describe 'Query.project.pipeline', feature_category: :continuous_integrati
build_stage = create(:ci_stage, position: 2, name: 'build', project: project, pipeline: pipeline)
test_stage = create(:ci_stage, position: 3, name: 'test', project: project, pipeline: pipeline)
- create(:ci_build, pipeline: pipeline, name: 'docker 1 2', scheduling_type: :stage, stage: build_stage, stage_idx: build_stage.position)
- create(:ci_build, pipeline: pipeline, name: 'docker 2 2', stage: build_stage, stage_idx: build_stage.position, scheduling_type: :dag)
- create(:ci_build, pipeline: pipeline, name: 'rspec 1 2', scheduling_type: :stage, stage: test_stage, stage_idx: test_stage.position)
- test_job = create(:ci_build, pipeline: pipeline, name: 'rspec 2 2', scheduling_type: :dag, stage: test_stage, stage_idx: test_stage.position)
+ create(:ci_build, pipeline: pipeline, name: 'docker 1 2', scheduling_type: :stage, ci_stage: build_stage, stage_idx: build_stage.position)
+ create(:ci_build, pipeline: pipeline, name: 'docker 2 2', ci_stage: build_stage, stage_idx: build_stage.position, scheduling_type: :dag)
+ create(:ci_build, pipeline: pipeline, name: 'rspec 1 2', scheduling_type: :stage, ci_stage: test_stage, stage_idx: test_stage.position)
+ test_job = create(:ci_build, pipeline: pipeline, name: 'rspec 2 2', scheduling_type: :dag, ci_stage: test_stage, stage_idx: test_stage.position)
create(:ci_build_need, build: test_job, name: 'my test job')
end