Commit edd4c195 authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Implement Vulnerabilities::Feedback#finding method

parent 57f52e00
......@@ -90,5 +90,13 @@ module Vulnerabilities
def touch_pipeline
pipeline&.touch
end
def finding
Finding.find_by(
project_id: project_id,
report_type: category,
project_fingerprint: project_fingerprint
)
end
end
end
......@@ -235,4 +235,25 @@ RSpec.describe Vulnerabilities::Feedback do
it { is_expected.to eq({ project_id: project.id, category: category, project_fingerprint: project_fingerprint }) }
end
describe '#finding' do
let_it_be(:feedback) { create(:vulnerability_feedback) }
subject { feedback.finding }
context 'when the is no finding persisted' do
it { is_expected.to be_nil }
end
context 'when there is a persisted finding' do
let!(:finding) do
create(:vulnerabilities_finding,
project: feedback.project,
report_type: feedback.category,
project_fingerprint: feedback.project_fingerprint)
end
it { is_expected.to eq(finding) }
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