availability<<" to #{(deactivation.deactivation_date-1.day).to_formatted_s(:govuk_date)}\nDeactivated on #{deactivation.deactivation_date.to_formatted_s(:govuk_date)}"
availability<<"\nActive from #{deactivation.reactivation_date.to_formatted_s(:govuk_date)}"ifdeactivation.reactivation_date.present?
deactivation_open=false
sorted_deactivation_periods.eachdo|deactivation|
availability<<" to #{(deactivation.deactivation_date-1.day).to_formatted_s(:govuk_date)}\nDeactivated on #{deactivation.deactivation_date.to_formatted_s(:govuk_date)}"unlessdeactivation_open
ifdeactivation.reactivation_date.present?
availability<<"\nActive from #{deactivation.reactivation_date.to_formatted_s(:govuk_date)}"
expect(availability_attribute).toeq("Active from 1 April 2022 to 9 August 2022\nDeactivated on 10 August 2022\nActive from 1 September 2022 to 14 September 2022\nDeactivated on 15 September 2022\nActive from 28 September 2022")
expect(availability_attribute).toeq("Active from 8 August 2022 to 9 August 2022\nDeactivated on 10 August 2022\nActive from 1 September 2022 to 14 September 2022\nDeactivated on 15 September 2022")
expect(availability_attribute).toeq("Active from 1 April 2022 to 9 August 2022\nDeactivated on 10 August 2022\nActive from 1 September 2022 to 14 September 2022\nDeactivated on 15 September 2022")
expect(availability_attribute).toeq("Active from 1 April 2022 to 14 June 2022\nDeactivated on 15 June 2022\nActive from 18 June 2022 to 23 September 2022\nDeactivated on 24 September 2022\nActive from 28 September 2022")
expect(availability_attribute).toeq("Active from 1 April 2022 to 14 June 2022\nDeactivated on 15 June 2022\nActive from 28 September 2022 to 23 October 2022\nDeactivated on 24 October 2022\nActive from 28 October 2022")