Commit f8238cde authored by Michał Zając's avatar Michał Zając

Create Vulnerability serializer

parent 00286b2f
# frozen_string_literal: true
class VulnerabilityEntity < Grape::Entity
include RequestAwareEntity
expose :id,
:title,
:state,
:severity,
:confidence,
:report_type,
:resolved_on_default_branch,
:project_default_branch,
:resolved_by_id,
:dismissed_by_id,
:confirmed_by_id
end
# frozen_string_literal: true
class VulnerabilitySerializer < BaseSerializer
entity VulnerabilityEntity
end
# frozen_string_literal: true
require 'spec_helper'
describe VulnerabilityEntity do
let(:entity) { described_class.new(vulnerability) }
let(:vulnerability) { create(:vulnerability, project: project, author: user) }
let(:project) { create(:project) }
let(:user) { create(:user) }
subject { entity.as_json }
it 'exposes vulnerability-specific elements' do
expect(subject).to match(
id: vulnerability.id,
title: vulnerability.title,
state: vulnerability.state,
severity: vulnerability.severity,
confidence: vulnerability.confidence,
report_type: vulnerability.report_type,
resolved_on_default_branch: vulnerability.resolved_on_default_branch,
project_default_branch: vulnerability.project_default_branch
)
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