diff options
Diffstat (limited to 'spec/services/projects/update_service_spec.rb')
-rw-r--r-- | spec/services/projects/update_service_spec.rb | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index 6620ee6e697..4a613f42556 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -396,6 +396,50 @@ RSpec.describe Projects::UpdateService do end end + shared_examples 'updating pages configuration' do + it 'schedules the `PagesUpdateConfigurationWorker` when pages are deployed' do + project.mark_pages_as_deployed + + expect(PagesUpdateConfigurationWorker).to receive(:perform_async).with(project.id) + + subject + end + + it "does not schedule a job when pages aren't deployed" do + project.mark_pages_as_not_deployed + + expect(PagesUpdateConfigurationWorker).not_to receive(:perform_async).with(project.id) + + subject + end + + context 'when `async_update_pages_config` is disabled' do + before do + stub_feature_flags(async_update_pages_config: false) + end + + it 'calls Projects::UpdatePagesConfigurationService when pages are deployed' do + project.mark_pages_as_deployed + + expect(Projects::UpdatePagesConfigurationService) + .to receive(:new) + .with(project) + .and_call_original + + subject + end + + it "does not update pages config when pages aren't deployed" do + project.mark_pages_as_not_deployed + + expect(Projects::UpdatePagesConfigurationService) + .not_to receive(:new) + + subject + end + end + end + context 'when updating #pages_https_only', :https_pages_enabled do subject(:call_service) do update_project(project, admin, pages_https_only: false) @@ -407,14 +451,7 @@ RSpec.describe Projects::UpdateService do .to(false) end - it 'calls Projects::UpdatePagesConfigurationService' do - expect(Projects::UpdatePagesConfigurationService) - .to receive(:new) - .with(project) - .and_call_original - - call_service - end + it_behaves_like 'updating pages configuration' end context 'when updating #pages_access_level' do @@ -428,14 +465,7 @@ RSpec.describe Projects::UpdateService do .to(ProjectFeature::ENABLED) end - it 'calls Projects::UpdatePagesConfigurationService' do - expect(Projects::UpdatePagesConfigurationService) - .to receive(:new) - .with(project) - .and_call_original - - call_service - end + it_behaves_like 'updating pages configuration' end context 'when updating #emails_disabled' do |