Skip to content

Commit

Permalink
Showing 19 changed files with 55 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app/components/consultation_status_component.rb
Original file line number Diff line number Diff line change
@@ -67,6 +67,6 @@ def format_datetime(datetime_str)
end

def decision_notice_link
"#{Rails.configuration.api_protocol}://#{Current.local_authority}.#{Rails.configuration.api_host}/public/planning_applications/#{planning_application["id"]}/decision_notice"
"#{Rails.configuration.api_protocol}://#{Current.local_authority}.#{Rails.configuration.api_host}/public/planning_applications/#{planning_application["reference"]}/decision_notice"
end
end
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -21,4 +21,9 @@ def set_current_local_authority
def set_header_link
@header_link = validation_requests_path(planning_application_id: params["planning_application_id"], change_access_id: params["change_access_id"])
end

def set_planning_application
reference = params[:planning_application_reference] || params[:reference] || params[:planning_application_id]
@planning_application = Bops::PlanningApplication.find(reference)
end
end
4 changes: 0 additions & 4 deletions app/controllers/land_owners_controller.rb
Original file line number Diff line number Diff line change
@@ -26,10 +26,6 @@ def create

private

def set_planning_application
@planning_application = Bops::PlanningApplication.find(params[:planning_application_id])
end

def set_certificate
@ownership_certificate = OwnershipCertificate.find(params[:ownership_certificate_id])
end
10 changes: 3 additions & 7 deletions app/controllers/neighbour_responses_controller.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class NeighbourResponsesController < ApplicationController
{tags: []}
].freeze

PERMITTED_PARAMS = [:stage, :move_next, :move_back, :planning_application_id,
PERMITTED_PARAMS = [:stage, :move_next, :move_back, :planning_application_reference,
{neighbour_response: RESPONSE_PARAMS}].freeze

def start
@@ -27,7 +27,7 @@ def create
respond_to do |format|
format.html do
if @new_response.save
redirect_to thank_you_planning_application_neighbour_responses_path(params[:planning_application_id])
redirect_to thank_you_planning_application_neighbour_responses_path(params[:planning_application_reference])
else
render :new
end
@@ -52,10 +52,6 @@ def flattened_params
neighbour_response_params.merge!(hash)
end

def set_planning_application
@planning_application = Bops::PlanningApplication.find(params[:planning_application_id])
end

def neighbour_response_params
params.permit(PERMITTED_PARAMS)
end
@@ -67,6 +63,6 @@ def ensure_no_decision
end

def set_header_link
@header_link = planning_application_path(id: params["planning_application_id"])
@header_link = planning_application_path(reference: params["planning_application_reference"])
end
end
8 changes: 2 additions & 6 deletions app/controllers/ownership_certificates_controller.rb
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def submit
)

redirect_to validation_requests_path(
planning_application_id: params[:planning_application_id],
planning_application_reference: params[:planning_application_reference],
change_access_id: params[:change_access_id]
), notice: t("shared.response_updated.success")
else
@@ -76,14 +76,10 @@ def set_certificate
@ownership_certificate = OwnershipCertificate.find(params[:ownership_certificate_id] || params[:id])
end

def set_planning_application
@planning_application ||= Bops::PlanningApplication.find(params[:planning_application_id])
end

def ownership_certificate_params
params.require(:ownership_certificate)
.permit(:know_owners, :number_of_owners, :certificate_type, :notification_of_owners, :change_access_id)
.to_h.merge(planning_application_id: @planning_application["id"])
.to_h.merge(planning_application_id: @planning_application["reference"])
end

def set_validation_request
4 changes: 0 additions & 4 deletions app/controllers/planning_applications_controller.rb
Original file line number Diff line number Diff line change
@@ -24,10 +24,6 @@ def render_not_found
render plain: "Not Found", status: :not_found
end

def set_planning_application
@planning_application = Bops::PlanningApplication.find(params[:id])
end

def set_local_authority
@local_authority = Bops::LocalAuthority.find(Current.local_authority)
end
4 changes: 0 additions & 4 deletions app/controllers/site_notices_controller.rb
Original file line number Diff line number Diff line change
@@ -20,8 +20,4 @@ def download
def render_not_found
render plain: "Not Found", status: :not_found
end

def set_planning_application
@planning_application = Bops::PlanningApplication.find(params[:planning_application_id])
end
end
10 changes: 4 additions & 6 deletions app/controllers/validation_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -14,20 +14,18 @@ def index
private

def set_validation_requests
@validation_requests = Bops::ValidationRequest.find_all(params[:planning_application_id], params[:change_access_id])
end

