diff options
Diffstat (limited to 'spec/services/jira_connect_subscriptions/create_service_spec.rb')
-rw-r--r-- | spec/services/jira_connect_subscriptions/create_service_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/jira_connect_subscriptions/create_service_spec.rb b/spec/services/jira_connect_subscriptions/create_service_spec.rb index 77e758cf6fe..9750c671fa2 100644 --- a/spec/services/jira_connect_subscriptions/create_service_spec.rb +++ b/spec/services/jira_connect_subscriptions/create_service_spec.rb @@ -32,6 +32,36 @@ RSpec.describe JiraConnectSubscriptions::CreateService do it 'returns success' do expect(subject[:status]).to eq(:success) end + + context 'namespace has projects' do + let!(:project_1) { create(:project, group: group) } + let!(:project_2) { create(:project, group: group) } + + before do + stub_const("#{described_class}::MERGE_REQUEST_SYNC_BATCH_SIZE", 1) + end + + it 'starts workers to sync projects in batches with delay' do + allow(Atlassian::JiraConnect::Client).to receive(:generate_update_sequence_id).and_return(123) + + expect(JiraConnect::SyncProjectWorker).to receive(:bulk_perform_in).with(1.minute, [[project_1.id, 123]]) + expect(JiraConnect::SyncProjectWorker).to receive(:bulk_perform_in).with(2.minutes, [[project_2.id, 123]]) + + subject + end + + context 'when the jira_connect_full_namespace_sync feature flag is disabled' do + before do + stub_feature_flags(jira_connect_full_namespace_sync: false) + end + + specify do + expect(JiraConnect::SyncProjectWorker).not_to receive(:bulk_perform_in_with_contexts) + + subject + end + end + end end context 'when path is invalid' do |