INSTRUCTION stringlengths 202 35.5k | RESPONSE stringlengths 75 161k |
|---|---|
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Discussions
class CaptureDiffNotePositionService
def initialize(merge_request, paths)
@project = merge_request.project
@tracer = build_tracer(merge_request, paths)
end
def execute(discussion)
# ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Discussions::CaptureDiffNotePositionService, feature_category: :code_review_workflow do
subject { described_class.new(note.noteable, paths) }
context 'image note on diff' do
let!(:note) { create(:image_diff_note_on_merge_request) }
let(:p... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class AwardService
attr_reader :current_user, :achievement_id, :recipient_id
def initialize(current_user, achievement_id, recipient_id)
@current_user = current_user
@achievement_id = achievem... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::AwardService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:developer) { create(:user) }
let_it_be(:maintainer) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:achievement) { cre... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class UpdateUserAchievementPrioritiesService
attr_reader :current_user, :user_achievements
def initialize(current_user, user_achievements)
@current_user = current_user
@user_achievements = us... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::UpdateUserAchievementPrioritiesService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:achievement_owner) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:achievement) { create(:achie... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class DestroyUserAchievementService
attr_reader :current_user, :user_achievement
def initialize(current_user, user_achievement)
@current_user = current_user
@user_achievement = user_achieveme... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::DestroyUserAchievementService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:maintainer) { create(:user) }
let_it_be(:owner) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:achi... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class RevokeService
attr_reader :current_user, :user_achievement
def initialize(current_user, user_achievement)
@current_user = current_user
@user_achievement = user_achievement
end
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::RevokeService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:developer) { create(:user) }
let_it_be(:maintainer) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:achievement) { cr... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class DestroyService
attr_reader :current_user, :achievement
def initialize(current_user, achievement)
@current_user = current_user
@achievement = achievement
end
def execute
r... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::DestroyService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:developer) { create(:user) }
let_it_be(:maintainer) { create(:user) }
let_it_be(:group) { create(:group) }
let(:achievement) { create... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class UpdateService
attr_reader :current_user, :achievement, :params
def initialize(current_user, achievement, params)
@current_user = current_user
@achievement = achievement
@params = ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::UpdateService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:user) { create(:user) }
let(:params) { attributes_for(:achievement, namespace: group) }
subject(:response) { described_class.new(user, gr... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Achievements
class CreateService < BaseService
def execute
return error_no_permissions unless allowed?
achievement = Achievements::Achievement.create(params.merge(namespace_id: @namespace.id))
return e... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Achievements::CreateService, feature_category: :user_profile do
describe '#execute' do
let_it_be(:user) { create(:user) }
let(:params) { attributes_for(:achievement, namespace: group) }
subject(:response) { described_class.new(namespac... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
class MergeReportsService
attr_reader :source_reports
def initialize(*source_reports)
@source_reports = source_reports
end
def execute
copy_resources_to_target_report
copy_findings... | # frozen_string_literal: true
require 'spec_helper'
# rubocop: disable RSpec/MultipleMemoizedHelpers
RSpec.describe Security::MergeReportsService, '#execute', feature_category: :code_review_workflow do
let(:scanner_1) { build(:ci_reports_security_scanner, external_id: 'scanner-1', name: 'Scanner 1') }
let(:scanne... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
class DependencyScanningCreateService < ::Security::CiConfiguration::BaseCreateService
private
def action
Security::CiConfiguration::DependencyScanningBuildAction.new(p... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::DependencyScanningCreateService, :snowplow,
feature_category: :software_composition_analysis do
subject(:result) { described_class.new(project, user).execute }
let(:branch_name) { 'set-dependency-scanning-config-1' }
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
class SastCreateService < ::Security::CiConfiguration::BaseCreateService
attr_reader :params
def initialize(project, current_user, params, commit_on_default: false)
sup... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::SastCreateService, :snowplow,
feature_category: :static_application_security_testing do
subject(:result) { described_class.new(project, user, params).execute }
let(:branch_name) { 'set-sast-config-1' }
let(:non_emp... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
# This class parses SAST template file and .gitlab-ci.yml to populate default and current values into the JSON
# read from app/validators/json_schemas/security_ci_configuration_schemas/... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::SastParserService, feature_category: :static_application_security_testing do
describe '#configuration' do
include_context 'read ci configuration for sast enabled project'
let(:configuration) { described_class.new(... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
class SecretDetectionCreateService < ::Security::CiConfiguration::BaseCreateService
private
def action
Security::CiConfiguration::SecretDetectionBuildAction.new(project... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::SecretDetectionCreateService, :snowplow, feature_category: :container_scanning do
subject(:result) { described_class.new(project, user).execute }
let(:branch_name) { 'set-secret-detection-config-1' }
let(:snowplow_ev... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
class ContainerScanningCreateService < ::Security::CiConfiguration::BaseCreateService
private
def action
Security::CiConfiguration::ContainerScanningBuildAction.new(pro... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::ContainerScanningCreateService, :snowplow, feature_category: :container_scanning do
subject(:result) { described_class.new(project, user).execute }
let(:branch_name) { 'set-container-scanning-config-1' }
let(:snowplo... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Security
module CiConfiguration
class SastIacCreateService < ::Security::CiConfiguration::BaseCreateService
private
def action
Security::CiConfiguration::SastIacBuildAction.new(project.auto_devops_ena... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Security::CiConfiguration::SastIacCreateService, :snowplow, feature_category: :static_application_security_testing do
subject(:result) { described_class.new(project, user).execute }
let(:branch_name) { 'set-sast-iac-config-1' }
let(:snowplow_e... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Auth
class DependencyProxyAuthenticationService < BaseService
AUDIENCE = 'dependency_proxy'
HMAC_KEY = 'gitlab-dependency-proxy'
DEFAULT_EXPIRE_TIME = 1.minute
def execute(authentication_abilities:)
ret... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Auth::DependencyProxyAuthenticationService, feature_category: :dependency_proxy do
let_it_be(:user) { create(:user) }
let_it_be(:params) { {} }
let(:service) { described_class.new(nil, user, params) }
before do
stub_config(dependency_pro... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Auth
class ContainerRegistryAuthenticationService < BaseService
AUDIENCE = 'container_registry'
REGISTRY_LOGIN_ABILITIES = [
:read_container_image,
:create_container_image,
:destroy_container_image,
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Auth::ContainerRegistryAuthenticationService, feature_category: :container_registry do
include AdminModeHelper
it_behaves_like 'a container registry auth service'
end
|
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
include ValidatesClassificationLabel
attr_reader :params, :application_setting
MARKDOWN_CACHE_INVALIDATING_PARAMS = %w[asset_proxy_enabl... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ApplicationSettings::UpdateService, feature_category: :shared do
include ExternalAuthorizationServiceHelpers
let(:application_settings) { ::Gitlab::CurrentSettings.current_application_settings }
let(:admin) { create(:user, :admin) }
let(:para... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module BatchedGitRefUpdates
class CleanupSchedulerService
include Gitlab::ExclusiveLeaseHelpers
MAX_PROJECTS = 10_000
BATCH_SIZE = 100
LOCK_TIMEOUT = 10.minutes
def execute
total_projects = 0
in_loc... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe BatchedGitRefUpdates::CleanupSchedulerService, feature_category: :gitaly do
let(:service) { described_class.new }
describe '#execute' do
before do
BatchedGitRefUpdates::Deletion.create!(project_id: 123, ref: 'ref1')
BatchedGitRefU... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module BatchedGitRefUpdates
class ProjectCleanupService
include ::Gitlab::ExclusiveLeaseHelpers
LOCK_TIMEOUT = 10.minutes
GITALY_BATCH_SIZE = 100
QUERY_BATCH_SIZE = 1000
MAX_DELETES = 10_000
def initialize(... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe BatchedGitRefUpdates::ProjectCleanupService, feature_category: :gitaly do
let(:service) { described_class.new(project1.id) }
let_it_be(:project1) { create(:project, :repository) }
let_it_be(:project2) { create(:project, :repository) }
let!(:pr... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ProcessSyncEventsService
include ExclusiveLeaseGuard
BATCH_SIZE = 1000
def initialize(sync_event_class, sync_class)
@sync_event_class = sync_event_class
@sync_class = sync_class
@resul... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ProcessSyncEventsService, feature_category: :continuous_integration do
let!(:group) { create(:group) }
let!(:project1) { create(:project, group: group) }
let!(:project2) { create(:project, group: group) }
let!(:parent_group_1) { create(:gr... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class TestFailureHistoryService
class Async
attr_reader :service
def initialize(service)
@service = service
end
def perform_if_needed
TestFailureHistoryWorker.perform_async(ser... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::TestFailureHistoryService, :aggregate_failures, feature_category: :continuous_integration do
let_it_be(:project) { create(:project, :repository) }
let_it_be_with_reload(:pipeline) do
create(:ci_pipeline, status: :created, project: project... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class UnlockPipelineService
include BaseServiceUtility
include ::Gitlab::ExclusiveLeaseHelpers
ExecutionTimeoutError = Class.new(StandardError)
BATCH_SIZE = 100
MAX_EXEC_DURATION = 10.minutes.freeze
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UnlockPipelineService, :unlock_pipelines, :clean_gitlab_redis_shared_state, feature_category: :build_artifacts do
describe '#execute', :aggregate_failures do
let(:service) { described_class.new(pipeline) }
let!(:pipeline) do
creat... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ExpirePipelineCacheService
class UrlHelpers
include ::Gitlab::Routing
include ::GitlabRoutingHelper
end
def execute(pipeline, delete: false)
store = Gitlab::EtagCaching::Store.new
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ExpirePipelineCacheService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
# This service tracks failed CI builds using Snowplow.
#
# @param build [Ci::Build] the build that failed.
# @param exit_code [Int] the resulting exit code.
module Ci
class TrackFailedBuildService
SCHEMA_URL = 'iglu:com.gitlab/c... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::TrackFailedBuildService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let_it_... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ChangeVariablesService < BaseContainerService
def execute
container.update(params)
end
end
end
::Ci::ChangeVariablesService.prepend_mod_with('Ci::ChangeVariablesService')
``` | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ChangeVariablesService, feature_category: :secrets_management do
let(:service) { described_class.new(container: group, current_user: user, params: params) }
let_it_be(:user) { create(:user) }
let(:group) { spy(:group, variables: []) }
le... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class RetryJobService < ::BaseService
include Gitlab::Utils::StrongMemoize
def execute(job, variables: [])
if job.retryable?
job.ensure_scheduling_type!
new_job = retry_job(job, variables: va... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::RetryJobService, feature_category: :continuous_integration do
using RSpec::Parameterized::TableSyntax
let_it_be(:reporter) { create(:user) }
let_it_be(:developer) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
le... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DeleteUnitTestsService
include EachBatch
BATCH_SIZE = 100
def execute
purge_data!(Ci::UnitTestFailure)
purge_data!(Ci::UnitTest)
end
private
def purge_data!(klass)
loop d... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DeleteUnitTestsService, feature_category: :continuous_integration do
describe '#execute' do
let!(:unit_test_1) { create(:ci_unit_test) }
let!(:unit_test_2) { create(:ci_unit_test) }
let!(:unit_test_3) { create(:ci_unit_test) }
le... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
# This class is a simplified version of assign_nested_attributes_for_collection_association from ActiveRecord
# https://github.com/rails/rails/blob/v6.0.2.1/activerecord/lib/active_record/nested_attributes.rb#L466
module Ci
class U... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UpdateInstanceVariablesService, feature_category: :secrets_management do
let(:params) { { variables_attributes: variables_attributes } }
subject { described_class.new(params) }
describe '#execute' do
context 'without variables' do
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# TODO: a couple of points with this approach:
# + reuses existing architecture and reactive caching
# - it's not a report comparison and some comparing features must be turned off.
# see CompareReportsBaseService fo... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::GenerateCoverageReportsService, feature_category: :code_testing do
let_it_be(:project) { create(:project, :repository) }
let(:service) { described_class.new(project) }
describe '#execute' do
subject { service.execute(base_pipeline, hea... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ProcessPipelineService
attr_reader :pipeline
def initialize(pipeline)
@pipeline = pipeline
end
def execute
increment_processing_counter
Ci::PipelineProcessing::AtomicProcessingSer... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ProcessPipelineService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let(:pipeline) do
create(:ci_empty_pipeline, ref: 'master', project: project)
end
let(:pipeline_processing_events_counter) ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CreateWebIdeTerminalService < ::BaseService
include ::Gitlab::Utils::StrongMemoize
TerminalCreationError = Class.new(StandardError)
TERMINAL_NAME = 'terminal'
attr_reader :terminal
def execute... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CreateWebIdeTerminalService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let(:ref) { 'master' }
describe '#execute' do
subject { described_clas... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# Takes in input a Ci::Bridge job and creates a downstream pipeline
# (either multi-project or child pipeline) according to the Ci::Bridge
# specifications.
class CreateDownstreamPipelineService < ::BaseService
i... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CreateDownstreamPipelineService, '#execute', feature_category: :continuous_integration do
include Ci::SourcePipelineHelpers
# Using let_it_be on user and projects for these specs can cause
# spec-ordering failures due to the project-based p... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ArchiveTraceService
include ::Gitlab::ExclusiveLeaseHelpers
EXCLUSIVE_LOCK_KEY = 'archive_trace_service:batch_execute:lock'
LOCK_TIMEOUT = 56.minutes
LOOP_TIMEOUT = 55.minutes
LOOP_LIMIT = 2000
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ArchiveTraceService, '#execute', feature_category: :continuous_integration do
subject { described_class.new.execute(job, worker_name: Ci::ArchiveTraceWorker.name) }
context 'when job is finished' do
let(:job) { create(:ci_build, :success,... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class UnlockArtifactsService < ::BaseService
BATCH_SIZE = 100
def execute(ci_ref, before_pipeline = nil)
results = {
unlocked_pipelines: 0,
unlocked_job_artifacts: 0,
unlocked_pipelin... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UnlockArtifactsService, feature_category: :continuous_integration do
using RSpec::Parameterized::TableSyntax
where(:tag) do
[
[false],
[true]
]
end
with_them do
let(:ref) { 'master' }
let(:ref_path) { tag ? "#... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# Cancel a pipelines cancelable jobs and optionally it's child pipelines cancelable jobs
class CancelPipelineService
include Gitlab::OptimisticLocking
include Gitlab::Allowable
##
# @cascade_to_children ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CancelPipelineService, :aggregate_failures, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let_it_be(:current_user) { project.owner }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
l... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# This service resets skipped jobs so they can be processed again.
# It affects the jobs that depend on the passed in job parameter.
class ResetSkippedJobsService < ::BaseService
def execute(processables)
@pr... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ResetSkippedJobsService, :sidekiq_inline, feature_category: :continuous_integration do
let_it_be(:project) { create(:project, :empty_repo) }
let_it_be(:user) { project.first_owner }
let(:pipeline) do
Ci::CreatePipelineService.new(projec... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CopyCrossDatabaseAssociationsService
def execute(old_build, new_build)
ServiceResponse.success
end
end
end
Ci::CopyCrossDatabaseAssociationsService.prepend_mod_with('Ci::CopyCrossDatabaseAssociations... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CopyCrossDatabaseAssociationsService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let_it_be(:old_build) { create(:ci_build, pipeline: p... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CompareTestReportsService < CompareReportsBaseService
def comparer_class
Gitlab::Ci::Reports::TestReportsComparer
end
def serializer_class
TestReportsComparerSerializer
end
def get_r... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CompareTestReportsService, feature_category: :continuous_integration do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
describe '#execute' do
subject(:comparison) { service.execute(base_pi... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PlayBuildService < ::BaseService
def execute(build, job_variables_attributes = nil)
check_access!(build, job_variables_attributes)
Ci::EnqueueJobService.new(build, current_user: current_user, variabl... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PlayBuildService, '#execute', feature_category: :continuous_integration do
let(:user) { create(:user, developer_projects: [project]) }
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build)... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class RetryPipelineService < ::BaseService
include Gitlab::OptimisticLocking
def execute(pipeline)
access_response = check_access(pipeline)
return access_response if access_response.error?
pipel... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::RetryPipelineService, '#execute', feature_category: :continuous_integration do
include ProjectForksHelper
let_it_be_with_refind(:user) { create(:user) }
let_it_be_with_refind(:project) { create(:project) }
let(:pipeline) { create(:ci_pip... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PipelineScheduleService < BaseService
def execute(schedule)
return unless project.persisted?
# Ensure `next_run_at` is set properly before creating a pipeline.
# Otherwise, multiple pipelines c... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineScheduleService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:service) { described_class.new(project, user) }
describe '#execute' do
subject { s... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
##
# We call this service everytime we persist a CI/CD job.
#
# In most cases a job should already have a stage assigned, but in cases it
# doesn't have we need to either find existing one or create a brand new
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::EnsureStageService, '#execute', feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let(:stage) { create(:ci_stage) }
let(:job) { build(:ci_build) }
let(:service) { d... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ChangeVariableService < BaseContainerService
def execute
case params[:action]
when :create
container.variables.create(params[:variable_params])
when :update
variable.tap do |targ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ChangeVariableService, feature_category: :secrets_management do
let(:service) { described_class.new(container: group, current_user: user, params: params) }
let_it_be(:user) { create(:user) }
let(:group) { create(:group) }
describe '#exe... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DestroyPipelineService < BaseService
def execute(pipeline)
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_pipeline, pipeline)
Ci::ExpirePipelineCacheService.new.execute(pi... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ci::DestroyPipelineService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project, :repository) }
let!(:pipeline) { create(:ci_pipeline, :success, project: project, sha: project.commit.id) }
subject { described_c... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class AppendBuildTraceService
Result = Struct.new(:status, :stream_size, keyword_init: true)
TraceRangeError = Class.new(StandardError)
attr_reader :build, :params
def initialize(build, params)
@bui... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::AppendBuildTraceService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let_it_be_with_reload(:build) { create(:ci_build, :running, pipeli... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class UpdateBuildQueueService
InvalidQueueTransition = Class.new(StandardError)
attr_reader :metrics
def initialize(metrics = ::Gitlab::Ci::Queue::Metrics)
@metrics = metrics
end
##
# Add a... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UpdateBuildQueueService, feature_category: :continuous_integration do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
describe... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# TODO: when using this class with exposed artifacts we see that there are
# 2 responsibilities:
# 1. reactive caching interface (same in all cases)
# 2. data generator (report comparison in most of the case but not ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CompareReportsBaseService, feature_category: :continuous_integration do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ci_pipeline... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CreateCommitStatusService < BaseService
include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::Utils::StrongMemoize
include ::Services::ReturnServiceResponses
delegate :sha, to: :commit
def e... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CreateCommitStatusService, :clean_gitlab_redis_cache, feature_category: :continuous_integration do
using RSpec::Parameterized::TableSyntax
subject(:response) { execute_service(params) }
let_it_be_with_refind(:project) { create(:project, :r... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CompareCodequalityReportsService < CompareReportsBaseService
def comparer_class
Gitlab::Ci::Reports::CodequalityReportsComparer
end
def serializer_class
CodequalityReportsComparerSerializer
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CompareCodequalityReportsService, feature_category: :continuous_integration do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
describe '#execute' do
subject { service.execute(base_pipeline... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DeleteObjectsService
TransactionInProgressError = Class.new(StandardError)
TRANSACTION_MESSAGE = "can't perform network calls inside a database transaction"
BATCH_SIZE = 100
RETRY_IN = 10.minutes
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DeleteObjectsService, :aggregate_failures, feature_category: :continuous_integration do
let(:service) { described_class.new }
let(:artifact) { create(:ci_job_artifact, :archive) }
let(:data) { [artifact] }
describe '#execute' do
befor... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DropPipelineService
PRELOADED_RELATIONS = [:project, :pipeline, :metadata, :deployment, :taggings].freeze
# execute service asynchronously for each cancelable pipeline
def execute_async_for_all(pipelines... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DropPipelineService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let(:failure_reason) { :user_blocked }
let!(:cancelable_pipeline) { create(:ci_pipeline, :running, user: user) }
let!(:running_build) { ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PipelineTriggerService < BaseService
include Gitlab::Utils::StrongMemoize
include Services::ReturnServiceResponses
include Ci::DownstreamPipelineHelpers
def execute
if trigger_from_token
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineTriggerService, feature_category: :continuous_integration do
include AfterNextHelpers
let_it_be(:project) { create(:project, :repository) }
before do
stub_ci_pipeline_to_return_yaml_file
end
describe '#execute' do
let_... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class BuildCancelService
def initialize(build, user)
@build = build
@user = user
end
def execute
return forbidden unless allowed?
return unprocessable_entity unless build.cancelable?
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::BuildCancelService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
describe '#execute' do
subjec... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class RunScheduledBuildService < ::BaseService
def execute(build)
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
end
build.enqueue_scheduled!
end
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::RunScheduledBuildService, feature_category: :continuous_integration do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class.new(project, user).... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# TODO: a couple of points with this approach:
# + reuses existing architecture and reactive caching
# - it's not a report comparison and some comparing features must be turned off.
# see CompareReportsBaseService fo... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::GenerateCodequalityMrDiffReportService, feature_category: :code_review_workflow do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
describe '#execute' do
subject { service.execute(base_pipe... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class GenerateKubeconfigService
def initialize(pipeline, token:, environment:)
@pipeline = pipeline
@token = token
@environment = environment
@template = Gitlab::Kubernetes::Kubeconfig::Templat... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::GenerateKubeconfigService, feature_category: :deployment_management do
describe '#execute' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:pipeline) { create(:ci_empty_pipelin... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class UpdateBuildStateService
include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::ExclusiveLeaseHelpers
Result = Struct.new(:status, :backoff, keyword_init: true)
InvalidTraceError = Class.new(Standar... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UpdateBuildStateService, feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PlayManualStageService < BaseService
def initialize(project, current_user, params)
super
@pipeline = params[:pipeline]
end
def execute(stage)
stage.processables.manual.each do |process... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PlayManualStageService, '#execute', feature_category: :continuous_integration do
let(:current_user) { create(:user) }
let(:pipeline) { create(:ci_pipeline, user: current_user) }
let(:project) { pipeline.project }
let(:downstream_project) {... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class BuildEraseService
include BaseServiceUtility
def initialize(build, current_user)
@build = build
@current_user = current_user
end
def execute
unless build.erasable?
return S... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::BuildEraseService, feature_category: :continuous_integration do
let_it_be(:user) { user }
let(:build) { create(:ci_build, :artifacts, :trace_artifact, artifacts_expire_at: 100.days.from_now) }
subject(:service) { described_class.new(build,... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ListConfigVariablesService < ::BaseService
include ReactiveCaching
self.reactive_cache_key = ->(service) { [service.class.name, service.id] }
self.reactive_cache_work_type = :external_dependency
self... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ListConfigVariablesService,
:use_clean_rails_memory_store_caching, feature_category: :secrets_management do
include ReactiveCachingHelpers
let(:ci_config) { {} }
let(:files) { { '.gitlab-ci.yml' => YAML.dump(ci_config) } }
let(:project)... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PlayBridgeService < ::BaseService
def execute(bridge)
check_access!(bridge)
Ci::EnqueueJobService.new(bridge, current_user: current_user).execute
end
private
def check_access!(bridge)
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PlayBridgeService, '#execute', feature_category: :continuous_integration do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:downstream_project) { create(:projec... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# This class loops through all builds with exposed artifacts and returns
# basic information about exposed artifacts for given jobs for the frontend
# to display them as custom links in the merge request.
#
# This ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::FindExposedArtifactsService, feature_category: :build_artifacts do
include Gitlab::Routing
let(:metadata) do
Gitlab::Ci::Build::Artifacts::Metadata
.new(metadata_file_stream, path, { recursive: true })
end
let(:metadata_file_st... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class UpdatePendingBuildService
VALID_PARAMS = %i[instance_runners_enabled namespace_id namespace_traversal_ids].freeze
InvalidParamsError = Class.new(StandardError)
InvalidModelError = Class.new(StandardError... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::UpdatePendingBuildService, feature_category: :continuous_integration do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, namespace: group) }
let_it_be_with_reload(:pending_build_1) { create(:ci_pending_build, proje... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CreatePipelineService < BaseService
attr_reader :pipeline, :logger
LOG_MAX_DURATION_THRESHOLD = 3.seconds
LOG_MAX_PIPELINE_SIZE = 2_000
LOG_MAX_CREATION_THRESHOLD = 20.seconds
SEQUENCE = [Gitlab:... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness, :clean_gitlab_redis_cache, feature_category: :continuous_integration do
include ProjectForksHelper
let_it_be_with_refind(:project) { create(:project, :repository) }
let_it_be_w... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DailyBuildGroupReportResultService
def execute(pipeline)
if DailyBuildGroupReportResult.upsert_reports(coverage_reports(pipeline))
Projects::CiFeatureUsage.insert_usage(
project_id: pipeli... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute', feature_category: :continuous_integration do
let_it_be(:group) { create(:group, :private) }
let_it_be(:pipeline) { create(:ci_pipeline, project: create(:project, group: group), created_at: '2020-... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class EnqueueJobService
attr_accessor :job, :current_user, :variables
def initialize(job, current_user:, variables: nil)
@job = job
@current_user = current_user
@variables = variables
end
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::EnqueueJobService, '#execute', feature_category: :continuous_integration do
let_it_be(:project) { create(:project) }
let(:user) { create(:user, developer_projects: [project]) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class BuildUnscheduleService
def initialize(build, user)
@build = build
@user = user
end
def execute
return forbidden unless allowed?
return unprocessable_entity unless build.scheduled?... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::BuildUnscheduleService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
describe '#execute' do
su... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ProcessBuildService < BaseService
def execute(processable, current_status)
if valid_statuses_for_processable(processable).include?(current_status)
process(processable)
true
else
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ProcessBuildService, '#execute', feature_category: :continuous_integration do
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, re... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DisableUserPipelineSchedulesService
def execute(user)
Ci::PipelineSchedule.active.owned_by(user).each_batch do |relation|
relation.update_all(active: false)
end
end
end
end
``` | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DisableUserPipelineSchedulesService, feature_category: :continuous_integration do
describe '#execute' do
let(:user) { create(:user) }
subject(:service) { described_class.new.execute(user) }
context 'when user has active pipeline sc... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class BuildReportResultService
include Gitlab::Utils::UsageData
EVENT_NAME = 'i_testing_test_case_parsed'
def execute(build)
return unless build.has_test_reports?
test_suite = generate_test_suite... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::BuildReportResultService, feature_category: :continuous_integration do
describe '#execute', :clean_gitlab_redis_shared_state do
subject(:build_report_result) { described_class.new.execute(build) }
context 'when build is finished' do
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class DestroySecureFileService < BaseService
def execute(secure_file)
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :admin_secure_files, secure_file.project)
secure_file.destroy!
en... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ci::DestroySecureFileService, feature_category: :continuous_integration do
let_it_be(:maintainer_user) { create(:user) }
let_it_be(:developer_user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:secure_file) { create(:... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PrepareBuildService
attr_reader :build
def initialize(build)
@build = build
end
def execute
prerequisites.each(&:complete!)
build.enqueue_preparing!
rescue StandardError => e
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PrepareBuildService, feature_category: :continuous_integration do
describe '#execute' do
let(:build) { create(:ci_build, :preparing) }
subject { described_class.new(build).execute }
before do
allow(build).to receive(:prerequi... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class PipelineBridgeStatusService < ::BaseService
def execute(pipeline)
return unless pipeline.bridge_triggered?
begin
pipeline.source_bridge.inherit_status_from_downstream!(pipeline)
rescue ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineBridgeStatusService, feature_category: :continuous_integration do
let(:user) { build(:user) }
let_it_be(:project) { create(:project) }
let(:pipeline) { build(:ci_pipeline, project: project) }
describe '#execute' do
subject { ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# This class responsible for assigning
# proper pending build to runner on runner API request
class RegisterJobService
include ::Gitlab::Ci::Artifacts::Logger
attr_reader :runner, :runner_manager, :metrics
... | # frozen_string_literal: true
require 'spec_helper'
module Ci
RSpec.describe RegisterJobService, feature_category: :continuous_integration do
let_it_be(:group) { create(:group) }
let_it_be_with_reload(:project) { create(:project, group: group, shared_runners_enabled: false, group_runners_enabled: false) }
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ParseAnnotationsArtifactService < ::BaseService
include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::EncodingHelper
SizeLimitError = Class.new(StandardError)
ParserError = Class.new(StandardError... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ParseAnnotationsArtifactService, feature_category: :build_artifacts do
let_it_be(:project) { create(:project) }
let_it_be_with_reload(:build) { create(:ci_build, project: project) }
let(:service) { described_class.new(project, nil) }
des... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class ParseDotenvArtifactService < ::BaseService
include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::EncodingHelper
SizeLimitError = Class.new(StandardError)
ParserError = Class.new(StandardError)
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ParseDotenvArtifactService, feature_category: :build_artifacts do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline, project: project)... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
# TODO: a couple of points with this approach:
# + reuses existing architecture and reactive caching
# - it's not a report comparison and some comparing features must be turned off.
# see CompareReportsBaseService fo... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::GenerateTerraformReportsService, feature_category: :infrastructure_as_code do
let_it_be(:project) { create(:project, :repository) }
describe '#execute' do
let_it_be(:merge_request) { create(:merge_request, :with_terraform_reports, source_... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class AbortPipelinesService
# NOTE: This call fails pipelines in bulk without running callbacks.
# Only for pipeline abandonment scenarios (examples: project delete)
def execute(pipelines, failure_reason)
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::AbortPipelinesService, feature_category: :continuous_integration do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, namespace: user.namespace) }
let_it_be(:cancelable_pipeline, reload: true) { create(:ci_pipeline, ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
class CompareAccessibilityReportsService < CompareReportsBaseService
def comparer_class
Gitlab::Ci::Reports::AccessibilityReportsComparer
end
def serializer_class
AccessibilityReportsComparerSerial... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::CompareAccessibilityReportsService, feature_category: :continuous_integration do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
describe '#execute' do
subject { service.execute(base_pipeli... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module JobTokenScope
class AddProjectService < ::BaseService
include EditScopeValidations
def execute(target_project, direction: :inbound)
validate_edit!(project, target_project, current_user)
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::JobTokenScope::AddProjectService, feature_category: :continuous_integration do
let(:service) { described_class.new(project, current_user) }
let_it_be(:project) { create(:project, ci_outbound_job_token_scope_enabled: true).tap(&:save!) }
let_... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module JobTokenScope
class RemoveProjectService < ::BaseService
include EditScopeValidations
def execute(target_project, direction)
validate_edit!(project, target_project, current_user)
if... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::JobTokenScope::RemoveProjectService, feature_category: :continuous_integration do
let(:service) { described_class.new(project, current_user) }
let_it_be(:project) { create(:project, ci_outbound_job_token_scope_enabled: true).tap(&:save!) }
l... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module StuckBuilds
class DropScheduledService
include DropHelpers
BUILD_SCHEDULED_OUTDATED_TIMEOUT = 1.hour
def execute
Gitlab::AppLogger.info "#{self.class}: Cleaning scheduled, timed-out b... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::StuckBuilds::DropScheduledService, feature_category: :runner_fleet do
let_it_be(:runner) { create :ci_runner }
let!(:job) { create :ci_build, :scheduled, scheduled_at: scheduled_at, runner: runner }
subject(:service) { described_class.new ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module StuckBuilds
class DropPendingService
include DropHelpers
BUILD_PENDING_OUTDATED_TIMEOUT = 1.day
BUILD_PENDING_STUCK_TIMEOUT = 1.hour
def execute
Gitlab::AppLogger.info "#{self.c... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::StuckBuilds::DropPendingService, feature_category: :runner_fleet do
let_it_be(:runner) { create(:ci_runner) }
let_it_be(:pipeline) { create(:ci_empty_pipeline) }
let_it_be_with_reload(:job) do
create(:ci_build, pipeline: pipeline, runner... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module StuckBuilds
class DropRunningService
include DropHelpers
BUILD_RUNNING_OUTDATED_TIMEOUT = 1.hour
def execute
Gitlab::AppLogger.info "#{self.class}: Cleaning running, timed-out builds"... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::StuckBuilds::DropRunningService, feature_category: :runner_fleet do
let!(:runner) { create :ci_runner }
let!(:job) { create(:ci_build, runner: runner, created_at: created_at, updated_at: updated_at, status: status) }
subject(:service) { des... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module ResourceGroups
class AssignResourceFromResourceGroupService < ::BaseService
# rubocop: disable CodeReuse/ActiveRecord
def execute(resource_group)
release_resource_from_stale_jobs(resource_gro... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ResourceGroups::AssignResourceFromResourceGroupService, feature_category: :continuous_integration do
include ConcurrentHelpers
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let(:service) { described_class.ne... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module PipelineProcessing
class AtomicProcessingService
include Gitlab::Utils::StrongMemoize
include ExclusiveLeaseGuard
attr_reader :pipeline
DEFAULT_LEASE_TIMEOUT = 1.minute
BATCH_SIZE... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineProcessing::AtomicProcessingService, feature_category: :continuous_integration do
include RepoHelpers
include ExclusiveLeaseHelpers
describe 'Pipeline Processing Service Tests With Yaml' do
let_it_be(:project) { create(:project,... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module PipelineProcessing
class AtomicProcessingService
class StatusCollection
include Gitlab::Utils::StrongMemoize
attr_reader :pipeline
def initialize(pipeline)
@pipeline = p... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineProcessing::AtomicProcessingService::StatusCollection,
feature_category: :continuous_integration do
using RSpec::Parameterized::TableSyntax
let_it_be(:pipeline) { create(:ci_pipeline) }
let_it_be(:build_stage) { create(:ci_stage, ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Catalog
module Resources
class ValidateService
MINIMUM_AMOUNT_OF_COMPONENTS = 1
def initialize(project, ref)
@project = project
@ref = ref
@errors = []
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::ValidateService, feature_category: :pipeline_composition do
describe '#execute' do
context 'when a project has a README, a description, and at least one component' do
it 'is valid' do
project = create(:proje... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Catalog
module Resources
class ReleaseService
def initialize(release)
@release = release
@project = release.project
@errors = []
end
def execute
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::ReleaseService, feature_category: :pipeline_composition do
describe '#execute' do
context 'with a valid catalog resource and release' do
it 'validates the catalog resource and creates a version' do
project =... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Catalog
module Resources
class DestroyService
include Gitlab::Allowable
attr_reader :project, :current_user
def initialize(project, user)
@current_user = user
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::DestroyService, feature_category: :pipeline_composition do
let_it_be(:project) { create(:project, :catalog_resource_with_components) }
let_it_be(:catalog_resource) { create(:ci_catalog_resource, project: project) }
let_it... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Catalog
module Resources
class CreateService
include Gitlab::Allowable
attr_reader :project, :current_user
def initialize(project, user)
@current_user = user
@... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::CreateService, feature_category: :pipeline_composition do
let_it_be(:project) { create(:project, :catalog_resource_with_components) }
let_it_be(:user) { create(:user) }
let(:service) { described_class.new(project, user) ... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Catalog
module Resources
module Versions
class CreateService
def initialize(release)
@project = release.project
@release = release
@errors = []
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::Versions::CreateService, feature_category: :pipeline_composition do
describe '#execute' do
let(:files) do
{
'templates/secret-detection.yml' => "spec:\n inputs:\n website:\n---\nimage: alpine_1",
't... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Pipelines
class AddJobService
include ::Gitlab::ExclusiveLeaseHelpers
attr_reader :pipeline
def initialize(pipeline)
@pipeline = pipeline
raise ArgumentError, "Pipeline must ... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Pipelines::AddJobService, feature_category: :continuous_integration do
include ExclusiveLeaseHelpers
let_it_be_with_reload(:pipeline) { create(:ci_pipeline) }
let(:job) { build(:ci_build) }
subject(:service) { described_class.new(pipeli... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Pipelines
class HookService
include Gitlab::Utils::StrongMemoize
HOOK_NAME = :pipeline_hooks
def initialize(pipeline)
@pipeline = pipeline
end
def execute
project... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Pipelines::HookService, feature_category: :continuous_integration do
describe '#execute_hooks' do
let_it_be(:namespace) { create(:namespace) }
let_it_be(:project) { create(:project, :repository, namespace: namespace) }
let_it_be(:pip... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module Pipelines
class UpdateMetadataService
def initialize(pipeline, params)
@pipeline = pipeline
@params = params
end
def execute
metadata = pipeline.pipeline_metadata
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Pipelines::UpdateMetadataService, feature_category: :continuous_integration do
subject(:execute) { described_class.new(pipeline, { name: name }).execute }
let(:name) { 'Some random pipeline name' }
context 'when pipeline has no name' do
... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module PipelineArtifacts
class CreateCodeQualityMrDiffReportService
include Gitlab::Utils::StrongMemoize
def initialize(pipeline)
@pipeline = pipeline
end
def execute
return unl... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService, feature_category: :build_artifacts do
describe '#execute' do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
let(:head_pipeline) { crea... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module PipelineArtifacts
class CoverageReportService
include Gitlab::Utils::StrongMemoize
def initialize(pipeline)
@pipeline = pipeline
end
def execute
return if report.empty?
... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineArtifacts::CoverageReportService, feature_category: :build_artifacts do
describe '#execute' do
let_it_be(:project) { create(:project, :repository) }
subject { described_class.new(pipeline).execute }
shared_examples 'creatin... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
module Ci
module PipelineArtifacts
class DestroyAllExpiredService
include ::Gitlab::ExclusiveLeaseHelpers
include ::Gitlab::LoopHelpers
include ::Gitlab::Utils::StrongMemoize
BATCH_SIZE = 100
LOOP_... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_shared_state,
feature_category: :build_artifacts do
let(:service) { described_class.new }
describe '.execute' do
subject { service.execute }
context 'when timeout hap... |
Write RSpec test file for following ruby class
```ruby
# frozen_string_literal: true
# This service is responsible for creating a pipeline for a given
# ExternalPullRequest coming from other providers such as GitHub.
module Ci
module ExternalPullRequests
class CreatePipelineService < BaseService
def execu... | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ExternalPullRequests::CreatePipelineService, feature_category: :continuous_integration do
describe '#execute' do
let_it_be(:project) { create(:project, :auto_devops, :repository) }
let_it_be(:user) { create(:user) }
let_it_be_with_re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.