@ -90,7 +90,7 @@ RSpec.describe LocationsController, type: :request do
context " when signed in as a data coordinator " do
context " when signed in as a data coordinator " do
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
before do
before do
sign_in user
sign_in user
@ -108,13 +108,13 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when postcode is submitted with lower case " do
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " } } }
it " creates a new location for scheme with postcode " do
it " creates a new location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -123,7 +123,7 @@ RSpec.describe LocationsController, type: :request do
context " when trying to add location to a scheme that belongs to another organisation " do
context " when trying to add location to a scheme that belongs to another organisation " do
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
post " /schemes/ #{ another_scheme . id } /locations " , params : params
post " /schemes/ #{ another_scheme . id } /locations " , params : params
@ -132,7 +132,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when required postcode param is missing " do
context " when required postcode param is missing " do
let ( :params ) { { location : { name : " Test " , total_ units: " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -141,7 +141,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when do you want to add another location is selected as yes " do
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -153,14 +153,14 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is selected as no " do
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -172,14 +172,14 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is not selected " do
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , total_ units: " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -191,7 +191,7 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
@ -201,7 +201,7 @@ RSpec.describe LocationsController, type: :request do
context " when signed in as a support user " do
context " when signed in as a support user " do
let ( :user ) { FactoryBot . create ( :user , :support ) }
let ( :user ) { FactoryBot . create ( :user , :support ) }
let! ( :scheme ) { FactoryBot . create ( :scheme ) }
let! ( :scheme ) { FactoryBot . create ( :scheme ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
before do
before do
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
@ -219,13 +219,13 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
context " when postcode is submitted with lower case " do
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " } } }
it " creates a new location for scheme with postcode " do
it " creates a new location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -233,7 +233,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when required postcode param is missing " do
context " when required postcode param is missing " do
let ( :params ) { { location : { name : " Test " , total_ units: " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , add_another_location : " No " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
post " /schemes/ #{ scheme . id } /locations " , params : params
post " /schemes/ #{ scheme . id } /locations " , params : params
@ -243,7 +243,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when do you want to add another location is selected as yes " do
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -254,14 +254,14 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is selected as no " do
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -272,14 +272,14 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is not selected " do
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , total_ units: " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
let ( :params ) { { location : { name : " Test " , units : " 5 " , type_of_unit : " Bungalow " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " } } }
it " creates a new location for scheme with valid params and redirects to correct page " do
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 )
expect { post " /schemes/ #{ scheme . id } /locations " , params : } . to change ( Location , :count ) . by ( 1 )
@ -290,7 +290,7 @@ RSpec.describe LocationsController, type: :request do
it " creates a new location for scheme with valid params " do
it " creates a new location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
@ -390,7 +390,7 @@ RSpec.describe LocationsController, type: :request do
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
before do
before do
sign_in user
sign_in user
@ -407,7 +407,7 @@ RSpec.describe LocationsController, type: :request do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
@ -427,7 +427,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when postcode is submitted with lower case " do
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
it " updates existing location for scheme with postcode " do
it " updates existing location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -437,7 +437,7 @@ RSpec.describe LocationsController, type: :request do
context " when trying to update location for a scheme that belongs to another organisation " do
context " when trying to update location for a scheme that belongs to another organisation " do
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :another_scheme ) { FactoryBot . create ( :scheme ) }
let ( :another_location ) { FactoryBot . create ( :location ) }
let ( :another_location ) { FactoryBot . create ( :location ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
patch " /schemes/ #{ another_scheme . id } /locations/ #{ another_location . id } " , params : params
patch " /schemes/ #{ another_scheme . id } /locations/ #{ another_location . id } " , params : params
@ -446,7 +446,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when required postcode param is invalid " do
context " when required postcode param is invalid " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -455,7 +455,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when do you want to add another location is selected as yes " do
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -466,14 +466,14 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is selected as no " do
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -484,14 +484,14 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is not selected " do
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates existing location for scheme with valid params and redirects to correct page " do
it " updates existing location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -502,7 +502,7 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . scheme . owning_organisation_id ) . to eq ( user . organisation_id )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
@ -513,7 +513,7 @@ RSpec.describe LocationsController, type: :request do
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let ( :user ) { FactoryBot . create ( :user , :data_coordinator ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :scheme ) { FactoryBot . create ( :scheme , owning_organisation : user . organisation ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
before do
before do
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
allow ( user ) . to receive ( :need_two_factor_authentication? ) . and_return ( false )
@ -530,7 +530,7 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
@ -550,7 +550,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when postcode is submitted with lower case " do
context " when postcode is submitted with lower case " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " zz1 1zz " , page : " edit " } } }
it " updates a location for scheme with postcode " do
it " updates a location for scheme with postcode " do
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
expect ( Location . last . postcode ) . to eq ( " ZZ11ZZ " )
@ -558,7 +558,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when required postcode param is missing " do
context " when required postcode param is missing " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " invalid " , page : " edit " } } }
it " displays the new page with an error message " do
it " displays the new page with an error message " do
expect ( response ) . to have_http_status ( :unprocessable_entity )
expect ( response ) . to have_http_status ( :unprocessable_entity )
@ -567,7 +567,7 @@ RSpec.describe LocationsController, type: :request do
end
end
context " when do you want to add another location is selected as yes " do
context " when do you want to add another location is selected as yes " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " Yes " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates location for scheme with valid params and redirects to correct page " do
it " updates location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -577,14 +577,14 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is selected as no " do
context " when do you want to add another location is selected as no " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , add_another_location : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates a location for scheme with valid params and redirects to correct page " do
it " updates a location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -594,14 +594,14 @@ RSpec.describe LocationsController, type: :request do
it " updates existing location for scheme with valid params " do
it " updates existing location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end
end
end
context " when do you want to add another location is not selected " do
context " when do you want to add another location is not selected " do
let ( :params ) { { location : { name : " Test " , total_ 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 " , wheelchair_adaptation : " No " , postcode : " ZZ1 1ZZ " , page : " edit " } } }
it " updates a location for scheme with valid params and redirects to correct page " do
it " updates a location for scheme with valid params and redirects to correct page " do
follow_redirect!
follow_redirect!
@ -611,7 +611,7 @@ RSpec.describe LocationsController, type: :request do
it " updates a location for scheme with valid params " do
it " updates a location for scheme with valid params " do
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . name ) . to eq ( " Test " )
expect ( Location . last . total_ units) . to eq ( 5 )
expect ( Location . last . units ) . to eq ( 5 )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . type_of_unit ) . to eq ( " Bungalow " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
expect ( Location . last . wheelchair_adaptation ) . to eq ( " No " )
end
end