def set_planning_application
@planning_application = Bops::PlanningApplication.find(params[:planning_application_id])
planning_application_reference = params[:planning_application_reference] || params[:planning_application_id]
@validation_requests = Bops::ValidationRequest.find_all(planning_application_reference, params[:change_access_id])
end

def set_local_authority
@local_authority = Bops::LocalAuthority.find(Current.local_authority)
end

def set_validation_request
planning_application_reference = params[:planning_application_reference] || params[:planning_application_id]
@validation_request = validation_request_model_klass.find(
params[:id], params[:planning_application_id], params[:change_access_id]
params[:id], planning_application_reference, params[:change_access_id]
)
end

4 changes: 2 additions & 2 deletions app/models/neighbour_response.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ class NeighbourResponse
attribute :move_next
attribute :move_back
attribute :final_check
attribute :planning_application_id, :integer
attribute :planning_application_reference, :integer

STAGES = %w[about_you thoughts response check].freeze

@@ -61,7 +61,7 @@ def save
)

if Bops::NeighbourResponse.create(
params[:planning_application_id],
params[:planning_application_reference],
data: response_data
)
true
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
resources :time_extension_validation_requests
end

resources :planning_applications, only: %i[show] do
resources :planning_applications, param: :reference, only: %i[show] do
resource :site_notices, only: %i[] do
get :download
end
2 changes: 1 addition & 1 deletion spec/fixtures/test_planning_application.json
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
"invalidated_at": "2021-04-23T10:15:52.855Z",
"in_assessment_at": null,
"payment_reference": "PAY1",
"reference": "22-00100-LDCP",
"reference": "22-00128-LDCP",
"returned_at": null,
"started_at": null,
"status": "invalidated",
2 changes: 1 addition & 1 deletion spec/fixtures/test_private_planning_application.json
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
"invalidated_at": "2021-04-23T10:15:52.855Z",
"in_assessment_at": null,
"payment_reference": "PAY1",
"reference": "22-00100-LDCP",
"reference": "22-00129-LDCP",
"returned_at": null,
"started_at": null,
"status": "invalidated",
18 changes: 14 additions & 4 deletions spec/support/api_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -17,16 +17,20 @@ def stub_successful_get_planning_application
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28")
.with(headers:)
.to_return(status: 200, body: file_fixture("test_planning_application.json").read, headers: {})

stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP")
.with(headers:)
.to_return(status: 200, body: file_fixture("test_planning_application.json").read, headers: {})
end

def stub_successful_get_private_planning_application
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/29")
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00129-LDCP")
.with(headers:)
.to_return(status: 200, body: file_fixture("test_private_planning_application.json").read, headers: {})
end

def stub_unsuccessful_get_planning_application
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/100")
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-99999-LDCP")
.with(headers:)
.to_return(status: 404, body: '{"message": "Not found"}', headers: {})
end
@@ -41,10 +45,13 @@ def stub_successful_get_change_requests
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28/validation_requests?change_access_id=345443543")
.with(headers:)
.to_return(status: 200, body: file_fixture("test_change_request_index.json").read, headers: {})
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP/validation_requests?change_access_id=345443543")
.with(headers:)
.to_return(status: 200, body: file_fixture("test_change_request_index.json").read, headers: {})
end

def stub_rejected_patch_with_reason
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28/validation_requests?change_access_id=345443543")
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP/validation_requests?change_access_id=345443543")
.with(headers:)
.to_return(status: 200, body: file_fixture("rejected_request.json").read, headers: {})
end
@@ -53,6 +60,9 @@ def stub_cancelled_change_requests
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28/validation_requests?change_access_id=345443543")
.with(headers:)
.to_return(status: 200, body: file_fixture("cancelled_validation_requests.json").read, headers: {})
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP/validation_requests?change_access_id=345443543")
.with(headers:)
.to_return(status: 200, body: file_fixture("cancelled_validation_requests.json").read, headers: {})
end

def stub_successful_post_neighbour_response(planning_application_id:, name:, email:, address:, response:, summary_tag:, files:, tags:)
@@ -81,7 +91,7 @@ def stub_get_planning_application(file_fixture, additional_fields: nil)
response_body = parsed_body.to_json
end

stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28")
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP")
.with(headers:)
.to_return(status: 200, body: response_body, headers: {})
end
16 changes: 8 additions & 8 deletions spec/system/consultation_status_spec.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
}
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end

it "shows that comments will no longer be accepted" do
@@ -51,7 +51,7 @@
}
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end

it "shows the granted status and provides a link to the decision notice" do
@@ -76,7 +76,7 @@
}
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end

