Commit 001a182d authored by charlie ablett's avatar charlie ablett

Merge branch 'no-archived-or-deleted-vulns' into 'master'

No archived or deleted project vulnerabilties

See merge request gitlab-org/gitlab!28696
parents 5e09b45b 62e80498
...@@ -306,7 +306,9 @@ module EE ...@@ -306,7 +306,9 @@ module EE
end end
def vulnerabilities def vulnerabilities
::Vulnerability.where(project: ::Project.for_group_and_its_subgroups(self)) ::Vulnerability.where(
project: ::Project.for_group_and_its_subgroups(self).non_archived.without_deleted
)
end end
private private
......
...@@ -258,15 +258,19 @@ describe Group do ...@@ -258,15 +258,19 @@ describe Group do
end end
describe '#vulnerabilities' do describe '#vulnerabilities' do
subject { group.vulnerabilities }
let(:subgroup) { create(:group, parent: group) } let(:subgroup) { create(:group, parent: group) }
let(:group_project) { create(:project, namespace: group) } let(:group_project) { create(:project, namespace: group) }
let(:subgroup_project) { create(:project, namespace: subgroup) } let(:subgroup_project) { create(:project, namespace: subgroup) }
let(:archived_project) { create(:project, :archived, namespace: group) }
let(:deleted_project) { create(:project, pending_delete: true, namespace: group) }
let!(:group_vulnerability) { create(:vulnerability, project: group_project) } let!(:group_vulnerability) { create(:vulnerability, project: group_project) }
let!(:subgroup_vulnerability) { create(:vulnerability, project: subgroup_project) } let!(:subgroup_vulnerability) { create(:vulnerability, project: subgroup_project) }
let!(:archived_vulnerability) { create(:vulnerability, project: archived_project) }
let!(:deleted_vulnerability) { create(:vulnerability, project: deleted_project) }
subject { group.vulnerabilities } it 'returns vulnerabilities for all non-archived, non-deleted projects in the group and its subgroups' do
it 'returns vulnerabilities for all projects in the group and its subgroups' do
is_expected.to contain_exactly(group_vulnerability, subgroup_vulnerability) is_expected.to contain_exactly(group_vulnerability, subgroup_vulnerability)
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