diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/releases | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/releases')
-rw-r--r-- | spec/models/releases/evidence_spec.rb | 80 |
1 files changed, 9 insertions, 71 deletions
diff --git a/spec/models/releases/evidence_spec.rb b/spec/models/releases/evidence_spec.rb index d38d2021117..927e2e9bbe6 100644 --- a/spec/models/releases/evidence_spec.rb +++ b/spec/models/releases/evidence_spec.rb @@ -5,83 +5,21 @@ require 'spec_helper' describe Releases::Evidence do let_it_be(:project) { create(:project) } let(:release) { create(:release, project: project) } - let(:schema_file) { 'evidences/evidence' } - let(:summary_json) { described_class.last.summary.to_json } describe 'associations' do it { is_expected.to belong_to(:release) } end - describe 'summary_sha' do - it 'returns nil if summary is nil' do - expect(build(:evidence, summary: nil).summary_sha).to be_nil - end - end - - describe '#generate_summary_and_sha' do - before do - described_class.create!(release: release) - end - - context 'when a release name is not provided' do - let(:release) { create(:release, project: project, name: nil) } - - it 'creates a valid JSON object' do - expect(release.name).to eq(release.tag) - expect(summary_json).to match_schema(schema_file) - end - end - - context 'when a release is associated to a milestone' do - let(:milestone) { create(:milestone, project: project) } - let(:release) { create(:release, project: project, milestones: [milestone]) } - - context 'when a milestone has no issue associated with it' do - it 'creates a valid JSON object' do - expect(milestone.issues).to be_empty - expect(summary_json).to match_schema(schema_file) - end - end - - context 'when a milestone has no description' do - let(:milestone) { create(:milestone, project: project, description: nil) } - - it 'creates a valid JSON object' do - expect(milestone.description).to be_nil - expect(summary_json).to match_schema(schema_file) - end - end - - context 'when a milestone has no due_date' do - let(:milestone) { create(:milestone, project: project, due_date: nil) } - - it 'creates a valid JSON object' do - expect(milestone.due_date).to be_nil - expect(summary_json).to match_schema(schema_file) - end - end - - context 'when a milestone has an issue' do - context 'when the issue has no description' do - let(:issue) { create(:issue, project: project, description: nil, state: 'closed') } - - before do - milestone.issues << issue - end + it 'filters out issues from summary json' do + milestone = create(:milestone, project: project, due_date: nil) + issue = create(:issue, project: project, description: nil, state: 'closed') + milestone.issues << issue + release.milestones << milestone - it 'creates a valid JSON object' do - expect(milestone.issues.first.description).to be_nil - expect(summary_json).to match_schema(schema_file) - end - end - end - end + ::Releases::CreateEvidenceService.new(release).execute + evidence = release.evidences.last - context 'when a release is not associated to any milestone' do - it 'creates a valid JSON object' do - expect(release.milestones).to be_empty - expect(summary_json).to match_schema(schema_file) - end - end + expect(evidence.read_attribute(:summary)["release"]["milestones"].first["issues"].first["title"]).to be_present + expect(evidence.summary["release"]["milestones"].first["issues"]).to be_nil end end |