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>2020-03-13 03:09:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 03:09:34 +0300
commit3cd08f4bf96cda3e9d3abf233095107832b17c20 (patch)
treedc09a618783a79d70f2a404374d4b850ccf9cc84 /spec/models
parentdd4bee69b7d55620f7dc9db8c36b478bd4959755 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_services/jira_service_spec.rb21
-rw-r--r--spec/models/upload_spec.rb30
-rw-r--r--spec/models/x509_certificate_spec.rb22
3 files changed, 73 insertions, 0 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index c1e7a1c2875..32e6b5afce5 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -440,6 +440,27 @@ describe JiraService do
end
end
+ context 'when Remote Link already exists' do
+ let(:remote_link) do
+ double(
+ 'remote link',
+ object: {
+ url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/-/commit/#{commit_id}"
+ }.with_indifferent_access
+ )
+ end
+
+ it 'does not create comment' do
+ allow(JIRA::Resource::Remotelink).to receive(:all).and_return([remote_link])
+
+ expect(remote_link).to receive(:save!)
+
+ @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+
+ expect(WebMock).not_to have_requested(:post, @comment_url)
+ end
+ end
+
it 'does not send comment or remote links to issues already closed' do
allow_any_instance_of(JIRA::Resource::Issue).to receive(:resolution).and_return(true)
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index 7138305d7b1..8a64948d570 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -127,6 +127,36 @@ describe Upload do
expect(uploader.mounted_as).to eq(subject.send(:mount_point))
expect(uploader.file).not_to be_nil
end
+
+ context 'when upload has mount_point nil' do
+ context 'when an upload belongs to a note' do
+ it 'mounts it as attachment' do
+ project = create(:project, :legacy_storage)
+ merge_request = create(:merge_request, source_project: project)
+ note = create(:legacy_diff_note_on_merge_request, note: 'some note', project: project, noteable: merge_request)
+
+ subject = build(:upload, :with_file, :attachment_upload, model: note, mount_point: nil)
+ uploader = subject.retrieve_uploader
+
+ expect(uploader.upload).to eq(subject)
+ expect(uploader.path).to include('attachment')
+ expect(uploader.file).not_to be_nil
+ end
+ end
+
+ context 'when an upload does not belong to a note' do
+ it 'does not mount it as attachment' do
+ appearance = create(:appearance)
+
+ subject = build(:upload, :with_file, :attachment_upload, model: appearance, mount_point: nil)
+ uploader = subject.retrieve_uploader
+
+ expect(uploader.upload).to eq(subject)
+ expect(uploader.path).not_to include('attachment')
+ expect(uploader.file).not_to be_nil
+ end
+ end
+ end
end
describe '#needs_checksum?' do
diff --git a/spec/models/x509_certificate_spec.rb b/spec/models/x509_certificate_spec.rb
index 187d37334a1..880c5014a84 100644
--- a/spec/models/x509_certificate_spec.rb
+++ b/spec/models/x509_certificate_spec.rb
@@ -43,6 +43,28 @@ RSpec.describe X509Certificate do
expect(certificate.subject).to eq(subject)
expect(certificate.email).to eq(email)
end
+
+ it 'calls mark_commit_signatures_unverified' do
+ expect_any_instance_of(described_class).to receive(:mark_commit_signatures_unverified)
+
+ described_class.safe_create!(attributes)
+ end
+
+ context 'certificate revocation handling' do
+ let(:x509_certificate) { create(:x509_certificate) }
+
+ it 'starts a revoke worker if certificate is revoked' do
+ expect(X509CertificateRevokeWorker).to receive(:perform_async).with(x509_certificate.id)
+
+ x509_certificate.revoked!
+ end
+
+ it 'does not starts a revoke worker for good certificates' do
+ expect(X509CertificateRevokeWorker).not_to receive(:perform_async).with(x509_certificate.id)
+
+ x509_certificate
+ end
+ end
end
describe 'validators' do