Не подтверждена Коммит 96451294 создал по автору mo khan's avatar mo khan
Просмотр файлов

Rename .with_feedback_type to .by_feedback_type

владелец 3171b45b
......@@ -36,7 +36,7 @@ def by_category(feedback)
end
def by_feedback_type(feedback)
feedback = feedback.with_feedback_type(params[:feedback_type]) if params[:feedback_type].present?
feedback = feedback.by_feedback_type(params[:feedback_type]) if params[:feedback_type].present?
feedback
end
end
......
......@@ -179,10 +179,10 @@ def issue_links
def merge_request
BatchLoader::GraphQL.for(object.uuid).batch do |uuids, loader|
::Vulnerabilities::Feedback
.all_preloaded.by_finding_uuid(uuids)
.with_feedback_type('merge_request').each do |feedback|
loader.call(feedback.finding_uuid, feedback.merge_request)
end
.all_preloaded
.by_finding_uuid(uuids)
.by_feedback_type('merge_request')
.each { |feedback| loader.call(feedback.finding_uuid, feedback.merge_request) }
end
end
......@@ -210,7 +210,7 @@ def dismissal_feedback(lookahead:, &block)
subject = BatchLoader::GraphQL.for(object.uuid).batch(key: key) do |uuids, loader, batch|
feedbacks = ::Vulnerabilities::Feedback.by_finding_uuid(uuids)
feedbacks = feedbacks.preload_author if batch[:key][:preload_author]
feedbacks = feedbacks.with_feedback_type('dismissal')
feedbacks = feedbacks.by_feedback_type('dismissal')
feedbacks.each do |feedback|
loader.call(feedback.finding_uuid, feedback)
......
......@@ -44,6 +44,7 @@ class Feedback < ApplicationRecord
scope :with_associations, -> { includes(:pipeline, :issue, :merge_request, :author, :comment_author) }
scope :with_merge_request, -> { includes(:merge_request) }
scope :by_feedback_type, -> (feedback_type) { where(feedback_type: feedback_type) }
scope :by_finding_uuid, -> (uuids) { where(finding_uuid: uuids) }
scope :by_project, -> (project) { where(project: project) }
scope :by_project_fingerprints, -> (project_fingerprints) { where(project_fingerprint: project_fingerprints) }
......@@ -90,10 +91,6 @@ def self.with_category(category)
where(category: category)
end
def self.with_feedback_type(feedback_type)
where(feedback_type: feedback_type)
end
# A hard delete of the comment_author will cause the comment_author to be nil, but the comment
# will still exist.
def has_comment?
......
......@@ -189,16 +189,15 @@
end
end
describe '.with_feedback_type' do
describe '.by_feedback_type' do
it 'filters by feedback_type' do
create(:vulnerability_feedback, :dismissal)
create(:vulnerability_feedback, :issue)
issue_feedback = create(:vulnerability_feedback, :issue)
create(:vulnerability_feedback, :merge_request)
feedback = described_class.with_feedback_type('issue')
feedback = described_class.by_feedback_type('issue')
expect(feedback.length).to eq 1
expect(feedback.first.feedback_type).to eq 'issue'
expect(feedback).to contain_exactly(issue_feedback)
end
end
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать