Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/ci/enqueue_job_service_spec.rb')
-rw-r--r--spec/services/ci/enqueue_job_service_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/services/ci/enqueue_job_service_spec.rb b/spec/services/ci/enqueue_job_service_spec.rb
index c2bb0bb2bb5..85983651148 100644
--- a/spec/services/ci/enqueue_job_service_spec.rb
+++ b/spec/services/ci/enqueue_job_service_spec.rb
@@ -78,4 +78,33 @@ RSpec.describe Ci::EnqueueJobService, '#execute', feature_category: :continuous_
execute
end
end
+
+ context 'when the job is manually triggered another user' do
+ let(:job_variables) do
+ [{ key: 'third', secret_value: 'third' },
+ { key: 'fourth', secret_value: 'fourth' }]
+ end
+
+ let(:service) do
+ described_class.new(build, current_user: user, variables: job_variables)
+ end
+
+ it 'assigns the user and variables to the job', :aggregate_failures do
+ called = false
+ service.execute do
+ unless called
+ called = true
+ raise ActiveRecord::StaleObjectError
+ end
+
+ build.enqueue!
+ end
+
+ build.reload
+
+ expect(called).to be true # ensure we actually entered the failure path
+ expect(build.user).to eq(user)
+ expect(build.job_variables.map(&:key)).to contain_exactly('third', 'fourth')
+ end
+ end
end