Commit 0e32b4aa authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Add vulnerabilities method to user model

parent a0f60907
......@@ -349,6 +349,10 @@ module EE
gitlab_employee? ? 'GitLab' : super
end
def vulnerabilities
InstanceSecurityDashboard.new(self).vulnerabilities
end
protected
override :password_required?
......
......@@ -1143,4 +1143,21 @@ describe User do
it { is_expected.to eql(expected_result) }
end
end
describe '#vulnerabilities' do
let(:user) { create(:user) }
let(:vulnerability_collection) { instance_double(ActiveRecord::Relation) }
let(:mock_security_dashboard) { instance_double(InstanceSecurityDashboard, vulnerabilities: vulnerability_collection) }
subject(:vulnerabilities) { user.vulnerabilities }
before do
allow(InstanceSecurityDashboard).to receive(:new).and_return(mock_security_dashboard)
end
it 'delegates the call to an instance of `InstanceSecurityDashboard`' do
expect(vulnerabilities).to eql(vulnerability_collection)
expect(InstanceSecurityDashboard).to have_received(:new).with(user)
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