Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

964 lines
36 KiB

CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
require "rails_helper"
RSpec.describe Location, type: :model do
before do
Rails.application.load_seed
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
describe "#new" do
let(:location) { FactoryBot.build(:location) }
before do
stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
it "belongs to an organisation" do
expect(location.scheme).to be_a(Scheme)
end
it "infers the local authority" do
location.postcode = "M1 1AE"
location.save!
expect(location.location_code).to eq("E08000003")
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
describe "#postcode" do
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
let(:location) { FactoryBot.build(:location) }
it "does not add an error if postcode is valid" do
location.postcode = "M1 1AE"
location.save!
expect(location.errors).to be_empty
end
it "does add an error when the postcode is invalid" do
location.postcode = "invalid"
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
location.valid?(:postcode)
expect(location.errors.count).to eq(1)
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
it "does add an error when the postcode is missing" do
location.postcode = nil
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
location.valid?(:postcode)
expect(location.errors.count).to eq(1)
end
end
describe "#local_authority" do
let(:location) { FactoryBot.build(:location) }
it "does add an error when the local authority is invalid" do
location.location_admin_district = nil
location.valid?(:location_admin_district)
expect(location.errors.count).to eq(1)
end
end
describe "#local_authorities_for_current_year" do
context "when the current collection year is 22/23" do
let(:today) { Time.zone.local(2022, 4, 1) }
before do
Timecop.freeze(today)
end
after do
Timecop.unfreeze
end
it "returns a list of local authorities" do
expect(described_class.local_authorities_for_current_year).to eq({
"E07000223" => "Adur",
"E07000026" => "Allerdale",
"E07000032" => "Amber Valley",
"E07000224" => "Arun",
"E07000170" => "Ashfield",
"E07000105" => "Ashford",
"E07000200" => "Babergh",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
"E08000016" => "Barnsley",
"E07000027" => "Barrow-in-Furness",
"E07000066" => "Basildon",
"E07000084" => "Basingstoke and Deane",
"E07000171" => "Bassetlaw",
"E06000022" => "Bath and North East Somerset",
"E06000055" => "Bedford",
"E09000004" => "Bexley",
"E08000025" => "Birmingham",
"E07000129" => "Blaby",
"E06000008" => "Blackburn with Darwen",
"E06000009" => "Blackpool",
"E07000033" => "Bolsover",
"E08000001" => "Bolton",
"E07000136" => "Boston",
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000036" => "Bracknell Forest",
"E08000032" => "Bradford",
"E07000067" => "Braintree",
"E07000143" => "Breckland",
"E09000005" => "Brent",
"E07000068" => "Brentwood",
"E06000043" => "Brighton and Hove",
"E06000023" => "Bristol, City of",
"E07000144" => "Broadland",
"E09000006" => "Bromley",
"E07000234" => "Bromsgrove",
"E07000095" => "Broxbourne",
"E07000172" => "Broxtowe",
"E06000060" => "Buckinghamshire",
"E07000117" => "Burnley",
"E08000002" => "Bury",
"E08000033" => "Calderdale",
"E07000008" => "Cambridge",
"E09000007" => "Camden",
"E07000192" => "Cannock Chase",
"E07000106" => "Canterbury",
"E07000028" => "Carlisle",
"E07000069" => "Castle Point",
"E06000056" => "Central Bedfordshire",
"E07000130" => "Charnwood",
"E07000070" => "Chelmsford",
"E07000078" => "Cheltenham",
"E07000177" => "Cherwell",
"E06000049" => "Cheshire East",
"E06000050" => "Cheshire West and Chester",
"E07000034" => "Chesterfield",
"E07000225" => "Chichester",
"E07000118" => "Chorley",
"E09000001" => "City of London",
"E07000071" => "Colchester",
"E07000029" => "Copeland",
"E07000150" => "Corby",
"E06000052" => "Cornwall",
"E07000079" => "Cotswold",
"E06000047" => "County Durham",
"E08000026" => "Coventry",
"E07000163" => "Craven",
"E07000226" => "Crawley",
"E09000008" => "Croydon",
"E07000096" => "Dacorum",
"E06000005" => "Darlington",
"E07000107" => "Dartford",
"E07000151" => "Daventry",
"E06000015" => "Derby",
"E07000035" => "Derbyshire Dales",
"E08000017" => "Doncaster",
"E06000059" => "Dorset",
"E07000108" => "Dover",
"E08000027" => "Dudley",
"E09000009" => "Ealing",
"E07000009" => "East Cambridgeshire",
"E07000040" => "East Devon",
"E07000085" => "East Hampshire",
"E07000242" => "East Hertfordshire",
"E07000137" => "East Lindsey",
"E07000152" => "East Northamptonshire",
"E06000011" => "East Riding of Yorkshire",
"E07000193" => "East Staffordshire",
"E07000244" => "East Suffolk",
"E07000061" => "Eastbourne",
"E07000086" => "Eastleigh",
"E07000030" => "Eden",
"E07000207" => "Elmbridge",
"E09000010" => "Enfield",
"E07000072" => "Epping Forest",
"E07000208" => "Epsom and Ewell",
"E07000036" => "Erewash",
"E07000041" => "Exeter",
"E07000087" => "Fareham",
"E07000010" => "Fenland",
"E07000112" => "Folkestone and Hythe",
"E07000080" => "Forest of Dean",
"E07000119" => "Fylde",
"E08000037" => "Gateshead",
"E07000173" => "Gedling",
"E07000081" => "Gloucester",
"E07000088" => "Gosport",
"E07000109" => "Gravesham",
"E07000145" => "Great Yarmouth",
"E09000011" => "Greenwich",
"E07000209" => "Guildford",
"E09000012" => "Hackney",
"E06000006" => "Halton",
"E07000164" => "Hambleton",
"E09000013" => "Hammersmith and Fulham",
"E07000131" => "Harborough",
"E09000014" => "Haringey",
"E07000073" => "Harlow",
"E07000165" => "Harrogate",
"E09000015" => "Harrow",
"E07000089" => "Hart",
"E06000001" => "Hartlepool",
"E07000062" => "Hastings",
"E07000090" => "Havant",
"E09000016" => "Havering",
"E06000019" => "Herefordshire, County of",
"E07000098" => "Hertsmere",
"E07000037" => "High Peak",
"E09000017" => "Hillingdon",
"E07000132" => "Hinckley and Bosworth",
"E07000227" => "Horsham",
"E09000018" => "Hounslow",
"E07000011" => "Huntingdonshire",
"E07000120" => "Hyndburn",
"E07000202" => "Ipswich",
"E06000046" => "Isle of Wight",
"E06000053" => "Isles of Scilly",
"E09000019" => "Islington",
"E09000020" => "Kensington and Chelsea",
"E07000153" => "Kettering",
"E07000146" => "King’s Lynn and West Norfolk",
"E06000010" => "Kingston upon Hull, City of",
"E09000021" => "Kingston upon Thames",
"E08000034" => "Kirklees",
"E08000011" => "Knowsley",
"E09000022" => "Lambeth",
"E07000121" => "Lancaster",
"E08000035" => "Leeds",
"E06000016" => "Leicester",
"E07000063" => "Lewes",
"E09000023" => "Lewisham",
"E07000194" => "Lichfield",
"E07000138" => "Lincoln",
"E08000012" => "Liverpool",
"E06000032" => "Luton",
"E07000110" => "Maidstone",
"E07000074" => "Maldon",
"E07000235" => "Malvern Hills",
"E08000003" => "Manchester",
"E07000174" => "Mansfield",
"E06000035" => "Medway",
"E07000133" => "Melton",
"E07000187" => "Mendip",
"E09000024" => "Merton",
"E07000042" => "Mid Devon",
"E07000203" => "Mid Suffolk",
"E07000228" => "Mid Sussex",
"E06000002" => "Middlesbrough",
"E06000042" => "Milton Keynes",
"E07000210" => "Mole Valley",
"E07000091" => "New Forest",
"E07000175" => "Newark and Sherwood",
"E08000021" => "Newcastle upon Tyne",
"E07000195" => "Newcastle-under-Lyme",
"E09000025" => "Newham",
"E07000043" => "North Devon",
"E07000038" => "North East Derbyshire",
"E06000012" => "North East Lincolnshire",
"E07000099" => "North Hertfordshire",
"E07000139" => "North Kesteven",
"E06000013" => "North Lincolnshire",
"E07000147" => "North Norfolk",
"E06000024" => "North Somerset",
"E08000022" => "North Tyneside",
"E07000218" => "North Warwickshire",
"E07000134" => "North West Leicestershire",
"E07000154" => "Northampton",
"E06000057" => "Northumberland",
"E07000148" => "Norwich",
"E06000018" => "Nottingham",
"E07000219" => "Nuneaton and Bedworth",
"E07000135" => "Oadby and Wigston",
"E08000004" => "Oldham",
"E07000178" => "Oxford",
"E07000122" => "Pendle",
"E06000031" => "Peterborough",
"E06000026" => "Plymouth",
"E06000044" => "Portsmouth",
"E07000123" => "Preston",
"E06000038" => "Reading",
"E09000026" => "Redbridge",
"E06000003" => "Redcar and Cleveland",
"E07000236" => "Redditch",
"E07000211" => "Reigate and Banstead",
"E07000124" => "Ribble Valley",
"E09000027" => "Richmond upon Thames",
"E07000166" => "Richmondshire",
"E08000005" => "Rochdale",
"E07000075" => "Rochford",
"E07000125" => "Rossendale",
"E07000064" => "Rother",
"E08000018" => "Rotherham",
"E07000220" => "Rugby",
"E07000212" => "Runnymede",
"E07000176" => "Rushcliffe",
"E07000092" => "Rushmoor",
"E06000017" => "Rutland",
"E07000167" => "Ryedale",
"E08000006" => "Salford",
"E08000028" => "Sandwell",
"E07000168" => "Scarborough",
"E07000188" => "Sedgemoor",
"E08000014" => "Sefton",
"E07000169" => "Selby",
"E07000111" => "Sevenoaks",
"E08000019" => "Sheffield",
"E06000051" => "Shropshire",
"E06000039" => "Slough",
"E08000029" => "Solihull",
"E07000246" => "Somerset West and Taunton",
"E07000012" => "South Cambridgeshire",
"E07000039" => "South Derbyshire",
"E06000025" => "South Gloucestershire",
"E07000044" => "South Hams",
"E07000140" => "South Holland",
"E07000141" => "South Kesteven",
"E07000031" => "South Lakeland",
"E07000149" => "South Norfolk",
"E07000155" => "South Northamptonshire",
"E07000179" => "South Oxfordshire",
"E07000126" => "South Ribble",
"E07000189" => "South Somerset",
"E07000196" => "South Staffordshire",
"E08000023" => "South Tyneside",
"E06000045" => "Southampton",
"E06000033" => "Southend-on-Sea",
"E09000028" => "Southwark",
"E07000213" => "Spelthorne",
"E07000240" => "St Albans",
"E08000013" => "St. Helens",
"E07000197" => "Stafford",
"E07000198" => "Staffordshire Moorlands",
"E07000243" => "Stevenage",
"E08000007" => "Stockport",
"E06000004" => "Stockton-on-Tees",
"E06000021" => "Stoke-on-Trent",
"E07000221" => "Stratford-on-Avon",
"E07000082" => "Stroud",
"E08000024" => "Sunderland",
"E07000214" => "Surrey Heath",
"E09000029" => "Sutton",
"E07000113" => "Swale",
"E06000030" => "Swindon",
"E08000008" => "Tameside",
"E07000199" => "Tamworth",
"E07000215" => "Tandridge",
"E07000045" => "Teignbridge",
"E06000020" => "Telford and Wrekin",
"E07000076" => "Tendring",
"E07000093" => "Test Valley",
"E07000083" => "Tewkesbury",
"E07000114" => "Thanet",
"E07000102" => "Three Rivers",
"E06000034" => "Thurrock",
"E07000115" => "Tonbridge and Malling",
"E06000027" => "Torbay",
"E07000046" => "Torridge",
"E09000030" => "Tower Hamlets",
"E08000009" => "Trafford",
"E07000116" => "Tunbridge Wells",
"E07000077" => "Uttlesford",
"E07000180" => "Vale of White Horse",
"E08000036" => "Wakefield",
"E08000030" => "Walsall",
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E06000007" => "Warrington",
"E07000222" => "Warwick",
"E07000103" => "Watford",
"E07000216" => "Waverley",
"E07000065" => "Wealden",
"E07000156" => "Wellingborough",
"E07000241" => "Welwyn Hatfield",
"E06000037" => "West Berkshire",
"E07000047" => "West Devon",
"E07000127" => "West Lancashire",
"E07000142" => "West Lindsey",
"E07000181" => "West Oxfordshire",
"E07000245" => "West Suffolk",
"E09000033" => "Westminster",
"E08000010" => "Wigan",
"E06000054" => "Wiltshire",
"E07000094" => "Winchester",
"E06000040" => "Windsor and Maidenhead",
"E08000015" => "Wirral",
"E07000217" => "Woking",
"E06000041" => "Wokingham",
"E08000031" => "Wolverhampton",
"E07000237" => "Worcester",
"E07000229" => "Worthing",
"E07000238" => "Wychavon",
"E07000128" => "Wyre",
"E07000239" => "Wyre Forest",
"E06000014" => "York",
})
end
end
context "when the current collection year is 23/24" do
let(:today) { Time.zone.local(2023, 5, 1) }
before do
Timecop.freeze(today)
end
after do
Timecop.unfreeze
end
it "returns a list of local authorities" do
expect(described_class.local_authorities_for_current_year).to eq({
"E07000223" => "Adur",
"E07000032" => "Amber Valley",
"E07000224" => "Arun",
"E07000170" => "Ashfield",
"E07000105" => "Ashford",
"E07000200" => "Babergh",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
"E08000016" => "Barnsley",
"E07000066" => "Basildon",
"E07000084" => "Basingstoke and Deane",
"E07000171" => "Bassetlaw",
"E06000022" => "Bath and North East Somerset",
"E06000055" => "Bedford",
"E09000004" => "Bexley",
"E08000025" => "Birmingham",
"E07000129" => "Blaby",
"E06000008" => "Blackburn with Darwen",
"E06000009" => "Blackpool",
"E07000033" => "Bolsover",
"E08000001" => "Bolton",
"E07000136" => "Boston",
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000036" => "Bracknell Forest",
"E08000032" => "Bradford",
"E07000067" => "Braintree",
"E07000143" => "Breckland",
"E09000005" => "Brent",
"E07000068" => "Brentwood",
"E06000043" => "Brighton and Hove",
"E06000023" => "Bristol, City of",
"E07000144" => "Broadland",
"E09000006" => "Bromley",
"E07000234" => "Bromsgrove",
"E07000095" => "Broxbourne",
"E07000172" => "Broxtowe",
"E06000060" => "Buckinghamshire",
"E07000117" => "Burnley",
"E08000002" => "Bury",
"E08000033" => "Calderdale",
"E07000008" => "Cambridge",
"E09000007" => "Camden",
"E07000192" => "Cannock Chase",
"E07000106" => "Canterbury",
"E07000069" => "Castle Point",
"E06000056" => "Central Bedfordshire",
"E07000130" => "Charnwood",
"E07000070" => "Chelmsford",
"E07000078" => "Cheltenham",
"E07000177" => "Cherwell",
"E06000049" => "Cheshire East",
"E06000050" => "Cheshire West and Chester",
"E07000034" => "Chesterfield",
"E07000225" => "Chichester",
"E07000118" => "Chorley",
"E09000001" => "City of London",
"E07000071" => "Colchester",
"E07000150" => "Corby",
"E06000052" => "Cornwall",
"E07000079" => "Cotswold",
"E06000047" => "County Durham",
"E08000026" => "Coventry",
"E07000226" => "Crawley",
"E09000008" => "Croydon",
"E06000063" => "Cumberland",
"E07000096" => "Dacorum",
"E06000005" => "Darlington",
"E07000107" => "Dartford",
"E07000151" => "Daventry",
"E06000015" => "Derby",
"E07000035" => "Derbyshire Dales",
"E08000017" => "Doncaster",
"E06000059" => "Dorset",
"E07000108" => "Dover",
"E08000027" => "Dudley",
"E09000009" => "Ealing",
"E07000009" => "East Cambridgeshire",
"E07000040" => "East Devon",
"E07000085" => "East Hampshire",
"E07000242" => "East Hertfordshire",
"E07000137" => "East Lindsey",
"E07000152" => "East Northamptonshire",
"E06000011" => "East Riding of Yorkshire",
"E07000193" => "East Staffordshire",
"E07000244" => "East Suffolk",
"E07000061" => "Eastbourne",
"E07000086" => "Eastleigh",
"E07000207" => "Elmbridge",
"E09000010" => "Enfield",
"E07000072" => "Epping Forest",
"E07000208" => "Epsom and Ewell",
"E07000036" => "Erewash",
"E07000041" => "Exeter",
"E07000087" => "Fareham",
"E07000010" => "Fenland",
"E07000112" => "Folkestone and Hythe",
"E07000080" => "Forest of Dean",
"E07000119" => "Fylde",
"E08000037" => "Gateshead",
"E07000173" => "Gedling",
"E07000081" => "Gloucester",
"E07000088" => "Gosport",
"E07000109" => "Gravesham",
"E07000145" => "Great Yarmouth",
"E09000011" => "Greenwich",
"E07000209" => "Guildford",
"E09000012" => "Hackney",
"E06000006" => "Halton",
"E09000013" => "Hammersmith and Fulham",
"E07000131" => "Harborough",
"E09000014" => "Haringey",
"E07000073" => "Harlow",
"E09000015" => "Harrow",
"E07000089" => "Hart",
"E06000001" => "Hartlepool",
"E07000062" => "Hastings",
"E07000090" => "Havant",
"E09000016" => "Havering",
"E06000019" => "Herefordshire, County of",
"E07000098" => "Hertsmere",
"E07000037" => "High Peak",
"E09000017" => "Hillingdon",
"E07000132" => "Hinckley and Bosworth",
"E07000227" => "Horsham",
"E09000018" => "Hounslow",
"E07000011" => "Huntingdonshire",
"E07000120" => "Hyndburn",
"E07000202" => "Ipswich",
"E06000046" => "Isle of Wight",
"E06000053" => "Isles of Scilly",
"E09000019" => "Islington",
"E09000020" => "Kensington and Chelsea",
"E07000153" => "Kettering",
"E07000146" => "King’s Lynn and West Norfolk",
"E06000010" => "Kingston upon Hull, City of",
"E09000021" => "Kingston upon Thames",
"E08000034" => "Kirklees",
"E08000011" => "Knowsley",
"E09000022" => "Lambeth",
"E07000121" => "Lancaster",
"E08000035" => "Leeds",
"E06000016" => "Leicester",
"E07000063" => "Lewes",
"E09000023" => "Lewisham",
"E07000194" => "Lichfield",
"E07000138" => "Lincoln",
"E08000012" => "Liverpool",
"E06000032" => "Luton",
"E07000110" => "Maidstone",
"E07000074" => "Maldon",
"E07000235" => "Malvern Hills",
"E08000003" => "Manchester",
"E07000174" => "Mansfield",
"E06000035" => "Medway",
"E07000133" => "Melton",
"E09000024" => "Merton",
"E07000042" => "Mid Devon",
"E07000203" => "Mid Suffolk",
"E07000228" => "Mid Sussex",
"E06000002" => "Middlesbrough",
"E06000042" => "Milton Keynes",
"E07000210" => "Mole Valley",
"E07000091" => "New Forest",
"E07000175" => "Newark and Sherwood",
"E08000021" => "Newcastle upon Tyne",
"E07000195" => "Newcastle-under-Lyme",
"E09000025" => "Newham",
"E07000043" => "North Devon",
"E07000038" => "North East Derbyshire",
"E06000012" => "North East Lincolnshire",
"E07000099" => "North Hertfordshire",
"E07000139" => "North Kesteven",
"E06000013" => "North Lincolnshire",
"E07000147" => "North Norfolk",
"E06000024" => "North Somerset",
"E08000022" => "North Tyneside",
"E07000218" => "North Warwickshire",
"E07000134" => "North West Leicestershire",
"E06000065" => "North Yorkshire",
"E07000154" => "Northampton",
"E06000057" => "Northumberland",
"E07000148" => "Norwich",
"E06000018" => "Nottingham",
"E07000219" => "Nuneaton and Bedworth",
"E07000135" => "Oadby and Wigston",
"E08000004" => "Oldham",
"E07000178" => "Oxford",
"E07000122" => "Pendle",
"E06000031" => "Peterborough",
"E06000026" => "Plymouth",
"E06000044" => "Portsmouth",
"E07000123" => "Preston",
"E06000038" => "Reading",
"E09000026" => "Redbridge",
"E06000003" => "Redcar and Cleveland",
"E07000236" => "Redditch",
"E07000211" => "Reigate and Banstead",
"E07000124" => "Ribble Valley",
"E09000027" => "Richmond upon Thames",
"E08000005" => "Rochdale",
"E07000075" => "Rochford",
"E07000125" => "Rossendale",
"E07000064" => "Rother",
"E08000018" => "Rotherham",
"E07000220" => "Rugby",
"E07000212" => "Runnymede",
"E07000176" => "Rushcliffe",
"E07000092" => "Rushmoor",
"E06000017" => "Rutland",
"E08000006" => "Salford",
"E08000028" => "Sandwell",
"E08000014" => "Sefton",
"E07000111" => "Sevenoaks",
"E08000019" => "Sheffield",
"E06000051" => "Shropshire",
"E06000039" => "Slough",
"E08000029" => "Solihull",
"E06000066" => "Somerset",
"E07000012" => "South Cambridgeshire",
"E07000039" => "South Derbyshire",
"E06000025" => "South Gloucestershire",
"E07000044" => "South Hams",
"E07000140" => "South Holland",
"E07000141" => "South Kesteven",
"E07000149" => "South Norfolk",
"E07000155" => "South Northamptonshire",
"E07000179" => "South Oxfordshire",
"E07000126" => "South Ribble",
"E07000196" => "South Staffordshire",
"E08000023" => "South Tyneside",
"E06000045" => "Southampton",
"E06000033" => "Southend-on-Sea",
"E09000028" => "Southwark",
"E07000213" => "Spelthorne",
"E07000240" => "St Albans",
"E08000013" => "St. Helens",
"E07000197" => "Stafford",
"E07000198" => "Staffordshire Moorlands",
"E07000243" => "Stevenage",
"E08000007" => "Stockport",
"E06000004" => "Stockton-on-Tees",
"E06000021" => "Stoke-on-Trent",
"E07000221" => "Stratford-on-Avon",
"E07000082" => "Stroud",
"E08000024" => "Sunderland",
"E07000214" => "Surrey Heath",
"E09000029" => "Sutton",
"E07000113" => "Swale",
"E06000030" => "Swindon",
"E08000008" => "Tameside",
"E07000199" => "Tamworth",
"E07000215" => "Tandridge",
"E07000045" => "Teignbridge",
"E06000020" => "Telford and Wrekin",
"E07000076" => "Tendring",
"E07000093" => "Test Valley",
"E07000083" => "Tewkesbury",
"E07000114" => "Thanet",
"E07000102" => "Three Rivers",
"E06000034" => "Thurrock",
"E07000115" => "Tonbridge and Malling",
"E06000027" => "Torbay",
"E07000046" => "Torridge",
"E09000030" => "Tower Hamlets",
"E08000009" => "Trafford",
"E07000116" => "Tunbridge Wells",
"E07000077" => "Uttlesford",
"E07000180" => "Vale of White Horse",
"E08000036" => "Wakefield",
"E08000030" => "Walsall",
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E06000007" => "Warrington",
"E07000222" => "Warwick",
"E07000103" => "Watford",
"E07000216" => "Waverley",
"E07000065" => "Wealden",
"E07000156" => "Wellingborough",
"E07000241" => "Welwyn Hatfield",
"E06000037" => "West Berkshire",
"E07000047" => "West Devon",
"E07000127" => "West Lancashire",
"E07000142" => "West Lindsey",
"E07000181" => "West Oxfordshire",
"E07000245" => "West Suffolk",
"E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness",
"E08000010" => "Wigan",
"E06000054" => "Wiltshire",
"E07000094" => "Winchester",
"E06000040" => "Windsor and Maidenhead",
"E08000015" => "Wirral",
"E07000217" => "Woking",
"E06000041" => "Wokingham",
"E08000031" => "Wolverhampton",
"E07000237" => "Worcester",
"E07000229" => "Worthing",
"E07000238" => "Wychavon",
"E07000128" => "Wyre",
"E07000239" => "Wyre Forest",
"E06000014" => "York",
})
end
end
end
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
describe "#name" do
let(:location) { FactoryBot.build(:location) }
it "does not add an error when the name is invalid" do
location.name = nil
location.valid?
expect(location.errors.count).to eq(0)
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end
describe "#units" do
let(:location) { FactoryBot.build(:location) }
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
it "does add an error when the number of units is invalid" do
location.units = nil
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
location.valid?(:units)
expect(location.errors.count).to eq(1)
end
end
describe "#type_of_unit" do
let(:location) { FactoryBot.build(:location) }
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
it "does add an error when the type of unit is invalid" do
location.type_of_unit = nil
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
location.valid?(:type_of_unit)
expect(location.errors.count).to eq(1)
end
end
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
describe "#mobility_type" do
let(:location) { FactoryBot.build(:location) }
it "does add an error when the mobility type is invalid" do
location.mobility_type = nil
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
location.valid?(:mobility_type)
expect(location.errors.count).to eq(1)
end
end
describe "#availability" do
let(:location) { FactoryBot.build(:location) }
it "does add an error when the availability is invalid" do
location.startdate = Time.zone.local(1, 1, 1)
location.valid?(:startdate)
expect(location.errors.count).to eq(1)
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
end
end
describe "paper trail" do
let(:location) { FactoryBot.create(:location) }
let!(:name) { location.name }
it "creates a record of changes to a log" do
expect { location.update!(name: "new test name") }.to change(location.versions, :count).by(1)
end
it "allows lettings logs to be restored to a previous version" do
location.update!(name: "new test name")
expect(location.paper_trail.previous_version.name).to eq(name)
end
end
describe "scopes" do
before do
FactoryBot.create(:location, name: "ABC", postcode: "NW1 8RR", startdate: Time.zone.today)
FactoryBot.create(:location, name: "XYZ", postcode: "SE1 6HJ", startdate: Time.zone.today + 1.day)
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
FactoryBot.create(:location, name: "GHQ", postcode: "EW1 7JK", startdate: Time.zone.today - 1.day, units: nil)
FactoryBot.create(:location, name: "GHQ", postcode: "EW1 7JK", startdate: nil)
end
context "when searching by name" do
it "returns case insensitive matching records" do
expect(described_class.search_by_name("abc").count).to eq(1)
expect(described_class.search_by_name("AbC").count).to eq(1)
end
end
context "when searching by postcode" do
it "returns case insensitive matching records" do
expect(described_class.search_by_postcode("se1 6hj").count).to eq(1)
expect(described_class.search_by_postcode("SE1 6HJ").count).to eq(1)
end
end
context "when searching by all searchable field" do
it "returns case insensitive matching records" do
expect(described_class.search_by("aBc").count).to eq(1)
expect(described_class.search_by("nw18rr").count).to eq(1)
end
end
context "when filtering by started locations" do
it "returns only locations that started today or earlier" do
expect(described_class.started.count).to eq(3)
end
end
context "when filtering by active locations" do
Cldc 1669 add location redesign (#1034) * feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>
2 years ago
it "returns only locations that started today or earlier and are complete (and so confirmed)" do
expect(described_class.active.count).to eq(2)
end
end
end
describe "status" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
let(:location) { FactoryBot.build(:location, startdate: Time.zone.local(2022, 4, 1)) }
before do
Timecop.freeze(2022, 6, 7)
end
after do
Timecop.unfreeze
end
CLDC-1666 Update locations table (#987) * feat: remove redundant cols from locations table * feat: add status col to locations table * test: start adding status tag tests * test: pick the simplest format for the tag helper tests * feat: make the locations table (plus related content above & below) 2/3 width * feat: add incomplete to location status method * test: all status tag helpers * test: update test text to match what's being tested * test: update locations list test in locations_controller_spec.rb * test: update locations list test in schemes feature tests * test: that status=incomplete when mandatory info is missing * feat: simplify logic for incomplete status Co-authored-by: James Rose <james@jbpr.net> * feat: hide new locations table layout behind feature flag * feat: use route helpers to get scheme_location path * feat: simplify "scheme_id: @scheme.id" to "@scheme" * feat: reference location, not @location, in scheme_location_path * feat: reorder postcode and code in locations table * feat: change ' ' to "" in location_spec * feat: update wording and ordering for 'view location details' page * test: re-add tests for locations page when new layout not enabled * test: check for mobility_type and location_admin_district in locations_controller as support user * test: update locations helper test to match new field naming and ordering * feat: always scale locations list by 2/3, not just when new layout used * feat: scale the scheme details page by 2/3 to match the locations list page * feat: only make scheme details and locations pages 2/3 scale if feature toggle on * test: mock new locations layout feature toggle in tests * feat: use the existing location_toggle_enabled instead of new_locations_table_layout_enabled * refactor: don't use html inside ruby in locations index page * refactor: use Rails routes in all places in locations index page * style: lint * feat: move logic from views/schemes/show into schemes_helper * refactor: make consistent the removal of fields from SchemeHelper base_attributes * test: improvements to tests * test: make 'returns correct display attributes' tests sensible * test: check scheme toggle off => no scheme status shown * style: correct indentation in spec/helpers/schemes_helper_spec.rb * test: that when owning = managing, "Organisation providing support" hidden * style: lint code * test: don't set scheme id explicitly in schemes_helper_spec * style: reorder tag helper spec to match tag helper * refactor: ensure display_scheme_attributes always takes user type * test: make location incomplete status depend on location.confirmed * test: add missing location validations for nil postcode & mobility type Co-authored-by: James Rose <james@jbpr.net>
2 years ago
context "when location is not confirmed" do
it "returns incomplete " do
location.confirmed = false
expect(location.status).to eq(:incomplete)
end
end
context "when there have not been any previous deactivations" do
it "returns active if the location has no deactivation records" do
expect(location.status).to eq(:active)
end
it "returns deactivating soon if deactivation_date is in the future" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 8, 8), location:)
location.save!
expect(location.status).to eq(:deactivating_soon)
end
it "returns deactivated if deactivation_date is in the past" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 6), location:)
location.save!
expect(location.status).to eq(:deactivated)
end
it "returns deactivated if deactivation_date is today" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 7), location:)
location.save!
expect(location.status).to eq(:deactivated)
end
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
it "returns reactivating soon if the location has a future reactivation date" do
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 7), reactivation_date: Time.zone.local(2022, 6, 8), location:)
location.save!
expect(location.status).to eq(:reactivating_soon)
end
it "returns activating soon if the location has a future startdate" do
location.startdate = Time.zone.local(2022, 7, 7)
location.save!
expect(location.status).to eq(:activating_soon)
end
end
context "when there have been previous deactivations" do
before do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 5, 4), reactivation_date: Time.zone.local(2022, 6, 5), location:)
location.save!
end
it "returns active if the location has no relevant deactivation records" do
expect(location.status).to eq(:active)
end
it "returns deactivating soon if deactivation_date is in the future" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 8, 8), location:)
location.save!
expect(location.status).to eq(:deactivating_soon)
end
it "returns deactivated if deactivation_date is in the past" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 6), location:)
location.save!
expect(location.status).to eq(:deactivated)
end
it "returns deactivated if deactivation_date is today" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 7), location:)
location.save!
expect(location.status).to eq(:deactivated)
end
Cldc 1671 deactivate scheme (#980) * feat: wip update scheme summary page * feat: wip deactivate scheme schemes page * feat: wip toggle active page * feat: wip set deactivation_date to a datetime (to be more specific times later_ * Change conditional question controller to accommodate all models * feat: add specific datetimes for deactivation * feat: correct date and add notice * feat: wip error behaviour * feat: wip errors * feat: wip errors refactoring * feat: wip errors more refactoring * refactor: linting * feat: add second error in correct position and wip date range error * feat: remove unneccessary db field * feat: change type values to strings * refactor: tidy up controller logic * refactor: use same structure as locations deactivation * feat: add general partially missing date input error * feat: add tests ("updates existing scheme with valid deactivation date and renders scheme page" still wip) and add new partially nil date behaviour to locations controller * feat: fix tests, add status tag behaviour and remove unnecessary nils * refactor: linting * refactor: erblinting * refactor: remove redundant line * refactor: respond to PR comments 1 * refactor: respond to PR comments 2 * refactor: respond to PR comments 3 * refactor: respond to PR comments 3 (locations side) * fix: remove @locations in location model * fix: remove @locations in location model * fix: update status names * feat: wip validation update * feat: add validation to model layer * feat: further separate scheme deactivation behaviour * test: update tests to new flow * feat: respond to pr comments and add dynamic success text * feat: duplicate behaviour schemes -> locations (+ tests) * refactor: linting * refactor: typo and remove unnecessary line for this PR * refactor: feature toggle simplification * Refactor locations and schemes controller actions - Rename confirmation partials to `deactivate_confirm.html.erb` so that they match the actions in which they belong to - Make all deactivation date comparision UTC time * feat: update deactivation_date validation and add tests * refactor: linting Co-authored-by: Kat <katrina@kosiak.co.uk> Co-authored-by: James Rose <james@jbpr.net>
2 years ago
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
it "returns reactivating soon if the location has a future reactivation date" do
Timecop.freeze(2022, 6, 8)
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 7), reactivation_date: Time.zone.local(2022, 6, 9), location:)
location.save!
expect(location.status).to eq(:reactivating_soon)
end
Cldc 1671 deactivate scheme (#980) * feat: wip update scheme summary page * feat: wip deactivate scheme schemes page * feat: wip toggle active page * feat: wip set deactivation_date to a datetime (to be more specific times later_ * Change conditional question controller to accommodate all models * feat: add specific datetimes for deactivation * feat: correct date and add notice * feat: wip error behaviour * feat: wip errors * feat: wip errors refactoring * feat: wip errors more refactoring * refactor: linting * feat: add second error in correct position and wip date range error * feat: remove unneccessary db field * feat: change type values to strings * refactor: tidy up controller logic * refactor: use same structure as locations deactivation * feat: add general partially missing date input error * feat: add tests ("updates existing scheme with valid deactivation date and renders scheme page" still wip) and add new partially nil date behaviour to locations controller * feat: fix tests, add status tag behaviour and remove unnecessary nils * refactor: linting * refactor: erblinting * refactor: remove redundant line * refactor: respond to PR comments 1 * refactor: respond to PR comments 2 * refactor: respond to PR comments 3 * refactor: respond to PR comments 3 (locations side) * fix: remove @locations in location model * fix: remove @locations in location model * fix: update status names * feat: wip validation update * feat: add validation to model layer * feat: further separate scheme deactivation behaviour * test: update tests to new flow * feat: respond to pr comments and add dynamic success text * feat: duplicate behaviour schemes -> locations (+ tests) * refactor: linting * refactor: typo and remove unnecessary line for this PR * refactor: feature toggle simplification * Refactor locations and schemes controller actions - Rename confirmation partials to `deactivate_confirm.html.erb` so that they match the actions in which they belong to - Make all deactivation date comparision UTC time * feat: update deactivation_date validation and add tests * refactor: linting Co-authored-by: Kat <katrina@kosiak.co.uk> Co-authored-by: James Rose <james@jbpr.net>
2 years ago
it "returns reactivating soon if the location had a deactivation during another deactivation" do
Cldc 1670 reactivate locations (#1007) * route deactivated scheme to reactivation page * Render correct reactivate question content * refactor into a helper * display successful reactivation banner for default date * Save reactivation date * Add reactivation errors * lint and fix url in tests * make toggle translations generic * Add reactivation status * Reuse date validation messages * Show deactivate this location when location is reactivating soon * Display correct confirmation banner * Add validation for reactivation date before deactivation date * Improve availability label * Use current collection start date if created at is later than that * Update paths * Fix controller and don't display the previous day if location availability start afterwards * refactor availability label * Filter out active periods * lint * Refactor active_period method into the model * Allow deactivations and reactivations from available from date instead of start of the collection date * Prevent deactivations during deactivated periods * lint * typo * Remove active periods that last 1 day (because they get deactivated on the same day) * Move the active_periods into helper * extract remove_overlapping_and_empty_periods into a separate method * Remove nested deactivation periods * Make deactivate/reactvate location form use location_deactivation_period model * refactor toggle date methods * extract shared condition * update validations * refactor validations * Update schemes deactivation form to use dectivation model * Refactor * lint * remove redundant location_id and update scheme controller * update active_periods
2 years ago
Timecop.freeze(2022, 6, 4)
FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 5, 5), reactivation_date: Time.zone.local(2022, 6, 2), location:)
location.save!
expect(location.status).to eq(:reactivating_soon)
end
it "returns activating soon if the location has a future startdate" do
location.startdate = Time.zone.local(2022, 7, 7)
location.save!
expect(location.status).to eq(:activating_soon)
end
Cldc 1671 deactivate scheme (#980) * feat: wip update scheme summary page * feat: wip deactivate scheme schemes page * feat: wip toggle active page * feat: wip set deactivation_date to a datetime (to be more specific times later_ * Change conditional question controller to accommodate all models * feat: add specific datetimes for deactivation * feat: correct date and add notice * feat: wip error behaviour * feat: wip errors * feat: wip errors refactoring * feat: wip errors more refactoring * refactor: linting * feat: add second error in correct position and wip date range error * feat: remove unneccessary db field * feat: change type values to strings * refactor: tidy up controller logic * refactor: use same structure as locations deactivation * feat: add general partially missing date input error * feat: add tests ("updates existing scheme with valid deactivation date and renders scheme page" still wip) and add new partially nil date behaviour to locations controller * feat: fix tests, add status tag behaviour and remove unnecessary nils * refactor: linting * refactor: erblinting * refactor: remove redundant line * refactor: respond to PR comments 1 * refactor: respond to PR comments 2 * refactor: respond to PR comments 3 * refactor: respond to PR comments 3 (locations side) * fix: remove @locations in location model * fix: remove @locations in location model * fix: update status names * feat: wip validation update * feat: add validation to model layer * feat: further separate scheme deactivation behaviour * test: update tests to new flow * feat: respond to pr comments and add dynamic success text * feat: duplicate behaviour schemes -> locations (+ tests) * refactor: linting * refactor: typo and remove unnecessary line for this PR * refactor: feature toggle simplification * Refactor locations and schemes controller actions - Rename confirmation partials to `deactivate_confirm.html.erb` so that they match the actions in which they belong to - Make all deactivation date comparision UTC time * feat: update deactivation_date validation and add tests * refactor: linting Co-authored-by: Kat <katrina@kosiak.co.uk> Co-authored-by: James Rose <james@jbpr.net>
2 years ago
end
end
describe "available_from" do
context "when there is a startdate" do
let(:location) { FactoryBot.build(:location, startdate: Time.zone.local(2022, 4, 6)) }
it "returns the startdate" do
expect(location.available_from).to eq(Time.zone.local(2022, 4, 6))
end
end
context "when there is no start date" do
context "and the location was created at the start of the 2022/23 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2022, 4, 6), startdate: nil) }
it "returns the beginning of 22/23 collection window" do
expect(location.available_from).to eq(Time.zone.local(2022, 4, 1))
end
end
context "and the location was created at the end of the 2022/23 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2023, 2, 6), startdate: nil) }
it "returns the beginning of 22/23 collection window" do
expect(location.available_from).to eq(Time.zone.local(2022, 4, 1))
end
end
context "and the location was created at the start of the 2021/22 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2021, 4, 6), startdate: nil) }
it "returns the beginning of 21/22 collection window" do
expect(location.available_from).to eq(Time.zone.local(2021, 4, 1))
end
end
context "and the location was created at the end of the 2021/22 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2022, 2, 6), startdate: nil) }
it "returns the beginning of 21/22 collection window" do
expect(location.available_from).to eq(Time.zone.local(2021, 4, 1))
end
end
end
end
CLDC-1337-permitted-user-can-add-location-when-creating-scheme (#704) * added last step * not finding postcode field * testing being direct to add locations page after submitting support questions * added route to locations controller * location controller spec * location controller * added template for new * next step in feature * added postcode * added name to locations * removed total units from schemes * moved total units to locations * changed type of unit type in db * using type of units * add locations page is finished * purged total units and added test for location create * creating location * testing creating location as data provider * fixed factory * refacotred update/create and added test creating location as a coord user * testing returning back to create page if create another location is selected * testing returning back to create page if create another location is selected - part 2 * thanks rubocop * thanks rubocop * testing back from new location * returned tests back * testing clickable locations link * testing clickable locations link under correct context * correctly looking table * table with caption * wip * fixed failing exisiting tests * fixed failing exisiting tests - part 2 * validating postcode case logs style * validating postcode specs * validating postcode specs debugger removed * navigation when editing location * spike creating new location after addition * small refactoring * added test to add another location from locations page * added test to amend a location * added test to amend a location - part 2 * testing location cell * added wheelchair adaptions to the unit tyupe * rebased * testing postcode missing * testing creating schem for a different org for coordinator * testing new scheme for a different org for coordinator * upcasing all postcodes before creation * testing edge cases around postcodes and yes or no for another location * create locations with support user * details locations specs * update locations specs * rubocop * checking raising error * fixed failed test * switched yes and no for wheelchairs * routes refactoring * fixed routing - WIP * further chanegs * feature tests passing * correct page when errros * redundant page * moving viewing locations away from schemes controller * new is fixed * create fixed * fixed locations specs * fixed tab nav specs * completed location specs * lint
2 years ago
end