-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record whether regulations 3 and 4 apply for reporting purposes
- Loading branch information
1 parent
07d6f6b
commit fe058cd
Showing
12 changed files
with
236 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module ReportingTypeHelper | ||
def reporting_radio_button_disabled?(status, params) | ||
status.reporting_type_status == :complete && params.blank? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
app/views/planning_applications/validation/reporting_types/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<% content_for :page_title do %> | ||
Development type - <%= t("page_title") %> | ||
Reporting details - <%= t("page_title") %> | ||
<% end %> | ||
|
||
<%= render( | ||
partial: "planning_applications/validation/validation_requests/validation_requests_breadcrumbs", | ||
locals: {planning_application: @planning_application} | ||
) %> | ||
|
||
<% content_for :title, "Development type" %> | ||
<% content_for :title, "Reporting details" %> | ||
|
||
<%= render( | ||
partial: "shared/proposal_header", | ||
locals: {heading: "Select development type for reporting"} | ||
locals: {heading: "Add reporting details"} | ||
) %> | ||
|
||
<%= render "form" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
db/migrate/20240430102131_add_regulation3_and_regulation4_to_planning_application.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddRegulation3AndRegulation4ToPlanningApplication < ActiveRecord::Migration[7.1] | ||
def change | ||
safety_assured { | ||
change_table :planning_applications, bulk: true do |t| | ||
t.boolean :regulation_3, default: false, null: false | ||
t.boolean :regulation_4, default: false, null: false | ||
end | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
spec/system/planning_applications/validating/reporting_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Reporting validation task" do | ||
let!(:default_local_authority) { create(:local_authority, :default) } | ||
let!(:assessor) { create(:user, :assessor, local_authority: default_local_authority) } | ||
let!(:reporting_type) { create(:reporting_type, :ldc) } | ||
|
||
let!(:planning_application) do | ||
create(:planning_application, :not_started, local_authority: default_local_authority) | ||
end | ||
|
||
before do | ||
sign_in assessor | ||
visit "/planning_applications/#{planning_application.id}/validation/tasks" | ||
end | ||
|
||
context "when application is not started" do | ||
it "I can see that reporting type is not started" do | ||
expect(page).to have_link( | ||
"Add reporting details", | ||
href: "/planning_applications/#{planning_application.id}/validation/reporting_type/edit" | ||
) | ||
click_link "Add reporting details" | ||
|
||
expect(page).to have_content("Add reporting details") | ||
|
||
expect(page).to have_content("Select development type") | ||
|
||
click_link "Back" | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Not started") | ||
end | ||
end | ||
|
||
it "I can select the development type for reporting" do | ||
click_link "Add reporting details" | ||
|
||
expect(page).to have_content("Add reporting details") | ||
|
||
choose "Q26 – Certificates of lawful development" | ||
|
||
expect(page).to have_content("Includes both existing & proposed applications") | ||
|
||
click_button "Save and mark as complete" | ||
|
||
within(".govuk-notification-banner--notice") do | ||
expect(page).to have_content("Planning application's development type for reporting was successfully selected") | ||
end | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Completed") | ||
end | ||
|
||
expect(page).to have_link( | ||
"Add reporting details", | ||
href: "/planning_applications/#{planning_application.id}/validation/reporting_type/edit" | ||
) | ||
end | ||
|
||
it "shows errors when a development type for reporting is not selected" do | ||
click_link "Add reporting details" | ||
|
||
click_button "Save and mark as complete" | ||
|
||
expect(page).to have_content "Please select a development type for reporting" | ||
end | ||
|
||
it "I can report whether regulation 3 applies" do | ||
click_link "Add reporting details" | ||
|
||
expect(page).to have_content("Add reporting details") | ||
|
||
choose "Q26 – Certificates of lawful development" | ||
|
||
expect(page).to have_content("Includes both existing & proposed applications") | ||
|
||
# Radios within radios makes finding 'yes' complicated | ||
page.find(:xpath, '//*[@id="planning-application-regulation-true-field"]').click | ||
page.find(:xpath, '//*[@id="planning-application-regulation-3-true-field"]').click | ||
|
||
click_button "Save and mark as complete" | ||
|
||
within(".govuk-notification-banner--notice") do | ||
expect(page).to have_content("Planning application's development type for reporting was successfully selected") | ||
end | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Completed") | ||
end | ||
|
||
expect(planning_application.reload.regulation_3).to be true | ||
expect(planning_application.reload.regulation_4).to be false | ||
end | ||
|
||
it "I can report whether regulation 4 applies" do | ||
click_link "Add reporting details" | ||
|
||
expect(page).to have_content("Add reporting details") | ||
|
||
choose "Q26 – Certificates of lawful development" | ||
|
||
expect(page).to have_content("Includes both existing & proposed applications") | ||
|
||
# Radios within radios makes finding 'yes' complicated | ||
page.find(:xpath, '//*[@id="planning-application-regulation-true-field"]').click | ||
page.find(:xpath, '//*[@id="planning-application-regulation-3-field"]').click | ||
|
||
click_button "Save and mark as complete" | ||
|
||
within(".govuk-notification-banner--notice") do | ||
expect(page).to have_content("Planning application's development type for reporting was successfully selected") | ||
end | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Completed") | ||
end | ||
|
||
expect(planning_application.reload.regulation_3).to be false | ||
expect(planning_application.reload.regulation_4).to be true | ||
end | ||
|
||
it "I can edit the regulations" do | ||
click_link "Add reporting details" | ||
|
||
expect(page).to have_content("Add reporting details") | ||
|
||
choose "Q26 – Certificates of lawful development" | ||
|
||
expect(page).to have_content("Includes both existing & proposed applications") | ||
|
||
# Radios within radios makes finding 'yes' complicated | ||
page.find(:xpath, '//*[@id="planning-application-regulation-true-field"]').click | ||
page.find(:xpath, '//*[@id="planning-application-regulation-3-field"]').click | ||
|
||
click_button "Save and mark as complete" | ||
|
||
within(".govuk-notification-banner--notice") do | ||
expect(page).to have_content("Planning application's development type for reporting was successfully selected") | ||
end | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Completed") | ||
click_link "Add reporting details" | ||
end | ||
|
||
expect(page).not_to have_content "Save and mark as complete" | ||
|
||
click_link "Edit reporting details" | ||
|
||
page.find(:xpath, '//*[@id="planning-application-regulation-field"]').click | ||
|
||
click_button "Save and mark as complete" | ||
|
||
within("#development-type-for-reporting-task") do | ||
expect(page).to have_selector(".govuk-tag", text: "Completed") | ||
end | ||
|
||
expect(planning_application.reload.regulation_3).to be false | ||
expect(planning_application.reload.regulation_4).to be false | ||
end | ||
end | ||
end |
71 changes: 0 additions & 71 deletions
71
spec/system/planning_applications/validating/reporting_type_spec.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.