summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 15:09:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-14 15:09:44 +0000
commit874ead9c3a50de4c4ca4551eaf5b7eb976d26b50 (patch)
tree637ee9f2da5e251bc08ebf3e972209d51966bf7c /spec/models
parent2e4c4055181eec9186458dd5dd3219c937032ec7 (diff)
downloadgitlab-ce-874ead9c3a50de4c4ca4551eaf5b7eb976d26b50.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/job_artifact_spec.rb21
-rw-r--r--spec/models/diff_note_position_spec.rb22
2 files changed, 35 insertions, 8 deletions
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb
index 6f6ff3704b4..80b619ed2b1 100644
--- a/spec/models/ci/job_artifact_spec.rb
+++ b/spec/models/ci/job_artifact_spec.rb
@@ -349,16 +349,13 @@ describe Ci::JobArtifact do
end
describe 'file is being stored' do
- subject { create(:ci_job_artifact, :archive) }
-
context 'when object has nil store' do
- before do
- subject.update_column(:file_store, nil)
- subject.reload
- end
-
it 'is stored locally' do
- expect(subject.file_store).to be(nil)
+ subject = build(:ci_job_artifact, :archive, file_store: nil)
+
+ subject.save
+
+ expect(subject.file_store).to be(ObjectStorage::Store::LOCAL)
expect(subject.file).to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::LOCAL)
end
@@ -366,6 +363,10 @@ describe Ci::JobArtifact do
context 'when existing object has local store' do
it 'is stored locally' do
+ subject = build(:ci_job_artifact, :archive)
+
+ subject.save
+
expect(subject.file_store).to be(ObjectStorage::Store::LOCAL)
expect(subject.file).to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::LOCAL)
@@ -379,6 +380,10 @@ describe Ci::JobArtifact do
context 'when file is stored' do
it 'is stored remotely' do
+ subject = build(:ci_job_artifact, :archive)
+
+ subject.save
+
expect(subject.file_store).to eq(ObjectStorage::Store::REMOTE)
expect(subject.file).not_to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::REMOTE)
diff --git a/spec/models/diff_note_position_spec.rb b/spec/models/diff_note_position_spec.rb
new file mode 100644
index 00000000000..a00ba35feef
--- /dev/null
+++ b/spec/models/diff_note_position_spec.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe DiffNotePosition, type: :model do
+ it 'has a position attribute' do
+ diff_position = build(:diff_position)
+ line_code = 'bd4b7bfff3a247ccf6e3371c41ec018a55230bcc_534_521'
+ diff_note_position = build(:diff_note_position, line_code: line_code, position: diff_position)
+
+ expect(diff_note_position.position).to eq(diff_position)
+ expect(diff_note_position.line_code).to eq(line_code)
+ expect(diff_note_position.diff_content_type).to eq('text')
+ end
+
+ it 'unique by note_id and diff type' do
+ existing_diff_note_position = create(:diff_note_position)
+ diff_note_position = build(:diff_note_position, note: existing_diff_note_position.note)
+
+ expect { diff_note_position.save! }.to raise_error(ActiveRecord::RecordNotUnique)
+ end
+end