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>2019-10-01 18:06:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 18:06:05 +0300
commit05f4b2fb34dbb051b2ce5ddbc801ec42998c019c (patch)
tree0fd7a153f3ed7d00d40e428c08ab81ae3d863afe /spec/serializers
parent9e27f0d920cc3891fa7644c5cc0bc280c519fb20 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/evidences/author_entity_spec.rb13
-rw-r--r--spec/serializers/evidences/issue_entity_spec.rb13
-rw-r--r--spec/serializers/evidences/milestone_entity_spec.rb35
-rw-r--r--spec/serializers/evidences/project_entity_spec.rb13
-rw-r--r--spec/serializers/evidences/release_entity_spec.rb36
-rw-r--r--spec/serializers/evidences/release_serializer_spec.rb9
6 files changed, 119 insertions, 0 deletions
diff --git a/spec/serializers/evidences/author_entity_spec.rb b/spec/serializers/evidences/author_entity_spec.rb
new file mode 100644
index 00000000000..1d0fa95217c
--- /dev/null
+++ b/spec/serializers/evidences/author_entity_spec.rb
@@ -0,0 +1,13 @@
+# 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/issue_entity_spec.rb b/spec/serializers/evidences/issue_entity_spec.rb
new file mode 100644
index 00000000000..a1402808757
--- /dev/null
+++ b/spec/serializers/evidences/issue_entity_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::IssueEntity do
+ let(:entity) { described_class.new(build(:issue)) }
+
+ 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)
+ end
+end
diff --git a/spec/serializers/evidences/milestone_entity_spec.rb b/spec/serializers/evidences/milestone_entity_spec.rb
new file mode 100644
index 00000000000..082e178618e
--- /dev/null
+++ b/spec/serializers/evidences/milestone_entity_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::MilestoneEntity do
+ let(:milestone) { build(:milestone) }
+ let(:entity) { described_class.new(milestone) }
+
+ subject { entity.as_json }
+
+ it 'exposes the expected fields' 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
+ let(:issue_1) { build(:issue) }
+ let(:issue_2) { build(:issue) }
+ let(:milestone) { build(:milestone, issues: [issue_1, issue_2]) }
+
+ it 'exposes these issues' do
+ expect(subject[:issues]).to contain_exactly(
+ Evidences::IssueEntity.new(issue_1).as_json,
+ Evidences::IssueEntity.new(issue_2).as_json
+ )
+ end
+ end
+
+ context 'when the release has no milestone' do
+ let(:milestone) { build(:milestone, issues: []) }
+
+ it 'exposes an empty array for milestones' do
+ expect(subject[:issues]).to be_empty
+ end
+ end
+end
diff --git a/spec/serializers/evidences/project_entity_spec.rb b/spec/serializers/evidences/project_entity_spec.rb
new file mode 100644
index 00000000000..01c160425a8
--- /dev/null
+++ b/spec/serializers/evidences/project_entity_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::ProjectEntity do
+ let(:entity) { described_class.new(build(:project)) }
+
+ subject { entity.as_json }
+
+ it 'exposes the expected fields' do
+ expect(subject.keys).to contain_exactly(:id, :name, :description, :created_at)
+ end
+end
diff --git a/spec/serializers/evidences/release_entity_spec.rb b/spec/serializers/evidences/release_entity_spec.rb
new file mode 100644
index 00000000000..8e2be748169
--- /dev/null
+++ b/spec/serializers/evidences/release_entity_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::ReleaseEntity do
+ let(:release) { build(:release) }
+ let(:entity) { described_class.new(release) }
+
+ subject { entity.as_json }
+
+ it 'exposes the expected fields' do
+ expect(subject.keys).to contain_exactly(:id, :tag_name, :name, :description, :created_at, :project, :milestones)
+ end
+
+ context 'when the release has milestones' do
+ let(:project) { create(:project) }
+ let(:milestone_1) { build(:milestone, project: project) }
+ let(:milestone_2) { build(:milestone, project: project) }
+ let(:release) { build(:release, project: project, milestones: [milestone_1, milestone_2]) }
+
+ it 'exposes these milestones' do
+ expect(subject[:milestones]).to contain_exactly(
+ Evidences::MilestoneEntity.new(milestone_1).as_json,
+ Evidences::MilestoneEntity.new(milestone_2).as_json
+ )
+ end
+ end
+
+ context 'when the release has no milestone' do
+ let(:release) { build(:release, milestones: []) }
+
+ it 'exposes an empty array for milestones' do
+ expect(subject[:milestones]).to be_empty
+ end
+ end
+end
diff --git a/spec/serializers/evidences/release_serializer_spec.rb b/spec/serializers/evidences/release_serializer_spec.rb
new file mode 100644
index 00000000000..a0dbf50137c
--- /dev/null
+++ b/spec/serializers/evidences/release_serializer_spec.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Evidences::ReleaseSerializer do
+ it 'represents an Evidence::ReleaseEntity entity' do
+ expect(described_class.entity_class).to eq(Evidences::ReleaseEntity)
+ end
+end