@ -908,15 +908,21 @@ RSpec.describe LettingsLogsController, type: :request do
end
end
context " with a signed in user " do
context " with a signed in user " do
context " with lettings logs that are owned or managed by your organisation " do
before do
before do
sign_in user
get " /lettings-logs/ #{ lettings_log . id } " , headers : , params : { }
Timecop . freeze ( 2021 , 4 , 1 )
Timecop . freeze ( 2021 , 4 , 1 )
Singleton . __init__ ( FormHandler )
Singleton . __init__ ( FormHandler )
completed_lettings_log . update! ( startdate : Time . zone . local ( 2021 , 4 , 1 ) , voiddate : Time . zone . local ( 2021 , 4 , 1 ) , mrcdate : Time . zone . local ( 2021 , 4 , 1 ) )
completed_lettings_log . update! ( startdate : Time . zone . local ( 2021 , 4 , 1 ) , voiddate : Time . zone . local ( 2021 , 4 , 1 ) , mrcdate : Time . zone . local ( 2021 , 4 , 1 ) )
completed_lettings_log . reload
completed_lettings_log . reload
Timecop . unfreeze
end
context " with lettings logs that are owned or managed by your organisation " do
before do
sign_in user
get " /lettings-logs/ #{ lettings_log . id } " , headers : , params : { }
end
after do
Timecop . return
Singleton . __init__ ( FormHandler )
Singleton . __init__ ( FormHandler )
end
end
@ -933,19 +939,51 @@ RSpec.describe LettingsLogsController, type: :request do
end
end
it " displays a link to update the log for currently editable logs " do
it " displays a link to update the log for currently editable logs " do
completed_lettings_log . update! ( startdate : Time . zone . local ( 2022 , 4 , 1 ) , tenancylength : nil )
completed_lettings_log . update! ( startdate : Time . zone . local ( 2021 , 4 , 1 ) , tenancylength : nil )
completed_lettings_log . reload
completed_lettings_log . reload
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
expect ( completed_lettings_log . form . new_logs_end_date ) . to eq ( Time . zone . local ( 2023 , 12 , 31 ) )
expect ( completed_lettings_log . form . new_logs_end_date ) . to eq ( Time . zone . local ( 2022 , 12 , 31 ) )
expect ( completed_lettings_log . status ) . to eq ( " completed " )
expect ( completed_lettings_log . status ) . to eq ( " completed " )
expect ( page ) . to have_link ( " review and make changes to this log " , href : " /lettings-logs/ #{ completed_lettings_log . id } /review " )
expect ( page ) . to have_link ( " review and make changes to this log " , href : " /lettings-logs/ #{ completed_lettings_log . id } /review " )
end
end
end
xit " displays a closed collection window message for previous collection year logs " do
context " with lettings logs from a closed collection period before the previous collection " do
before do
sign_in user
Timecop . return
Singleton . __init__ ( FormHandler )
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
expect ( completed_lettings_log . form . new_logs_end_date ) . to eq ( Time . zone . local ( 2022 , 7 , 1 ) )
end
it " redirects to review page " do
expect ( response ) . to redirect_to ( " /lettings-logs/ #{ completed_lettings_log . id } /review " )
end
end
context " with lettings logs from a closed previous collection period " do
before do
sign_in user
Timecop . freeze ( 2023 , 2 , 1 )
Singleton . __init__ ( FormHandler )
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
end
after do
Timecop . return
Singleton . __init__ ( FormHandler )
end
it " redirects to review page " do
expect ( response ) . to redirect_to ( " /lettings-logs/ #{ completed_lettings_log . id } /review " )
end
it " displays a closed collection window message for previous collection year logs " do
get " /lettings-logs/ #{ completed_lettings_log . id } " , headers : , params : { }
expect ( completed_lettings_log . form . new_logs_end_date ) . to eq ( Time . zone . local ( 2022 , 12 , 31 ) )
expect ( completed_lettings_log . status ) . to eq ( " completed " )
expect ( completed_lettings_log . status ) . to eq ( " completed " )
follow_redirect!
expect ( page ) . to have_content ( " This log is from the 2021/2022 collection window, which is now closed. " )
expect ( page ) . to have_content ( " This log is from the 2021/2022 collection window, which is now closed. " )
end
end
end
end
@ -992,10 +1030,17 @@ RSpec.describe LettingsLogsController, type: :request do
end
end
before do
before do
Timecop . freeze ( 2021 , 4 , 1 )
Singleton . __init__ ( FormHandler )
sign_in user
sign_in user
get " /lettings-logs/ #{ section_completed_lettings_log . id } " , headers : , params : { }
get " /lettings-logs/ #{ section_completed_lettings_log . id } " , headers : , params : { }
end
end
after do
Timecop . unfreeze
Singleton . __init__ ( FormHandler )
end
it " displays a section status for a lettings log " do
it " displays a section status for a lettings log " do
assert_select " .govuk-tag " , text : / Not started / , count : 6
assert_select " .govuk-tag " , text : / Not started / , count : 6
assert_select " .govuk-tag " , text : / Completed / , count : 1
assert_select " .govuk-tag " , text : / Completed / , count : 1
@ -1019,12 +1064,19 @@ RSpec.describe LettingsLogsController, type: :request do
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
let! ( :location ) { FactoryBot . create ( :location , scheme : ) }
before do
before do
Timecop . freeze ( 2021 , 4 , 1 )
Singleton . __init__ ( FormHandler )
FactoryBot . create_list ( :lettings_log , 3 , unresolved : true , created_by : user )
FactoryBot . create_list ( :lettings_log , 3 , unresolved : true , created_by : user )
lettings_log . update! ( needstype : 2 , scheme : , location : , unresolved : true )
lettings_log . update! ( needstype : 2 , scheme : , location : , unresolved : true )
sign_in user
sign_in user
get " /lettings-logs/ #{ lettings_log . id } " , headers : , params : { }
get " /lettings-logs/ #{ lettings_log . id } " , headers : , params : { }
end
end
after do
Timecop . return
Singleton . __init__ ( FormHandler )
end
it " marks it as resolved when both scheme and location exist " do
it " marks it as resolved when both scheme and location exist " do
lettings_log . reload
lettings_log . reload
expect ( lettings_log . unresolved ) . to eq ( false )
expect ( lettings_log . unresolved ) . to eq ( false )