diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 06:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 06:08:56 +0300 |
commit | 3ed6401d35e18e711dbcba55fc1399d689f6b7ea (patch) | |
tree | 0c7ddd549f48f7cb763f34a0ba1c7ba275364665 /spec/workers/jira_connect | |
parent | 5774fd89127bafc0e045a47b48d90ded94786418 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/jira_connect')
-rw-r--r-- | spec/workers/jira_connect/sync_branch_worker_spec.rb | 33 | ||||
-rw-r--r-- | spec/workers/jira_connect/sync_merge_request_worker_spec.rb | 33 |
2 files changed, 62 insertions, 4 deletions
diff --git a/spec/workers/jira_connect/sync_branch_worker_spec.rb b/spec/workers/jira_connect/sync_branch_worker_spec.rb index 2da3ea9d256..4aa2f89de7b 100644 --- a/spec/workers/jira_connect/sync_branch_worker_spec.rb +++ b/spec/workers/jira_connect/sync_branch_worker_spec.rb @@ -4,7 +4,10 @@ require 'spec_helper' RSpec.describe JiraConnect::SyncBranchWorker do describe '#perform' do - let_it_be(:project) { create(:project, :repository) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, :repository, group: group) } + let_it_be(:subscription) { create(:jira_connect_subscription, installation: create(:jira_connect_installation), namespace: group) } + let(:project_id) { project.id } let(:branch_name) { 'master' } let(:commit_shas) { %w(b83d6e3 5a62481) } @@ -13,7 +16,7 @@ RSpec.describe JiraConnect::SyncBranchWorker do def expect_jira_sync_service_execute(args) expect_next_instance_of(JiraConnect::SyncService) do |instance| - expect(instance).to receive(:execute).with(args) + expect(instance).to receive(:execute).with(args.merge(update_sequence_id: nil)) end end @@ -61,5 +64,31 @@ RSpec.describe JiraConnect::SyncBranchWorker do subject end end + + context 'with update_sequence_id' do + let(:update_sequence_id) { 1 } + let(:request_url) { 'https://sample.atlassian.net/rest/devinfo/0.10/bulk' } + let(:request_body) do + { + repositories: [ + Atlassian::JiraConnect::Serializers::RepositoryEntity.represent( + project, + commits: project.commits_by(oids: commit_shas), + branches: [project.repository.find_branch(branch_name)], + update_sequence_id: update_sequence_id + ) + ] + }.to_json + end + + subject { described_class.new.perform(project_id, branch_name, commit_shas, update_sequence_id) } + + it 'sends the reqeust with custom update_sequence_id' do + expect(Atlassian::JiraConnect::Client).to receive(:post) + .with(URI(request_url), headers: anything, body: request_body) + + subject + end + end end end diff --git a/spec/workers/jira_connect/sync_merge_request_worker_spec.rb b/spec/workers/jira_connect/sync_merge_request_worker_spec.rb index 764201e750a..b3c0db4f260 100644 --- a/spec/workers/jira_connect/sync_merge_request_worker_spec.rb +++ b/spec/workers/jira_connect/sync_merge_request_worker_spec.rb @@ -4,14 +4,18 @@ require 'spec_helper' RSpec.describe JiraConnect::SyncMergeRequestWorker do describe '#perform' do - let(:merge_request) { create(:merge_request) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, :repository, group: group) } + let_it_be(:subscription) { create(:jira_connect_subscription, installation: create(:jira_connect_installation), namespace: group) } + let_it_be(:merge_request) { create(:merge_request, source_project: project) } + let(:merge_request_id) { merge_request.id } subject { described_class.new.perform(merge_request_id) } it 'calls JiraConnect::SyncService#execute' do expect_next_instance_of(JiraConnect::SyncService) do |service| - expect(service).to receive(:execute).with(merge_requests: [merge_request]) + expect(service).to receive(:execute).with(merge_requests: [merge_request], update_sequence_id: nil) end subject @@ -26,5 +30,30 @@ RSpec.describe JiraConnect::SyncMergeRequestWorker do subject end end + + context 'with update_sequence_id' do + let(:update_sequence_id) { 1 } + let(:request_url) { 'https://sample.atlassian.net/rest/devinfo/0.10/bulk' } + let(:request_body) do + { + repositories: [ + Atlassian::JiraConnect::Serializers::RepositoryEntity.represent( + project, + merge_requests: [merge_request], + update_sequence_id: update_sequence_id + ) + ] + }.to_json + end + + subject { described_class.new.perform(merge_request_id, update_sequence_id) } + + it 'sends the request with custom update_sequence_id' do + expect(Atlassian::JiraConnect::Client).to receive(:post) + .with(URI(request_url), headers: anything, body: request_body) + + subject + end + end end end |