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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-17 21:09:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-17 21:09:13 +0300
commit5150ecc452f4cf1c899f79d35d52af978ff2d43f (patch)
treeed36b7982b574d6b4ec5b4e3f68a61a0f7e762d1 /spec/models
parent3884d9d7160e80a70ad327813ada6cab03cded65 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb18
-rw-r--r--spec/models/concerns/token_authenticatable_spec.rb100
-rw-r--r--spec/models/hooks/web_hook_spec.rb4
3 files changed, 40 insertions, 82 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index d854943e277..751a303739c 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -2983,6 +2983,24 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let_it_be(:pipeline) { create(:ci_empty_pipeline, :created) }
+ it 'logs the event' do
+ allow(Gitlab::AppJsonLogger).to receive(:info)
+
+ pipeline.cancel_running
+
+ expect(Gitlab::AppJsonLogger)
+ .to have_received(:info)
+ .with(
+ a_hash_including(
+ event: 'pipeline_cancel_running',
+ pipeline_id: pipeline.id,
+ auto_canceled_by_pipeline_id: nil,
+ cascade_to_children: true,
+ execute_async: true
+ )
+ )
+ end
+
context 'when there is a running external job and a regular job' do
before do
create(:ci_build, :running, pipeline: pipeline)
diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb
index 3f6bbe795cc..e8db83b7144 100644
--- a/spec/models/concerns/token_authenticatable_spec.rb
+++ b/spec/models/concerns/token_authenticatable_spec.rb
@@ -314,52 +314,22 @@ RSpec.describe Ci::Runner, 'TokenAuthenticatable', :freeze_time do
describe '#token_expired?' do
subject { runner.token_expired? }
- context 'when enforce_runner_token_expires_at feature flag is disabled' do
- before do
- stub_feature_flags(enforce_runner_token_expires_at: false)
- end
-
- context 'when runner has no token expiration' do
- let(:runner) { non_expirable_runner }
-
- it { is_expected.to eq(false) }
- end
-
- context 'when runner token is not expired' do
- let(:runner) { non_expired_runner }
+ context 'when runner has no token expiration' do
+ let(:runner) { non_expirable_runner }
- it { is_expected.to eq(false) }
- end
-
- context 'when runner token is expired' do
- let(:runner) { expired_runner }
-
- it { is_expected.to eq(false) }
- end
+ it { is_expected.to eq(false) }
end
- context 'when enforce_runner_token_expires_at feature flag is enabled' do
- before do
- stub_feature_flags(enforce_runner_token_expires_at: true)
- end
-
- context 'when runner has no token expiration' do
- let(:runner) { non_expirable_runner }
-
- it { is_expected.to eq(false) }
- end
+ context 'when runner token is not expired' do
+ let(:runner) { non_expired_runner }
- context 'when runner token is not expired' do
- let(:runner) { non_expired_runner }
-
- it { is_expected.to eq(false) }
- end
+ it { is_expected.to eq(false) }
+ end
- context 'when runner token is expired' do
- let(:runner) { expired_runner }
+ context 'when runner token is expired' do
+ let(:runner) { expired_runner }
- it { is_expected.to eq(true) }
- end
+ it { is_expected.to eq(true) }
end
end
@@ -386,52 +356,22 @@ RSpec.describe Ci::Runner, 'TokenAuthenticatable', :freeze_time do
describe '.find_by_token' do
subject { Ci::Runner.find_by_token(runner.token) }
- context 'when enforce_runner_token_expires_at feature flag is disabled' do
- before do
- stub_feature_flags(enforce_runner_token_expires_at: false)
- end
-
- context 'when runner has no token expiration' do
- let(:runner) { non_expirable_runner }
-
- it { is_expected.to eq(non_expirable_runner) }
- end
-
- context 'when runner token is not expired' do
- let(:runner) { non_expired_runner }
-
- it { is_expected.to eq(non_expired_runner) }
- end
-
- context 'when runner token is expired' do
- let(:runner) { expired_runner }
+ context 'when runner has no token expiration' do
+ let(:runner) { non_expirable_runner }
- it { is_expected.to eq(expired_runner) }
- end
+ it { is_expected.to eq(non_expirable_runner) }
end
- context 'when enforce_runner_token_expires_at feature flag is enabled' do
- before do
- stub_feature_flags(enforce_runner_token_expires_at: true)
- end
-
- context 'when runner has no token expiration' do
- let(:runner) { non_expirable_runner }
-
- it { is_expected.to eq(non_expirable_runner) }
- end
-
- context 'when runner token is not expired' do
- let(:runner) { non_expired_runner }
+ context 'when runner token is not expired' do
+ let(:runner) { non_expired_runner }
- it { is_expected.to eq(non_expired_runner) }
- end
+ it { is_expected.to eq(non_expired_runner) }
+ end
- context 'when runner token is expired' do
- let(:runner) { expired_runner }
+ context 'when runner token is expired' do
+ let(:runner) { expired_runner }
- it { is_expected.to be_nil }
- end
+ it { is_expected.to be_nil }
end
end
end
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index 93c47422f37..6419a9fc9d9 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -316,7 +316,7 @@ RSpec.describe WebHook do
end
it 'is twice the initial value' do
- expect(hook.next_backoff).to eq(20.minutes)
+ expect(hook.next_backoff).to eq(2 * described_class::INITIAL_BACKOFF)
end
end
@@ -326,7 +326,7 @@ RSpec.describe WebHook do
end
it 'grows exponentially' do
- expect(hook.next_backoff).to eq(80.minutes)
+ expect(hook.next_backoff).to eq(2 * 2 * 2 * described_class::INITIAL_BACKOFF)
end
end