Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dry specialist publisher tests #3029

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has the behaviour changed or was this fixture data always wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it must have always been wrong, when I ran this through the 'valid_against_schema' shared example it complained about the time element.

I don't think this was caught previously because the drcf finder didn't have it's own model spec file to check it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for animal disease case

"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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this into its own commit - it'll make the PR easier to review.

I had drafted the following comment further up in this commit, because it looked as though you were deleting the schema validation tests without adding a new equivalent.

When you move this into its own commit, you can also use that as an opportunity to explain (in the message) why ai_assurance_portfolio_technique needs to be excluded.

I think we'll want to copy this sort of general schema validation check over to `spec/features/creating_a_new_document_spec.rb` (or some other generic test file). We want to ensure that all finder schemas are valid.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually quite like the validation tests to live here, rather than in the feature specs.

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