it "shows the granted (not required) status and provides a link to the decision notice" do
@@ -89,7 +89,7 @@

expect(page).to have_link(
"View decision notice",
href: "#{Rails.configuration.api_protocol}://default.#{Rails.configuration.api_host}/public/planning_applications/28/decision_notice"
href: "#{Rails.configuration.api_protocol}://default.#{Rails.configuration.api_host}/public/planning_applications/22-00128-LDCP/decision_notice"
)
end
end
@@ -106,7 +106,7 @@
}
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end

it "shows the refused status and provides a link to the decision notice" do
@@ -119,7 +119,7 @@

expect(page).to have_link(
"View decision notice",
href: "#{Rails.configuration.api_protocol}://default.#{Rails.configuration.api_host}/public/planning_applications/28/decision_notice"
href: "#{Rails.configuration.api_protocol}://default.#{Rails.configuration.api_host}/public/planning_applications/22-00128-LDCP/decision_notice"
)
end
end
@@ -140,7 +140,7 @@
)

travel_to(DateTime.new(2023, 11, 4)) do
visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end
end

@@ -170,7 +170,7 @@
)

travel_to(DateTime.new(2023, 11, 24)) do
visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"
end
end

2 changes: 1 addition & 1 deletion spec/system/landing_page_spec.rb
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
end

it "renders the application reference" do
expect(page).to have_content("Application number: 22-00100-LDCP")
expect(page).to have_content("Application number: 22-00128-LDCP")
end

context "within phase-banner" do
6 changes: 3 additions & 3 deletions spec/system/neighbour_submits_comment_spec.rb
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
tags: %w[access other]
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"

click_link "Submit a comment"

@@ -102,7 +102,7 @@
tags: %w[noise other]
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"

click_link "Submit a comment"

@@ -193,7 +193,7 @@
tags: ["acess"]
)

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"

click_link "this link"

6 changes: 3 additions & 3 deletions spec/system/planning_applications_spec.rb
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
stub_successful_get_planning_application
stub_successful_get_local_authority

visit "/planning_applications/28"
visit "/planning_applications/22-00128-LDCP"

expect(page).to have_content("11 Mel Gardens, Southwark, SE16 3RQ")
expect(page).to have_content("Add a chimney stack")
@@ -43,7 +43,7 @@
it "shows 404 if not found" do
stub_unsuccessful_get_planning_application

visit "/planning_applications/100"
visit "/planning_applications/22-99999-LDCP"

expect(page).to have_content("Not Found")
end
@@ -52,7 +52,7 @@
stub_successful_get_private_planning_application
stub_successful_get_local_authority

visit "/planning_applications/29"
visit "/planning_applications/22-00129-LDCP"

expect(page).to have_content("Not Found")
end
6 changes: 3 additions & 3 deletions spec/system/site_notices_spec.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
it "allows the user to see a planning application if it's public" do
stub_successful_get_planning_application

visit "/planning_applications/28/site_notices/download"
visit "/planning_applications/22-00128-LDCP/site_notices/download"

expect(page).to have_content("Download your site notice")
expect(page).to have_content("11 Mel Gardens, Southwark, SE16 3RQ")
@@ -22,7 +22,7 @@
it "shows 404 if not found" do
stub_unsuccessful_get_planning_application

visit "/planning_applications/100/site_notices/download"
visit "/planning_applications/22-99999-LDCP/site_notices/download"

expect(page).to have_content("Not Found")
end
@@ -31,7 +31,7 @@
stub_successful_get_private_planning_application
stub_successful_get_local_authority

visit "/planning_applications/29/site_notices/download"
visit "/planning_applications/22-00129-LDCP/site_notices/download"

expect(page).to have_content("Not Found")
end
4 changes: 3 additions & 1 deletion spec/system/validation_request_spec.rb
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@
it "forbids the user from accessing change requests for a different application" do
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/28/validation_requests?change_access_id=345443543")
.to_return(status: 401, body: "{}")
stub_request(:get, "https://default.bops.test/api/v1/planning_applications/22-00128-LDCP/validation_requests?change_access_id=345443543")
.to_return(status: 401, body: "{}")
stub_successful_get_planning_application

visit "/validation_requests?planning_application_id=28&change_access_id=345443543"
@@ -39,7 +41,7 @@

expect(page).to have_content("11 Mel Gardens, London, SE16 3RQ")
expect(page).to have_content("Date received: 23 April 2021")
expect(page).to have_content("Application number: 22-00100-LDCP")
expect(page).to have_content("Application number: 22-00128-LDCP")
end

it "displays the description of the change request on the change request page" do

0 comments on commit fc31a34

Please sign in to comment.