Commit 90970775 authored by Avielle Wolfe's avatar Avielle Wolfe

Update uses of feedback type enum

parent f2030f1b
......@@ -4,9 +4,9 @@ module Vulnerabilities
class FeedbackPolicy < BasePolicy
delegate { @subject.project }
condition(:issue) { @subject.issue? }
condition(:merge_request) { @subject.merge_request? }
condition(:dismissal) { @subject.dismissal? }
condition(:issue) { @subject.issue_type? }
condition(:merge_request) { @subject.merge_request_type? }
condition(:dismissal) { @subject.dismissal_type? }
rule { issue & ~can?(:create_issue) }.prevent :create_vulnerability_feedback
......
......@@ -7,11 +7,11 @@ module VulnerabilityFeedback
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :create_vulnerability_feedback, vulnerability_feedback)
if vulnerability_feedback.issue? &&
if vulnerability_feedback.issue_type? &&
!vulnerability_feedback.vulnerability_data.blank?
create_issue_for(vulnerability_feedback)
elsif vulnerability_feedback.merge_request? &&
elsif vulnerability_feedback.merge_request_type? &&
!vulnerability_feedback.vulnerability_data.blank?
create_merge_request_for(vulnerability_feedback)
......
......@@ -50,10 +50,10 @@ describe VulnerabilityFeedback::CreateService, '#execute' do
expect(feedback.pipeline_id).to eq(pipeline.id)
expect(feedback.category).to eq('sast')
expect(feedback.project_fingerprint).to eq('418291a26024a1445b23fe64de9380cdcdfd1fa8')
expect(feedback.dismissal?).to eq(true)
expect(feedback.issue?).to eq(false)
expect(feedback.dismissal_type?).to eq(true)
expect(feedback.issue_type?).to eq(false)
expect(feedback.issue).to be_nil
expect(feedback.merge_request?).to eq(false)
expect(feedback.merge_request_type?).to eq(false)
expect(feedback.merge_request).to be_nil
end
......@@ -101,10 +101,10 @@ describe VulnerabilityFeedback::CreateService, '#execute' do
expect(feedback.pipeline_id).to eq(pipeline.id)
expect(feedback.category).to eq('sast')
expect(feedback.project_fingerprint).to eq('418291a26024a1445b23fe64de9380cdcdfd1fa8')
expect(feedback.dismissal?).to eq(false)
expect(feedback.issue?).to eq(true)
expect(feedback.dismissal_type?).to eq(false)
expect(feedback.issue_type?).to eq(true)
expect(feedback.issue).to be_an(Issue)
expect(feedback.merge_request?).to eq(false)
expect(feedback.merge_request_type?).to eq(false)
expect(feedback.merge_request).to be_nil
end
......@@ -176,10 +176,10 @@ describe VulnerabilityFeedback::CreateService, '#execute' do
expect(feedback.pipeline_id).to eq(pipeline.id)
expect(feedback.category).to eq('dependency_scanning')
expect(feedback.project_fingerprint).to eq('418291a26024a1445b23fe64de9380cdcdfd1fa8')
expect(feedback.dismissal?).to eq(false)
expect(feedback.issue?).to eq(false)
expect(feedback.dismissal_type?).to eq(false)
expect(feedback.issue_type?).to eq(false)
expect(feedback.issue).to be_nil
expect(feedback.merge_request?).to eq(true)
expect(feedback.merge_request_type?).to eq(true)
expect(feedback.merge_request).to be_an(MergeRequest)
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