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:
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/build_trace_entity_spec.rb63
-rw-r--r--spec/serializers/evidences/author_entity_spec.rb13
-rw-r--r--spec/serializers/evidences/evidence_entity_spec.rb14
-rw-r--r--spec/serializers/evidences/evidence_serializer_spec.rb9
-rw-r--r--spec/serializers/evidences/issue_entity_spec.rb2
-rw-r--r--spec/serializers/evidences/milestone_entity_spec.rb2
6 files changed, 88 insertions, 15 deletions
diff --git a/spec/serializers/build_trace_entity_spec.rb b/spec/serializers/build_trace_entity_spec.rb
new file mode 100644
index 00000000000..bafead04a51
--- /dev/null
+++ b/spec/serializers/build_trace_entity_spec.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BuildTraceEntity do
+ let(:build) { build_stubbed(:ci_build) }
+ let(:request) { double('request') }
+
+ let(:stream) do
+ Gitlab::Ci::Trace::Stream.new do
+ StringIO.new('the-trace')
+ end
+ end
+
+ let(:build_trace) do
+ Ci::BuildTrace.new(build: build, stream: stream, content_format: content_format, state: nil)
+ end
+
+ let(:entity) do
+ described_class.new(build_trace, request: request)
+ end
+
+ subject { entity.as_json }
+
+ shared_examples 'includes build and trace metadata' do
+ it 'includes build attributes' do
+ expect(subject[:id]).to eq(build.id)
+ expect(subject[:status]).to eq(build.status)
+ expect(subject[:complete]).to eq(build.complete?)
+ end
+
+ it 'includes trace metadata' do
+ expect(subject).to include(:state)
+ expect(subject).to include(:append)
+ expect(subject).to include(:truncated)
+ expect(subject).to include(:offset)
+ expect(subject).to include(:size)
+ expect(subject).to include(:total)
+ end
+ end
+
+ context 'when content format is :json' do
+ let(:content_format) { :json }
+
+ it_behaves_like 'includes build and trace metadata'
+
+ it 'includes the trace content in json' do
+ expect(subject[:lines]).to eq([
+ { offset: 0, content: [{ text: 'the-trace' }] }
+ ])
+ end
+ end
+
+ context 'when content format is :html' do
+ let(:content_format) { :html }
+
+ it_behaves_like 'includes build and trace metadata'
+
+ it 'includes the trace content in json' do
+ expect(subject[:html]).to eq('<span>the-trace</span>')
+ end
+ end
+end
diff --git a/spec/serializers/evidences/author_entity_spec.rb b/spec/serializers/evidences/author_entity_spec.rb
deleted file mode 100644
index 1d0fa95217c..00000000000
--- a/spec/serializers/evidences/author_entity_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Evidences::AuthorEntity do
- let(:entity) { described_class.new(build(:author)) }
-
- subject { entity.as_json }
-
- it 'exposes the expected fields' do
- expect(subject.keys).to contain_exactly(:id, :name, :email)
- end
-end
diff --git a/spec/serializers/evidences/evidence_entity_spec.rb b/spec/serializers/evidences/evidence_entity_spec.rb
new file mode 100644
index 00000000000..531708e3be6
--- /dev/null
+++ b/spec/serializers/evidences/evidence_entity_spec.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::EvidenceEntity do
+ let(:evidence) { build(:evidence) }
+ let(:entity) { described_class.new(evidence) }
+
+ subject { entity.as_json }
+
+ it 'exposes the expected fields' do
+ expect(subject.keys).to contain_exactly(:release)
+ end
+end
diff --git a/spec/serializers/evidences/evidence_serializer_spec.rb b/spec/serializers/evidences/evidence_serializer_spec.rb
new file mode 100644
index 00000000000..5322f6a43fc
--- /dev/null
+++ b/spec/serializers/evidences/evidence_serializer_spec.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::EvidenceSerializer do
+ it 'represents an EvidenceEntity entity' do
+ expect(described_class.entity_class).to eq(Evidences::EvidenceEntity)
+ end
+end
diff --git a/spec/serializers/evidences/issue_entity_spec.rb b/spec/serializers/evidences/issue_entity_spec.rb
index a1402808757..915df986887 100644
--- a/spec/serializers/evidences/issue_entity_spec.rb
+++ b/spec/serializers/evidences/issue_entity_spec.rb
@@ -8,6 +8,6 @@ describe Evidences::IssueEntity do
subject { entity.as_json }
it 'exposes the expected fields' do
- expect(subject.keys).to contain_exactly(:id, :title, :description, :author, :state, :iid, :confidential, :created_at, :due_date)
+ expect(subject.keys).to contain_exactly(:id, :title, :description, :state, :iid, :confidential, :created_at, :due_date)
end
end
diff --git a/spec/serializers/evidences/milestone_entity_spec.rb b/spec/serializers/evidences/milestone_entity_spec.rb
index 082e178618e..68eb12093da 100644
--- a/spec/serializers/evidences/milestone_entity_spec.rb
+++ b/spec/serializers/evidences/milestone_entity_spec.rb
@@ -12,7 +12,7 @@ describe Evidences::MilestoneEntity do
expect(subject.keys).to contain_exactly(:id, :title, :description, :state, :iid, :created_at, :due_date, :issues)
end
- context 'when there issues linked to this milestone' do
+ context 'when there are issues linked to this milestone' do
let(:issue_1) { build(:issue) }
let(:issue_2) { build(:issue) }
let(:milestone) { build(:milestone, issues: [issue_1, issue_2]) }