-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
Changes from all commits
12353cc
284af6a
30e7f2e
d927acf
628b016
0f653f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,7 @@ | |
} | ||
], | ||
"filter": { | ||
"format": "european_structural_investment_fund" | ||
"format": "esi_fund" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't (easily) change this as this value is used in Search API too and is associated with all the ESI specialist documents. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah was worried that might be the case, format was a convenient value to use from the schema to set the document type in the test. I'm trying to add a conditional, in the test, to do this but having some issues accessing DOM elements atm 😢 |
||
}, | ||
"name": "European Structural and Investment Funds (ESIF)", | ||
"organisations": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,60 @@ | ||
require "spec_helper" | ||
|
||
RSpec.feature "Access control", type: :feature do | ||
GDSNewt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
before do | ||
stub_publishing_api_has_content([], hash_including(document_type: CmaCase.document_type)) | ||
stub_publishing_api_has_content([], hash_including(document_type: AaibReport.document_type)) | ||
stub_publishing_api_has_content([], hash_including(document_type: StatutoryInstrument.document_type)) | ||
stub_publishing_api_has_content([], hash_including(document_type: Organisation.document_type)) | ||
context "as an editor of an organisation that doesn't have access to the application" do | ||
before do | ||
log_in_as_editor(:incorrect_id_editor) | ||
end | ||
|
||
scenario "visiting homepage shows a permissions error" do | ||
visit "/" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("Sorry, you don't have permission to access this application") | ||
expect(page).to have_content("Please contact your main GDS contact if you need access.") | ||
end | ||
end | ||
|
||
context "as a CMA Editor" do | ||
before do | ||
stub_publishing_api_has_content([], hash_including(document_type: CmaCase.document_type)) | ||
stub_publishing_api_has_content([], hash_including(document_type: Organisation.document_type)) | ||
log_in_as_editor(:cma_editor) | ||
end | ||
|
||
scenario "visiting /cma-cases" do | ||
scenario "visiting /cma-cases is allowed" do | ||
visit "/cma-cases" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("CMA Cases") | ||
end | ||
|
||
scenario "visiting admin/cma-cases" do | ||
scenario "visiting admin/cma-cases is allowed" do | ||
visit "admin/cma-cases" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("CMA Case finder") | ||
end | ||
|
||
scenario "visiting /aaib-reports" do | ||
scenario "visiting /aaib-reports is rejected" do | ||
visit "/aaib-reports" | ||
|
||
expect(page.current_path).to eq("/cma-cases") | ||
expect(page).to have_content("You aren't permitted to access AAIB Reports") | ||
end | ||
|
||
scenario "visiting admin/aaib-reports" do | ||
scenario "visiting admin/aaib-reports is rejected" do | ||
visit "admin/aaib-reports" | ||
|
||
expect(page.current_path).to eq("/cma-cases") | ||
expect(page).to have_content("You aren't permitted to access AAIB Reports") | ||
end | ||
|
||
scenario "visiting a format which doesn't exist" do | ||
scenario "visiting a format which doesn't exist gives an error message" do | ||
visit "/a-format-which-doesnt-exist" | ||
|
||
expect(page.current_path).to eq("/cma-cases") | ||
expect(page).to have_content("That format doesn't exist.") | ||
end | ||
end | ||
|
||
context "as an AAIB Editor" do | ||
before do | ||
log_in_as_editor(:aaib_editor) | ||
end | ||
|
||
scenario "visiting /aaib-reports" do | ||
visit "/aaib-reports" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("AAIB Reports") | ||
end | ||
|
||
scenario "visiting admin/aaib-reports" do | ||
visit "admin/aaib-reports" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("AAIB Report finder") | ||
end | ||
|
||
scenario "visiting /cma-cases" do | ||
visit "/cma-cases" | ||
|
||
expect(page.current_path).to eq("/aaib-reports") | ||
expect(page).to have_content("You aren't permitted to access CMA Cases") | ||
end | ||
|
||
scenario "visiting admin/cma-cases" do | ||
visit "admin/cma-cases" | ||
|
||
expect(page.current_path).to eq("/aaib-reports") | ||
expect(page).to have_content("You aren't permitted to access CMA Cases") | ||
end | ||
end | ||
|
||
context "as a statutory instrument editor" do | ||
before do | ||
stub_publishing_api_has_content([], hash_including(document_type: Organisation.document_type)) | ||
log_in_as_editor(:statutory_instrument_editor) | ||
end | ||
|
||
scenario "visiting the statutory instruments format" do | ||
visit "/eu-withdrawal-act-2018-statutory-instruments" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("EU Withdrawal Act 2018 statutory instruments") | ||
end | ||
|
||
scenario "visiting another format" do | ||
visit "/cma-cases" | ||
|
||
expect(page.current_path).to eq("/eu-withdrawal-act-2018-statutory-instruments") | ||
expect(page).to have_content("You aren't permitted to access CMA Cases") | ||
end | ||
|
||
scenario "visiting the home page" do | ||
visit "/" | ||
|
||
expect(page.current_path).to eq("/eu-withdrawal-act-2018-statutory-instruments") | ||
end | ||
end | ||
|
||
context "as an editor with incorrect organisation_content_id" do | ||
before do | ||
log_in_as_editor(:incorrect_id_editor) | ||
end | ||
|
||
scenario "visiting /" do | ||
visit "/" | ||
|
||
expect(page.status_code).to eq(200) | ||
expect(page).to have_content("Sorry, you don't have permission to access this application") | ||
expect(page).to have_content("Please contact your main GDS contact if you need access.") | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did not add
apply_validations
to models that simply did not have any validation. They did not have any presence checks, nor any date fields (the only schema validations we added).I believe it is still redundant to add this. I understand the "completeness" aspect, but it might also read as, "ah this thing should have validations", but then you look in the schema and there are none 🕵🏻♀️ Up to you though.