Commit f3e7f530 authored by Vladimir Shushlin's avatar Vladimir Shushlin

Fix false negative tests

Also returning issues to schema since they are generated and saved
but filtered later

And fix issue schema
parent 40b52543
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
"id", "id",
"title", "title",
"description", "description",
"author",
"state", "state",
"iid", "iid",
"confidential", "confidential",
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"state", "state",
"iid", "iid",
"created_at", "created_at",
"due_date" "due_date",
"issues"
], ],
"properties": { "properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
...@@ -16,7 +17,11 @@ ...@@ -16,7 +17,11 @@
"state": { "type": "string" }, "state": { "type": "string" },
"iid": { "type": "integer" }, "iid": { "type": "integer" },
"created_at": { "type": "date" }, "created_at": { "type": "date" },
"due_date": { "type": ["date", "null"] } "due_date": { "type": ["date", "null"] },
"issues": {
"type": "array",
"items": { "$ref": "issue.json" }
}
}, },
"additionalProperties": false "additionalProperties": false
} }
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe Evidences::EvidenceEntity do describe Evidences::EvidenceEntity do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:release) { create(:release, project: project) } let(:release) { create(:release, project: project) }
let(:evidence) { build(:evidence) } let(:evidence) { build(:evidence, release: release) }
let(:entity) { described_class.new(evidence) } let(:entity) { described_class.new(evidence) }
let(:schema_file) { 'evidences/evidence' } let(:schema_file) { 'evidences/evidence' }
...@@ -21,7 +21,7 @@ describe Evidences::EvidenceEntity do ...@@ -21,7 +21,7 @@ describe Evidences::EvidenceEntity do
context 'when a milestone has no issue associated with it' do context 'when a milestone has no issue associated with it' do
it 'creates a valid JSON object' do it 'creates a valid JSON object' do
expect(milestone.issues).to be_empty expect(subject[:release][:milestones].first[:issues]).to be_empty
expect(subject.to_json).to match_schema(schema_file) expect(subject.to_json).to match_schema(schema_file)
end end
end end
...@@ -30,7 +30,7 @@ describe Evidences::EvidenceEntity do ...@@ -30,7 +30,7 @@ describe Evidences::EvidenceEntity do
let(:milestone) { create(:milestone, project: project, description: nil) } let(:milestone) { create(:milestone, project: project, description: nil) }
it 'creates a valid JSON object' do it 'creates a valid JSON object' do
expect(milestone.description).to be_nil expect(subject[:release][:milestones].first[:description]).to be_nil
expect(subject.to_json).to match_schema(schema_file) expect(subject.to_json).to match_schema(schema_file)
end end
end end
...@@ -39,7 +39,7 @@ describe Evidences::EvidenceEntity do ...@@ -39,7 +39,7 @@ describe Evidences::EvidenceEntity do
let(:milestone) { create(:milestone, project: project, due_date: nil) } let(:milestone) { create(:milestone, project: project, due_date: nil) }
it 'creates a valid JSON object' do it 'creates a valid JSON object' do
expect(milestone.due_date).to be_nil expect(subject[:release][:milestones].first[:due_date]).to be_nil
expect(subject.to_json).to match_schema(schema_file) expect(subject.to_json).to match_schema(schema_file)
end end
end end
...@@ -53,7 +53,7 @@ describe Evidences::EvidenceEntity do ...@@ -53,7 +53,7 @@ describe Evidences::EvidenceEntity do
end end
it 'creates a valid JSON object' do it 'creates a valid JSON object' do
expect(milestone.issues.first.description).to be_nil expect(subject[:release][:milestones].first[:issues].first[:title]).to be_present
expect(subject.to_json).to match_schema(schema_file) expect(subject.to_json).to match_schema(schema_file)
end end
end end
...@@ -62,7 +62,7 @@ describe Evidences::EvidenceEntity do ...@@ -62,7 +62,7 @@ describe Evidences::EvidenceEntity do
context 'when a release is not associated to any milestone' do context 'when a release is not associated to any milestone' do
it 'creates a valid JSON object' do it 'creates a valid JSON object' do
expect(release.milestones).to be_empty expect(subject[:release][:milestones]).to be_empty
expect(subject.to_json).to match_schema(schema_file) expect(subject.to_json).to match_schema(schema_file)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment