-
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.
Allow local admin to set determination period day for pre app
- Loading branch information
1 parent
f133f46
commit d3e7d8d
Showing
13 changed files
with
245 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationTypeOverrides | ||
include StoreModel::Model | ||
|
||
attribute :code, :string | ||
attribute :determination_period_days, :integer | ||
|
||
validates :determination_period_days, presence: true | ||
validates :determination_period_days, numericality: {only_integer: true} | ||
validates :determination_period_days, numericality: {greater_than_or_equal_to: 1} | ||
validates :determination_period_days, numericality: {less_than_or_equal_to: 99} | ||
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
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 |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
email_address: "[email protected]" | ||
feedback_email: "[email protected]" | ||
press_notice_email: "[email protected]" | ||
application_type_overrides: | ||
- code: "preApp" | ||
determination_period_days: 30 | ||
|
||
- subdomain: "southwark" | ||
council_code: "SWK" | ||
|
@@ -22,6 +25,9 @@ | |
email_address: "[email protected]" | ||
feedback_email: "[email protected]" | ||
press_notice_email: "[email protected]" | ||
application_type_overrides: | ||
- code: "preApp" | ||
determination_period_days: 30 | ||
|
||
- subdomain: "buckinghamshire" | ||
council_code: "BUC" | ||
|
@@ -34,3 +40,6 @@ | |
email_address: "[email protected]" | ||
feedback_email: "[email protected]" | ||
press_notice_email: "[email protected]" | ||
application_type_overrides: | ||
- code: "preApp" | ||
determination_period_days: 30 |
36 changes: 36 additions & 0 deletions
36
engines/bops_admin/app/controllers/bops_admin/determination_periods_controller.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,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module BopsAdmin | ||
class DeterminationPeriodsController < ApplicationController | ||
def edit | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def update | ||
respond_to do |format| | ||
if current_local_authority.update(application_type_overrides_params, :application_type_overrides) | ||
format.html do | ||
redirect_to setting_path, notice: t(".success") | ||
end | ||
else | ||
format.html { render :edit } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def application_type_overrides_params | ||
params.require(:local_authority).permit(application_type_overrides_attributes:) | ||
end | ||
|
||
def application_type_overrides_attributes | ||
[ | ||
:determination_period_days, | ||
code: :preApp | ||
] | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
engines/bops_admin/app/controllers/bops_admin/settings_controller.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module BopsAdmin | ||
class SettingsController < ApplicationController | ||
before_action :set_application_type_overrides | ||
|
||
def show | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_application_type_overrides | ||
@application_type_overrides = current_local_authority.application_type_overrides | ||
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
26 changes: 26 additions & 0 deletions
26
engines/bops_admin/app/views/bops_admin/determination_periods/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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<% content_for :page_title do %> | ||
<%= t(".determination_period") %> - <%= t("page_title") %> | ||
<% end %> | ||
|
||
<% add_parent_breadcrumb_link "Home", root_path %> | ||
|
||
<% content_for :title, t(".determination_period") %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<%= form_with model: current_local_authority, url: [:setting, :determination_period] do |form| %> | ||
<%= form.govuk_error_summary %> | ||
|
||
<%= form.fields_for :application_type_overrides do |ff| %> | ||
<%= ff.govuk_text_field :determination_period_days, width: 5, | ||
label: {text: t(".set_determination_period"), size: "l"}, | ||
hint: {text: t(".hint")}, | ||
suffix_text: t(".days"), | ||
value: current_local_authority&.application_type_overrides&.map(&:determination_period_days) %> | ||
<% end %> | ||
|
||
<%= form.govuk_submit(t(".save")) %> | ||
<%= govuk_button_link_to t("back"), setting_path, secondary: true %> | ||
<% end %> | ||
</div> | ||
</div> |
18 changes: 18 additions & 0 deletions
18
engines/bops_admin/app/views/bops_admin/settings/show.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% content_for :page_title do %> | ||
<%= t(".application_settings") %> - <%= t("page_title") %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full"> | ||
<h1 class="govuk-heading-l"><%= t(".application_settings") %></h1> | ||
|
||
<h2 class="govuk-heading-m"><%= t(".determination_period") %></h2> | ||
<%= govuk_summary_list do |summary_list| | ||
summary_list.with_row do |row| | ||
row.with_key { t(".pre_app_determination_period") } | ||
row.with_value { t(".determination_period_including_bank_holidays", count: @application_type_overrides.map(&:determination_period_days).join(" ")) if @application_type_overrides.map(&:determination_period_days).join(" ") } | ||
row.with_action(text: t(".change"), href: url_for([:edit, :setting, :determination_period]), visually_hidden_text: t(".determination_period")) | ||
end | ||
end %> | ||
</div> | ||
</div> |
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
76 changes: 76 additions & 0 deletions
76
engines/bops_admin/spec/system/application_settings_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,76 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Profile", type: :system do | ||
let(:local_authority) { create(:local_authority, :default, :with_api_user) } | ||
let(:user) { create(:user, :administrator, local_authority:) } | ||
|
||
before do | ||
sign_in(user) | ||
end | ||
|
||
it "shows the council as active on the dashboard" do | ||
visit "/admin/dashboard" | ||
expect(page).to have_content("Active") | ||
end | ||
|
||
it "allows the administrator to view the determination period days" do | ||
visit "/admin/setting" | ||
expect(page).to have_selector("h1", text: "Application settings") | ||
expect(page).to have_selector("h2", text: "Determination period") | ||
|
||
within "dl div:nth-child(1)" do | ||
expect(page).to have_selector("dt", text: "Pre-application determination period") | ||
expect(page).to have_selector("dd", text: "30 days - bank holidays included") | ||
expect(page).to have_selector("dd > a", text: "Change") | ||
|
||
expect(page).to have_link( | ||
"Change", | ||
href: "/admin/setting/determination_period/edit" | ||
) | ||
end | ||
end | ||
|
||
it "allows the administrator to edit determination" do | ||
visit "/admin/setting" | ||
|
||
within "dl div:nth-child(1)" do | ||
expect(page).to have_selector("dt", text: "Pre-application determination period") | ||
expect(page).to have_selector("dd", text: "30 days - bank holidays included") | ||
click_link "Change" | ||
end | ||
|
||
# Set determination period | ||
expect(page).to have_selector(".govuk-label", text: "Set determination period") | ||
expect(page).to have_selector("div.govuk-hint", text: "Choose the length of the determination period for the pre-application type.") | ||
|
||
fill_in "Set determination period", with: "" | ||
click_button "Save" | ||
|
||
expect(page).to have_content("can't be blank") | ||
|
||
fill_in "Set determination period", with: "not an integer" | ||
click_button "Save" | ||
|
||
expect(page).to have_content("is not a number") | ||
|
||
fill_in "Set determination period", with: "1.1" | ||
click_button "Save" | ||
|
||
expect(page).to have_content("must be an integer") | ||
|
||
fill_in "Set determination period", with: "0" | ||
click_button "Save" | ||
expect(page).to have_content("must be greater than or equal to 1") | ||
|
||
fill_in "Set determination period", with: "100" | ||
click_button "Save" | ||
expect(page).to have_content("must be less than or equal to 99") | ||
|
||
fill_in "Set determination period", with: "25" | ||
click_button "Save" | ||
|
||
expect(page).to have_content("Determination period successfully updated") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,14 @@ | |
feedback_email { "[email protected]" } | ||
email_reply_to_id { "4896bb50-4f4c-4b4d-ad67-2caddddde125" } | ||
active { true } | ||
application_type_overrides do | ||
[ | ||
{ | ||
code: :preApp, | ||
determination_period_days: 30 | ||
} | ||
] | ||
end | ||
|
||
trait :default do | ||
council_code { "PlanX" } | ||
|