Commit 2e4b79ad authored by Sean McGivern's avatar Sean McGivern

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

Restructure Finding Evidence

See merge request gitlab-org/gitlab!61066
parents a6d828da 5e151367
......@@ -37,7 +37,7 @@ module Vulnerabilities
has_many :signatures, class_name: 'Vulnerabilities::FindingSignature', inverse_of: :finding
has_many :finding_evidences, class_name: 'Vulnerabilities::FindingEvidence', inverse_of: :finding, foreign_key: 'vulnerability_occurrence_id'
has_one :evidence, class_name: 'Vulnerabilities::Findings::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 FindingEvidence < ApplicationRecord
self.table_name = 'vulnerability_finding_evidences'
belongs_to :finding, class_name: 'Vulnerabilities::Finding', inverse_of: :finding_evidences, foreign_key: 'vulnerability_occurrence_id', optional: false
has_many :requests, class_name: 'Vulnerabilities::FindingEvidenceRequest', inverse_of: :finding_evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_many :responses, class_name: 'Vulnerabilities::FindingEvidenceResponse', inverse_of: :finding_evidence, foreign_key: 'vulnerability_finding_evidence_id'
end
end
# frozen_string_literal: true
module Vulnerabilities
class FindingEvidenceRequest < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_requests'
belongs_to :finding_evidence, class_name: 'Vulnerabilities::FindingEvidence', inverse_of: :requests, foreign_key: 'vulnerability_finding_evidence_id', optional: false
end
end
# frozen_string_literal: true
module Vulnerabilities
class FindingEvidenceResponse < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_responses'
belongs_to :finding_evidence, class_name: 'Vulnerabilities::FindingEvidence', inverse_of: :responses, foreign_key: 'vulnerability_finding_evidence_id', optional: false
end
end
# frozen_string_literal: true
module Vulnerabilities
class Findings
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'
end
end
end
# frozen_string_literal: true
module Vulnerabilities
class Findings
class Evidences
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
end
end
end
end
# frozen_string_literal: true
module Vulnerabilities
class Findings
class Evidences
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
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Vulnerabilities::FindingEvidenceRequest do
it { is_expected.to belong_to(:finding_evidence).class_name('Vulnerabilities::FindingEvidence').inverse_of(:requests).required }
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Vulnerabilities::FindingEvidenceResponse do
it { is_expected.to belong_to(:finding_evidence).class_name('Vulnerabilities::FindingEvidence').inverse_of(:responses).required }
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Vulnerabilities::FindingEvidence do
it { is_expected.to belong_to(:finding).class_name('Vulnerabilities::Finding').required }
it { is_expected.to have_many(:requests).class_name('Vulnerabilities::FindingEvidenceRequest').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:finding_evidence) }
it { is_expected.to have_many(:responses).class_name('Vulnerabilities::FindingEvidenceResponse').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:finding_evidence) }
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_many(:finding_evidences).class_name('Vulnerabilities::FindingEvidence').with_foreign_key('vulnerability_occurrence_id') }
it { is_expected.to have_one(:evidence).class_name('Vulnerabilities::Findings::Evidence').with_foreign_key('vulnerability_occurrence_id') }
end
describe 'validations' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::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) }
end
# frozen_string_literal: true
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 }
end
# frozen_string_literal: true
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 }
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