@ -91,7 +91,7 @@ RSpec.describe LocationsController, type: :request do
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let ( :startdate ) { Time . utc ( 2022 , 2 , 2 ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , startdate : } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , startdate : , mobility_type : " A " } } }
before do
sign_in user
@ -111,12 +111,12 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . startdate ) . to eq ( startdate )
expect ( Location . last . mobility_type ) . to eq ( " Fitted with equipment and adaptations " )
end
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " zz1 1zz " , mobility_type : " N " } } }
it " creates a new location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -125,7 +125,7 @@ RSpec.describe LocationsController, type: :request do
context " when trying to add location to a scheme that belongs to another organisation " do
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " displays the new page with an error message " do
post " /schemes/ #{ another_scheme . id } /locations " , params : params
@ -134,7 +134,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -148,12 +148,12 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . mobility_type ) . to eq ( " None " )
end
end
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -167,12 +167,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , postcode : " ZZ1 1ZZ " , mobility_type : " W " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -186,18 +185,19 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . mobility_type ) . to eq ( " Wheelchair-user standard " )
end
end
context " when required param are missing " do
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , add_another_location : " No " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
expect ( page ) . to have_content ( I18n . t ( " validations.postcode " ) )
expect ( page ) . to have_content ( I18n . t ( " activerecord.errors.models.location.attributes.units.blank " ) )
expect ( page ) . to have_content ( I18n . t ( " activerecord.errors.models.location.attributes.type_of_unit.blank " ) )
expect ( page ) . to have_content ( I18n . t ( " activerecord.errors.models.location.attributes.mobility_type.blank " ) )
end
end
@ -207,7 +207,7 @@ RSpec.describe LocationsController, type: :request do
name : " Test " ,
units : " 5 " ,
type_of_unit : " Bungalow " ,
wheelchair_adaptation : " No " ,
mobility_type : " N " ,
add_another_location : " No " ,
postcode : " ZZ1 1ZZ " ,
" startdate(3i) " = > " 1 " ,
@ -228,7 +228,7 @@ RSpec.describe LocationsController, type: :request do
name : " Test " ,
units : " 5 " ,
type_of_unit : " Bungalow " ,
wheelchair_adaptation : " No " ,
mobility_type : " N " ,
add_another_location : " No " ,
postcode : " ZZ1 1ZZ " ,
" startdate(3i) " = > " " ,
@ -249,7 +249,7 @@ RSpec.describe LocationsController, type: :request do
context " when signed in as a support user " do
let ( :user ) { FactoryBot . create ( :user , :support ) }
let! ( :scheme ) { FactoryBot . create ( :scheme ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
before do
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
@ -269,11 +269,10 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " zz1 1zz " , mobility_type : " N " } } }
it " creates a new location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -281,7 +280,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when required postcode param is missing " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " } } }
it " displays the new page with an error message " do
post " /schemes/ #{ scheme . id } /locations " , params : params
@ -291,7 +290,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -304,12 +303,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -322,12 +320,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , postcode : " ZZ1 1ZZ " , mobility_type : " N " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -340,12 +337,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when required param are missing " do
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , add_another_location : " No " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -361,7 +357,7 @@ RSpec.describe LocationsController, type: :request do
name : " Test " ,
units : " 5 " ,
type_of_unit : " Bungalow " ,
wheelchair_adaptation : " No " ,
mobility_type : " N " ,
add_another_location : " No " ,
postcode : " ZZ1 1ZZ " ,
" startdate(3i) " = > " 1 " ,
@ -382,7 +378,7 @@ RSpec.describe LocationsController, type: :request do
name : " Test " ,
units : " 5 " ,
type_of_unit : " Bungalow " ,
wheelchair_adaptation : " No " ,
mobility_type : " N " ,
add_another_location : " No " ,
postcode : " ZZ1 1ZZ " ,
" startdate(3i) " = > " " ,
@ -494,7 +490,7 @@ RSpec.describe LocationsController, type: :request do
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let ( :startdate ) { Time . utc ( 2021 , 1 , 2 ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , startdate : , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , startdate : , page : " edit " } } }
before do
sign_in user
@ -513,7 +509,6 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . startdate ) . to eq ( startdate )
end
@ -532,7 +527,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
it " updates existing location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -542,7 +537,7 @@ RSpec.describe LocationsController, type: :request do
context " when trying to update location for a scheme that belongs to another organisation " do
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :another_location ) { FactoryBot . create ( :location ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " displays the new page with an error message " do
patch " /schemes/ #{ another_scheme . id } /locations/ #{ another_location . id } " , params : params
@ -551,7 +546,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when required postcode param is invalid " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -560,7 +555,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -573,12 +568,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -591,12 +585,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -609,12 +602,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when required param are missing " do
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , add_another_location : " No " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -629,7 +621,7 @@ RSpec.describe LocationsController, type: :request do
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
before do
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
@ -648,7 +640,6 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
context " when updating from edit-name page " do
@ -666,7 +657,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
it " updates a location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -674,7 +665,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when required postcode param is missing " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -683,7 +674,7 @@ RSpec.describe LocationsController, type: :request do
end
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -695,12 +686,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates a location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -712,12 +702,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates a location for scheme with valid params and redirects to correct page " do
follow_redirect!
@ -729,12 +718,11 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when required param are missing " do
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { postcode : " " , name : " Test " , units : " " , type_of_unit : " " , add_another_location : " No " } } }
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -796,7 +784,7 @@ RSpec.describe LocationsController, type: :request do
expect ( page ) . to have_content ( location . id )
expect ( page ) . to have_content ( location . postcode )
expect ( page ) . to have_content ( location . type_of_unit )
expect ( page ) . to have_content ( location . wheelchair_adaptation )
expect ( page ) . to have_content ( location . mobility_type )
end
end
@ -874,7 +862,7 @@ RSpec.describe LocationsController, type: :request do
expect ( page ) . to have_content ( location . id )
expect ( page ) . to have_content ( location . postcode )
expect ( page ) . to have_content ( location . type_of_unit )
expect ( page ) . to have_content ( location . wheelchair_adaptation )
expect ( page ) . to have_content ( location . mobility_type )
end
end