Skip to content
Snippets Groups Projects
Verified Commit 15f829bf authored by Subashis  Chakraborty's avatar Subashis Chakraborty :one: Committed by GitLab
Browse files

Merge branch 'remove-as_vulnerable_project-helper' into 'master'

Remove as_vulnerable_project helper

See merge request !178361



Merged-by: default avatarSubashis Chakraborty <schakraborty@gitlab.com>
Approved-by: default avatarArpit Gogia <12347103-arpitgogia@users.noreply.gitlab.com>
Approved-by: default avatarMichał Zając <mzajac@gitlab.com>
Approved-by: default avatarSubashis Chakraborty <schakraborty@gitlab.com>
Co-authored-by: Fabien Catteau's avatarFabien Catteau <fcatteau@gitlab.com>
parents 162ff7ce cd7164b6
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!179611Draft: Rebase CR approach for zoekt assignments,!178361Remove as_vulnerable_project helper
Pipeline #1633214585 passed
......@@ -559,10 +559,6 @@ def first_non_empty_project
projects.detect { |project| !project.empty_repo? }
end
def project_ids_with_security_reports
all_projects.with_security_reports_stored.pluck_primary_key
end
def root_ancestor_ip_restrictions
return ip_restrictions if parent_id.nil?
......
......@@ -19,10 +19,6 @@ def duo_features_enabled
end
alias_method :duo_features_enabled?, :duo_features_enabled
def project_ids_with_security_reports
users_projects_with_security_reports.pluck(:project_id)
end
def feature_available?(feature)
License.feature_available?(feature)
end
......@@ -79,12 +75,6 @@ def duo_enabled_project
end
strong_memoize_attr :duo_enabled_project
def users_projects_with_security_reports
return visible_users_security_dashboard_projects if project_ids.empty?
visible_users_security_dashboard_projects.where(project_id: project_ids)
end
def visible_users_security_dashboard_projects
return users_security_dashboard_projects if user.can?(:read_all_resources)
......
......@@ -21,39 +21,6 @@
subject(:instance_dashboard) { described_class.new(user, project_ids: project_ids) }
describe '#project_ids_with_security_reports' do
context 'when given project IDs' do
it "returns the project IDs that are also on the user's security dashboard" do
expect(subject.project_ids_with_security_reports).to contain_exactly(project1.id)
end
end
context 'when not given project IDs' do
let(:project_ids) { [] }
it "returns the security dashboard projects' IDs" do
expect(subject.project_ids_with_security_reports).to contain_exactly(project1.id)
end
end
context 'when the user cannot read all resources' do
let(:project_ids) { [project1.id, project2.id] }
it 'only includes projects they can read' do
expect(subject.project_ids_with_security_reports).to contain_exactly(project1.id)
end
end
context 'when the user can read all resources' do
let(:project_ids) { [project1.id, project2.id] }
let(:user) { create(:auditor) }
it 'includes all dashboard projects' do
expect(subject.project_ids_with_security_reports).to contain_exactly(project1.id, project2.id)
end
end
end
describe '#feature_available?' do
subject { described_class.new(user).feature_available?(:security_dashboard) }
......
......@@ -6,17 +6,4 @@ def message
'The given vulnerable must be either `Project`, `Namespace`, or `InstanceSecurityDashboard`'
end
end
def as_vulnerable_project(vulnerable)
case vulnerable
when Project
vulnerable
when Namespace
create(:project, namespace: vulnerable)
when InstanceSecurityDashboard
Project.find(vulnerable.project_ids_with_security_reports.first)
else
raise BadVulnerableError
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment