diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 21:08:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 21:08:58 +0300 |
commit | 1ca9950d5f890cd8f185e1eda158b969a7244fe2 (patch) | |
tree | 6f62715938a4b2b001705c51c697609a8e0850ae /spec/workers | |
parent | bcc77054ee9aefd1e332e04a4189390fd5a3112e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
4 files changed, 43 insertions, 35 deletions
diff --git a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb index 10c23cbb6d4..736acc40371 100644 --- a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb +++ b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb @@ -12,7 +12,7 @@ describe PagesDomainSslRenewalCronWorker do end describe '#perform' do - let(:project) { create :project } + let_it_be(:project) { create :project } let!(:domain) { create(:pages_domain, project: project, auto_ssl_enabled: false) } let!(:domain_with_enabled_auto_ssl) { create(:pages_domain, project: project, auto_ssl_enabled: true) } let!(:domain_with_obtained_letsencrypt) do @@ -35,12 +35,16 @@ describe PagesDomainSslRenewalCronWorker do [domain, domain_with_obtained_letsencrypt].each do |domain| - expect(PagesDomainVerificationWorker).not_to receive(:perform_async).with(domain.id) + expect(PagesDomainSslRenewalWorker).not_to receive(:perform_async).with(domain.id) end worker.perform end + it_behaves_like 'a pages cronjob scheduling jobs with context', PagesDomainSslRenewalWorker do + let(:extra_domain) { create(:pages_domain, :with_project, auto_ssl_enabled: true) } + end + shared_examples 'does nothing' do it 'does nothing' do expect(PagesDomainSslRenewalWorker).not_to receive(:perform_async) diff --git a/spec/workers/pages_domain_verification_cron_worker_spec.rb b/spec/workers/pages_domain_verification_cron_worker_spec.rb index 3fb86adee11..6dd6c33f5fe 100644 --- a/spec/workers/pages_domain_verification_cron_worker_spec.rb +++ b/spec/workers/pages_domain_verification_cron_worker_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' describe PagesDomainVerificationCronWorker do subject(:worker) { described_class.new } - describe '#perform' do + describe '#perform', :sidekiq do let!(:verified) { create(:pages_domain) } - let!(:reverify) { create(:pages_domain, :reverify) } + let!(:reverify) { create(:pages_domain, :reverify, :with_project) } let!(:disabled) { create(:pages_domain, :disabled) } it 'does nothing if the database is read-only' do @@ -26,5 +26,9 @@ describe PagesDomainVerificationCronWorker do worker.perform end + + it_behaves_like 'a pages cronjob scheduling jobs with context', PagesDomainVerificationWorker do + let(:extra_domain) { create(:pages_domain, :reverify, :with_project) } + end end end diff --git a/spec/workers/propagate_instance_level_service_worker_spec.rb b/spec/workers/propagate_instance_level_service_worker_spec.rb deleted file mode 100644 index 6552b198181..00000000000 --- a/spec/workers/propagate_instance_level_service_worker_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe PropagateInstanceLevelServiceWorker do - include ExclusiveLeaseHelpers - - describe '#perform' do - it 'calls the propagate service with the instance level service' do - instance_level_service = PushoverService.create( - instance: true, - active: true, - properties: { - device: 'MyDevice', - sound: 'mic', - priority: 4, - user_key: 'asdf', - api_key: '123456789' - }) - - stub_exclusive_lease("propagate_instance_level_service_worker:#{instance_level_service.id}", - timeout: PropagateInstanceLevelServiceWorker::LEASE_TIMEOUT) - - expect(Projects::PropagateInstanceLevelService) - .to receive(:propagate) - .with(instance_level_service) - - subject.perform(instance_level_service.id) - end - end -end diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb new file mode 100644 index 00000000000..fb4ced77832 --- /dev/null +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe PropagateServiceTemplateWorker do + include ExclusiveLeaseHelpers + + describe '#perform' do + it 'calls the propagate service with the template' do + template = PushoverService.create( + template: true, + active: true, + properties: { + device: 'MyDevice', + sound: 'mic', + priority: 4, + user_key: 'asdf', + api_key: '123456789' + }) + + stub_exclusive_lease("propagate_service_template_worker:#{template.id}", + timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT) + + expect(Projects::PropagateServiceTemplate) + .to receive(:propagate) + .with(template) + + subject.perform(template.id) + end + end +end |