Skip to content

Commit

Permalink
Consolidate model spec in general test file
Browse files Browse the repository at this point in the history
Our validations are now largely defined by the schemas and are being applied
to the models without the need to be manually defined and configured.

This validation in tested by our feature tests. It seems unnecessary to test this validation twice.
  • Loading branch information
GDSNewt committed Feb 28, 2025
1 parent 9802a43 commit d6fd105
Show file tree
Hide file tree
Showing 32 changed files with 50 additions and 511 deletions.
30 changes: 26 additions & 4 deletions spec/fixtures/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@
"digital_market_research_publisher" => %w[gambling-commission],
"digital_market_research_area" => %w[media-and-entertainment],
"digital_market_research_topic" => %w[future-connectivity],
"digital_market_research_publish_date" => "2021-02-18T10:12:26+00:00",
"digital_market_research_publish_date" => "2021-02-18",
}
end
end
Expand All @@ -777,8 +777,8 @@
"zone_restriction" => "no-longer-in-force",
"zone_type" => %w[surveillance],
"virus_strain" => "h5nx",
"disease_case_opened_date" => "2022-08-18T10:12:26+00:00",
"disease_case_closed_date" => "2022-09-18T10:12:26+00:00",
"disease_case_opened_date" => "2022-08-18",
"disease_case_closed_date" => "2022-09-18",
}
end
end
Expand Down Expand Up @@ -846,10 +846,32 @@
factory :export_health_certificate, parent: :document do
base_path { "/export-health-certificates/example-document" }
document_type { "export_health_certificate" }

transient do
default_metadata do
{
"destination_country" => %w[afghanistan],
"commodity_type" => "animal-products-including-food",
"certificate_status" => "active",
}
end
end
end

factory :traffic_commissioner_regulatory_decision, parent: :document do
base_path { "/traffic_commissioner_regulatory_decisions/example-document" }
base_path { "/traffic-commissioner-regulatory-decisions/example-document" }
document_type { "traffic_commissioner_regulatory_decision" }

transient do
default_metadata do
{
"decision_subject" => %w[driver-conduct],
"regions" => %w[eastern],
"case_type" => %w[application],
"outcome_type" => %w[application-granted-as-applied-for],
"first_published_at" => "2022-08-18",
}
end
end
end
end
11 changes: 0 additions & 11 deletions spec/models/aaib_report_spec.rb

This file was deleted.

43 changes: 0 additions & 43 deletions spec/models/algorithmic_transparency_record_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/asylum_support_decision_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/business_finance_support_scheme_spec.rb

This file was deleted.

40 changes: 0 additions & 40 deletions spec/models/cma_case_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/countryside_stewardship_grant_spec.rb

This file was deleted.

26 changes: 0 additions & 26 deletions spec/models/data_ethics_guidance_document_spec.rb

This file was deleted.

24 changes: 24 additions & 0 deletions spec/models/document_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "spec_helper"
require "models/valid_against_schema"

EXCEPTIONS_TO_GENERAL_TESTING = %w[
ai_assurance_portfolio_technique
].freeze

Dir["lib/documents/schemas/*.json"].each do |file|
schema = JSON.parse(File.read(file))
format = schema["filter"]["format"]

next if EXCEPTIONS_TO_GENERAL_TESTING.include?(format)

RSpec.describe format.classify.constantize do
let(:payload) { FactoryBot.create(format.to_sym) }
include_examples "it saves payloads that are valid against the 'specialist_document' schema"

it "is not exportable" do
unless subject.instance_of?(BusinessFinanceSupportScheme)
expect(subject.class).not_to be_exportable
end
end
end
end
4 changes: 0 additions & 4 deletions spec/models/drug_safety_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
let(:payload) { FactoryBot.create(:drug_safety_update) }
include_examples "it saves payloads that are valid against the 'specialist_document' schema"

it "is not exportable" do
expect(described_class).not_to be_exportable
end

context "#publish" do
let(:payload) do
FactoryBot.create(
Expand Down
11 changes: 0 additions & 11 deletions spec/models/employment_appeal_tribunal_decision_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/employment_tribunal_decision_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/esi_fund_spec.rb

This file was deleted.

23 changes: 0 additions & 23 deletions spec/models/farming_grant_spec.rb

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/international_development_fund_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/licence_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
let(:payload) { FactoryBot.create(:licence_transaction) }
include_examples "it saves payloads that are valid against the 'specialist_document' schema"

it "is not exportable" do
expect(subject.class).not_to be_exportable
end

it "should have a rendering app of frontend" do
expect(subject.rendering_app).to eq "frontend"
end
Expand Down
34 changes: 0 additions & 34 deletions spec/models/life_saving_maritime_appliance_service_station_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/models/maib_report_spec.rb

This file was deleted.

Loading

0 comments on commit d6fd105

Please sign in to comment.