Commit 40960ae6 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '239179-new-model-for-finding-evidences-rename-classes' into 'master'

Rename classes to singular to match current naming

See merge request gitlab-org/gitlab!61933
parents c656d167 84905164
......@@ -37,7 +37,7 @@ module Vulnerabilities
has_many :signatures, class_name: 'Vulnerabilities::FindingSignature', inverse_of: :finding
has_one :evidence, class_name: 'Vulnerabilities::Findings::Evidence', inverse_of: :finding, foreign_key: 'vulnerability_occurrence_id'
has_one :evidence, class_name: 'Vulnerabilities::Finding::Evidence', inverse_of: :finding, foreign_key: 'vulnerability_occurrence_id'
serialize :config_options, Serializers::JSON # rubocop:disable Cop/ActiveRecordSerialize
......
# frozen_string_literal: true
module Vulnerabilities
class Findings
class Finding
class Evidence < ApplicationRecord
self.table_name = 'vulnerability_finding_evidences'
belongs_to :finding, class_name: 'Vulnerabilities::Finding', inverse_of: :evidence, foreign_key: 'vulnerability_occurrence_id', optional: false
has_one :request, class_name: 'Vulnerabilities::Findings::Evidences::Request', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :response, class_name: 'Vulnerabilities::Findings::Evidences::Response', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :request, class_name: 'Vulnerabilities::Finding::Evidence::Request', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :response, class_name: 'Vulnerabilities::Finding::Evidence::Response', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
validates :summary, length: { maximum: 8_000_000 }
end
......
# frozen_string_literal: true
module Vulnerabilities
class Findings
class Evidences
class Finding
class Evidence
class Request < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_requests'
belongs_to :evidence, class_name: 'Vulnerabilities::Findings::Evidence', inverse_of: :request, foreign_key: 'vulnerability_finding_evidence_id', optional: false
belongs_to :evidence, class_name: 'Vulnerabilities::Finding::Evidence', inverse_of: :request, foreign_key: 'vulnerability_finding_evidence_id', optional: false
validates :method, length: { maximum: 32 }
validates :url, length: { maximum: 2048 }
......
# frozen_string_literal: true
module Vulnerabilities
class Findings
class Evidences
class Finding
class Evidence
class Response < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_responses'
belongs_to :evidence, class_name: 'Vulnerabilities::Findings::Evidence', inverse_of: :response, foreign_key: 'vulnerability_finding_evidence_id', optional: false
belongs_to :evidence, class_name: 'Vulnerabilities::Finding::Evidence', inverse_of: :response, foreign_key: 'vulnerability_finding_evidence_id', optional: false
validates :reason_phrase, length: { maximum: 2048 }
validates :body, length: { maximum: 2048 }
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::Evidences::Request do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Findings::Evidence').inverse_of(:request).required }
RSpec.describe Vulnerabilities::Finding::Evidence::Request do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Finding::Evidence').inverse_of(:request).required }
it { is_expected.to validate_length_of(:method).is_at_most(32) }
it { is_expected.to validate_length_of(:url).is_at_most(2048) }
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::Evidences::Response do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Findings::Evidence').inverse_of(:response).required }
RSpec.describe Vulnerabilities::Finding::Evidence::Response do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Finding::Evidence').inverse_of(:response).required }
it { is_expected.to validate_length_of(:reason_phrase).is_at_most(2048) }
it { is_expected.to validate_length_of(:body).is_at_most(2048) }
......
......@@ -2,10 +2,10 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::Evidence do
RSpec.describe Vulnerabilities::Finding::Evidence do
it { is_expected.to belong_to(:finding).class_name('Vulnerabilities::Finding').required }
it { is_expected.to have_one(:request).class_name('Vulnerabilities::Findings::Evidences::Request').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:response).class_name('Vulnerabilities::Findings::Evidences::Response').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:request).class_name('Vulnerabilities::Finding::Evidence::Request').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:response).class_name('Vulnerabilities::Finding::Evidence::Response').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to validate_length_of(:summary).is_at_most(8_000_000) }
end
......@@ -26,7 +26,7 @@ RSpec.describe Vulnerabilities::Finding do
it { is_expected.to have_many(:finding_links).class_name('Vulnerabilities::FindingLink').with_foreign_key('vulnerability_occurrence_id') }
it { is_expected.to have_many(:finding_remediations).class_name('Vulnerabilities::FindingRemediation').with_foreign_key('vulnerability_occurrence_id') }
it { is_expected.to have_many(:remediations).through(:finding_remediations) }
it { is_expected.to have_one(:evidence).class_name('Vulnerabilities::Findings::Evidence').with_foreign_key('vulnerability_occurrence_id') }
it { is_expected.to have_one(:evidence).class_name('Vulnerabilities::Finding::Evidence').with_foreign_key('vulnerability_occurrence_id') }
end
describe 'validations' do
......
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