diff --git a/app/assets/javascripts/legacy_modules/legacy_downtime_message.js b/app/assets/javascripts/legacy_modules/legacy_downtime_message.js
deleted file mode 100644
index e381851d7..000000000
--- a/app/assets/javascripts/legacy_modules/legacy_downtime_message.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/* globals moment */
-
-(function (Modules) {
- 'use strict'
- Modules.LegacyDowntimeMessage = function () {
- this.start = function (element) {
- var $startTimeFields = element.find('.js-start-time select')
- var $stopTimeFields = element.find('.js-stop-time select')
- var $downtimeMessage = element.find('.js-downtime-message')
- var $scheduleMessage = element.find('.js-schedule-message')
- var $submit = element.find('.js-submit')
-
- element.on('change', 'select', updateFormAndMessages)
- updateForm()
-
- function updateFormAndMessages () {
- updateForm(true)
- }
-
- function updateForm (andMessages) {
- var startDate = getDateFromFields($startTimeFields)
- var stopDate = getDateFromFields($stopTimeFields)
-
- if (isValidSchedule(startDate, stopDate)) {
- enableForm()
- if (andMessages) {
- updateMessages(startDate, stopDate)
- }
- } else {
- if (andMessages) {
- $downtimeMessage.val('')
- }
- disableForm()
- }
- }
-
- function updateMessages (startDate, stopDate) {
- $downtimeMessage.val(downtimeMessage(startDate, stopDate))
- $scheduleMessage.text(scheduleMessage(startDate))
- }
-
- function getDateFromFields (fields) {
- var year,
- month,
- day,
- hours,
- minutes,
- date
-
- fields.each(function (i) {
- var value = parseInt($(this).val(), 10)
-
- switch (i) {
- case 4:
- year = value
- break
- case 3:
- month = value - 1
- break
- case 2:
- day = value
- break
- case 1:
- minutes = value
- break
- case 0:
- hours = value
- break
- }
- })
-
- date = new Date(year, month, day, hours, minutes)
- return moment(date)
- }
-
- function downtimeMessage (startDate, stopDate) {
- var message = 'This service will be unavailable from '
- var startTime = getTime(startDate)
- var startDay = getDay(startDate)
- var stopTime = getTime(stopDate)
- var stopDay = getDay(stopDate)
- var sameDay = isSameDay(startDate, stopDate)
-
- if (!isValidSchedule(startDate, stopDate)) {
- return ''
- }
-
- if (sameDay) {
- message = message + startTime + ' to ' + stopTime + ' on ' + startDay + '.'
- } else {
- message = message + startTime + ' on ' + startDay +
- ' to ' + stopTime + ' on ' + stopDay + '.'
- }
-
- return message
- }
-
- function scheduleMessage (startDate) {
- var message = 'A downtime message will show from '
- var beginShowingDate = startDate.clone().subtract(1, 'day')
- var beginTime = 'midnight'
- var beginDay = getDay(beginShowingDate)
-
- return message + beginTime + ' on ' + beginDay + ' (one day before the downtime)'
- }
-
- function isSameDay (startDate, stopDate) {
- // Treat a midnight stop date as being on the same day as
- // the hours before it. eg
- // Unavailable from 10pm to midnight on Thursday 8 January
- return startDate.isSame(stopDate.clone().subtract(1, 'minute'), 'day')
- }
-
- function getTime (moment) {
- var time = moment.format('h:mma')
- return time.replace(/:00/, '').replace(/12am/, 'midnight').replace(/12pm/, 'midday')
- }
-
- function getDay (moment) {
- return moment.format('dddd D MMMM')
- }
-
- function isValidSchedule (startDate, stopDate) {
- return stopDate.isAfter(startDate)
- }
-
- function disableForm () {
- $submit.attr('disabled', 'disabled')
- $downtimeMessage.attr('disabled', 'disabled')
- $scheduleMessage.text('Please select a valid date range')
- }
-
- function enableForm () {
- $submit.removeAttr('disabled')
- $downtimeMessage.removeAttr('disabled')
- }
- }
- }
-})(window.GOVUKAdmin.Modules)
diff --git a/app/assets/stylesheets/downtime.scss b/app/assets/stylesheets/downtime.scss
deleted file mode 100644
index 5a1c5e563..000000000
--- a/app/assets/stylesheets/downtime.scss
+++ /dev/null
@@ -1,24 +0,0 @@
-.help-note {
- font-weight: bold;
-
- .glyphicon {
- float: left;
- font-size: $font-size-large;
- margin-right: $default-horizontal-margin;
- }
-}
-
-.downtime-dates p {
- font-weight: bold;
- font-size: 16px;
-}
-
-.date {
- width: auto;
-}
-
-.joining-on {
- @media screen and (min-width: 600px) { // stylelint-disable-line max-nesting-depth, media-feature-range-notation
- margin-top: 40px;
- }
-}
diff --git a/app/assets/stylesheets/legacy-application.scss b/app/assets/stylesheets/legacy-application.scss
index 80439a259..689bc91de 100644
--- a/app/assets/stylesheets/legacy-application.scss
+++ b/app/assets/stylesheets/legacy-application.scss
@@ -17,7 +17,6 @@
@import "error_summary";
// Pages
-@import "downtime";
@import "smart_answer_builder";
@import "smart_answer_flowchart";
diff --git a/app/controllers/legacy_downtimes_controller.rb b/app/controllers/legacy_downtimes_controller.rb
deleted file mode 100644
index 45059ade5..000000000
--- a/app/controllers/legacy_downtimes_controller.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-class LegacyDowntimesController < ApplicationController
- before_action :require_govuk_editor
- before_action :load_edition
- before_action :process_params, only: %i[update]
-
- def edit
- @downtime = Downtime.for(@edition.artefact)
- end
-
- def update
- @downtime = Downtime.for(@edition.artefact)
-
- if params["commit"] == "Cancel downtime"
- DowntimeRemover.destroy_immediately(@downtime)
- flash[:success] = "#{edition_link} downtime message cancelled".html_safe
- redirect_to downtimes_path
- elsif @downtime.update(downtime_params)
- DowntimeScheduler.schedule_publish_and_expiry(@downtime)
- flash[:success] = "#{edition_link} downtime message re-scheduled (from #{view_context.downtime_datetime(@downtime)})".html_safe
- redirect_to downtimes_path
- else
- render :edit
- end
- end
-
-private
-
- def downtime_params
- params[:downtime].permit([
- "artefact_id",
- "message",
- "end_time(1i)",
- "end_time(2i)",
- "end_time(3i)",
- "end_time(4i)",
- "end_time(5i)",
- "start_time(1i)",
- "start_time(2i)",
- "start_time(3i)",
- "start_time(4i)",
- "start_time(5i)",
- ])
- end
-
- def load_edition
- @edition = Edition.find(params[:edition_id])
- end
-
- def process_params
- squash_multiparameter_datetime_attributes(downtime_params, %w[start_time end_time])
- end
-
- def edition_link
- view_context.link_to(@edition.title, edit_edition_downtime_path(@edition), class: "link-inherit bold")
- end
-end
diff --git a/app/views/legacy_downtimes/_form.html.erb b/app/views/legacy_downtimes/_form.html.erb
deleted file mode 100644
index 69676f59f..000000000
--- a/app/views/legacy_downtimes/_form.html.erb
+++ /dev/null
@@ -1,88 +0,0 @@
-<%= f.hidden_field :artefact_id %>
-
-<%= render :partial => 'legacy_downtimes_error_summary', locals: { object: @downtime} %>
-
-
-
-
-
-
- <%= f.label :start_time, "Hour", for: "downtime_start_time_4i" %>
- <%= select_hour @downtime.start_time&.hour || 1.hour.from_now.beginning_of_hour, { field_name: "start_time(4i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
- <%= f.label :start_time, "Minute", for: "downtime_start_time_5i" %>
- <%= select_minute @downtime.start_time&.minute, { field_name: "start_time(5i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
-
-
- <%= f.label :start_time, "Day", for: "downtime_start_time_3i" %>
- <%= select_day @downtime.start_time&.day || Date.tomorrow.day, { field_name: "start_time(3i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
- <%= f.label :start_time, "Month", for: "downtime_start_time_2i" %>
- <%= select_month@downtime.start_time&.month || Date.tomorrow.month, { field_name: "start_time(2i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
- <%= f.label :start_time, "Year", for: "downtime_start_time_1i" %>
- <%= select_year @downtime.start_time&.year || Date.tomorrow.year, { field_name: "start_time(1i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
-
-
-
-
-
- <%= f.label :end_time, "Hour", for: "downtime_end_time_4i" %>
- <%= select_hour @downtime.end_time&.hour || 1.hour.from_now.beginning_of_hour, { field_name: "end_time(4i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
- <%= f.label :end_time, "Minute", for: "downtime_end_time_5i" %>
- <%= select_minute @downtime.end_time&.minute, { field_name: "end_time(5i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
-
-
- <%= f.label :start_time, "Day", for: "downtime_end_time_3i" %>
- <%= select_day @downtime.end_time&.day || Date.tomorrow.day, { field_name: "end_time(3i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
- <%= f.label :end_time, "Month", for: "downtime_end_time_2i" %>
- <%= select_month @downtime.end_time&.month || Date.tomorrow.month, { field_name: "end_time(2i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
- <%= f.label :end_time, "Year", for: "downtime_end_time_1i" %>
- <%= select_year @downtime.end_time&.year || Date.tomorrow.year, { field_name: "end_time(1i)", prefix: "downtime" }, { class: "form-control date" } %>
-
-
-
-
-
-
-<%= form_group(f, :message) do %>
- <%= f.text_area :message, class: 'form-control input-md-6 js-downtime-message', rows: 5 %>
-<% end %>
-
-
-
- Messages appear on the start page one day before the downtime is due.
-
-
-
diff --git a/app/views/legacy_downtimes/_legacy_downtimes_error_summary.html.erb b/app/views/legacy_downtimes/_legacy_downtimes_error_summary.html.erb
deleted file mode 100644
index 359dcbcc6..000000000
--- a/app/views/legacy_downtimes/_legacy_downtimes_error_summary.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-<% if object.errors.any? %>
-
-
There is a problem
-
- <% object.errors.each do |error| %>
- -
- <% model = object.class.superclass.to_s == "Object" ? object.class : object.class.superclass %>
- "><%= error.full_message %>
-
- <% end %>
-
-
-<% end %>
diff --git a/app/views/legacy_downtimes/edit.html.erb b/app/views/legacy_downtimes/edit.html.erb
deleted file mode 100644
index e2f850b37..000000000
--- a/app/views/legacy_downtimes/edit.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-<% content_for :page_title, 'Re-schedule downtime message' %>
-
-
- - <%= link_to 'Downtime', downtimes_path %>
- - <%= @downtime.artefact.name %>
-
-
-
-
- <%= @downtime.artefact.name %>
- Re-schedule downtime message
-
-
-
-<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module': 'legacy-downtime-message' } do |f| %>
- <%= render 'form', f: f %>
- <%= f.submit 'Re-schedule downtime message', class: 'js-submit btn btn-success' %>
- <%= f.submit 'Cancel downtime', class: 'add-left-margin btn btn-danger' %>
-<% end %>
diff --git a/config/features.rb b/config/features.rb
index f42e41eda..e10ab9803 100644
--- a/config/features.rb
+++ b/config/features.rb
@@ -8,8 +8,4 @@
default: true,
description: "A feature only used by tests; not to be used for any actual features."
end
-
- feature :design_system_downtime_edit,
- default: true,
- description: "A transition of the edit downtime page to the GOV.UK Design System"
end
diff --git a/config/routes.rb b/config/routes.rb
index 018474bed..754886326 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -42,13 +42,8 @@
}
end
- resource :downtime, only: %i[new create]
-
- constraints FeatureConstraint.new("design_system_downtime_edit") do
- resource :downtime, only: %i[edit update destroy]
- get "downtime" => "downtimes#destroy", as: :destroy_downtime
- end
- resource :downtime, only: %i[edit update destroy], controller: "legacy_downtimes"
+ resource :downtime, only: %i[new create edit update destroy]
+ get "downtime" => "downtimes#destroy", as: :destroy_downtime
end
get "reports" => "reports#index", as: :reports
diff --git a/spec/javascripts/spec/legacy_downtime_message.spec.js b/spec/javascripts/spec/legacy_downtime_message.spec.js
deleted file mode 100644
index b92c0a8c8..000000000
--- a/spec/javascripts/spec/legacy_downtime_message.spec.js
+++ /dev/null
@@ -1,261 +0,0 @@
-describe('A downtime message module', function () {
- 'use strict'
-
- var downtimeMessage,
- form
-
- beforeEach(function () {
- var formHTML = '' +
- '' +
- '' +
- '' +
- ''
-
- form = $(
- ''
- )
-
- $('body').append(form)
-
- downtimeMessage = new GOVUKAdmin.Modules.LegacyDowntimeMessage()
- downtimeMessage.start(form)
- })
-
- afterEach(function () {
- form.remove()
- })
-
- describe('when starting', function () {
- it('leaves any existing downtime message alone', function () {
- expectDowntimeMessageToMatch('starting message')
- })
-
- it('disables the form if the preloaded dates aren’t valid', function () {
- expectDisabledForm()
- })
- })
-
- describe('when selecting dates', function () {
- it('generates a downtime message and a schedule message', function () {
- selectStartDate()
- selectStopDate({ hour: '02' })
- expectDowntimeMessageToMatch('This service will be unavailable from 1am to 2am on Thursday 1 January.')
- expectScheduleMessageToMatch('A downtime message will show from midnight on Wednesday 31 December')
-
- selectStopDate({ hour: '03' })
- expectDowntimeMessageToMatch('from 1am to 3am on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
-
- expectEnabledForm()
- })
-
- describe('that are the same', function () {
- beforeEach(function () {
- selectStartDate()
- selectStopDate()
- })
-
- it('doesn’t generate a message', function () {
- expectDowntimeMessageToBe('')
- })
-
- it('disables the form', function () {
- expectDisabledForm()
- })
- })
-
- describe('with a stop date before the start date', function () {
- beforeEach(function () {
- selectStartDate({ hour: '03' })
- selectStopDate({ hour: '01' })
- })
-
- it('doesn’t generate a message', function () {
- expectDowntimeMessageToBe('')
- })
-
- it('disables the form', function () {
- expectDisabledForm()
- })
- })
-
- describe('the generated messages', function () {
- it('use a 12 hour clock', function () {
- selectStartDate({ hour: '11' })
- selectStopDate({ hour: '15' })
- expectDowntimeMessageToMatch('from 11am to 3pm on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
- expectEnabledForm()
- })
-
- it('use midnight instead of 12am', function () {
- selectStartDate({ hour: '00' })
- selectStopDate({ hour: '02' })
- expectDowntimeMessageToMatch('from midnight to 2am on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
- })
-
- it('use midday instead of 12pm', function () {
- selectStartDate({ hour: '12' })
- selectStopDate({ hour: '14' })
- expectDowntimeMessageToMatch('from midday to 2pm on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
- })
-
- it('includes minutes when they are not 0', function () {
- selectStartDate({ hour: '00', minutes: '15' })
- selectStopDate({ hour: '02', minutes: '45' })
- expectDowntimeMessageToMatch('from 12:15am to 2:45am on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
- })
-
- it('includes both dates when they differ', function () {
- selectStartDate()
- selectStopDate({ day: '2', hour: '03' })
- expectDowntimeMessageToMatch('from 1am on Thursday 1 January to 3am on Friday 2 January.')
- })
-
- it('treats midnight on the next consecutive day as the same date', function () {
- selectStartDate({ hour: '22', day: '1' })
- selectStopDate({ hour: '00', day: '2' })
- expectDowntimeMessageToMatch('from 10pm to midnight on Thursday 1 January.')
- expectScheduleMessageToMatch('from midnight on Wednesday 31 December')
- })
-
- it('handles incorrect dates in the same way as rails', function () {
- selectStartDate({ day: '29', month: '2' })
- selectStopDate({ day: '5', month: '3' })
- expectDowntimeMessageToMatch('from 1am on Sunday 1 March to 1am on Thursday 5 March.')
- expectScheduleMessageToMatch('from midnight on Saturday 28 February')
- expectEnabledForm()
- })
- })
- })
-
- function expectDowntimeMessageToMatch (text) {
- expect(form.find('.js-downtime-message').val()).toMatch(text)
- }
-
- function expectDowntimeMessageToBe (text) {
- expect(form.find('.js-downtime-message').val()).toBe(text)
- }
-
- function expectScheduleMessageToMatch (text) {
- expect(form.find('.js-schedule-message').text()).toMatch(text)
- }
-
- function expectDisabledForm () {
- expect(form.find('.js-submit:disabled').length).toBe(1)
- expect(form.find('.js-downtime-message:disabled').length).toBe(1)
- expectScheduleMessageToMatch('Please select a valid date range')
- }
-
- function expectEnabledForm () {
- expect(form.find('.js-submit:disabled').length).toBe(0)
- expect(form.find('.js-downtime-message:disabled').length).toBe(0)
- }
-
- function selectStartDate (dateObj) {
- selectDate('.js-start-time', dateObj)
- }
-
- function selectStopDate (dateObj) {
- selectDate('.js-stop-time', dateObj)
- }
-
- function selectDate (selector, dateObj) {
- var selects = $(selector + ' select')
-
- dateObj = dateObj || {}
-
- selects.eq(0).val(dateObj.hour || '01')
- selects.eq(1).val(dateObj.minutes || '00')
- selects.eq(2).val(dateObj.day || '1')
- selects.eq(3).val(dateObj.month || '1')
- selects.eq(4).val(dateObj.year || '2015').trigger('change')
- }
-})
diff --git a/test/functional/legacy_downtimes_controller_test.rb b/test/functional/legacy_downtimes_controller_test.rb
deleted file mode 100644
index 5328366a3..000000000
--- a/test/functional/legacy_downtimes_controller_test.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require "test_helper"
-
-class LegacyDowntimesControllerTest < ActionController::TestCase
- setup do
- login_as_stub_user
- end
-
- context "#edit" do
- should "render the page ok" do
- create_downtime
- get :edit, params: { edition_id: edition.id }
- assert_response :ok
- end
- end
-
- context "#update" do
- context "cancelling scheduled downtime" do
- should "invoke the DowntimeRemover" do
- DowntimeRemover.expects(:destroy_immediately).with(downtime)
- put :update, params: { edition_id: edition.id, downtime: downtime_params, commit: "Cancel downtime" }
- end
-
- should "redirect to the downtime index" do
- DowntimeRemover.stubs(:destroy_immediately)
- put :update, params: { edition_id: edition.id, downtime: downtime_params, commit: "Cancel downtime" }
- assert_redirected_to controller: "downtimes", action: "index"
- end
- end
-
- context "rescheduling planned downtime" do
- should "schedule the changes for publication and expiration" do
- DowntimeScheduler.expects(:schedule_publish_and_expiry).with(downtime)
- put :update, params: { edition_id: edition.id, downtime: downtime_params, commit: "Re-schedule downtime message" }
- end
-
- should "redirect to the downtime index" do
- create_downtime
- DowntimeScheduler.stubs(:schedule_publish_and_expiry)
- put :update, params: { edition_id: edition.id, downtime: downtime_params, commit: "Re-schedule downtime message" }
- assert_redirected_to controller: "downtimes", action: "index"
- end
- end
-
- context "with invalid form data" do
- should "rerender the page" do
- create_downtime
- put :update, params: { edition_id: edition.id, downtime: invalid_params, commit: "Re-schedule downtime message" }
- assert_template :edit
- end
- end
- end
-
- def edition
- @edition ||= FactoryBot.create(:transaction_edition)
- end
-
- def downtime
- @downtime ||= FactoryBot.create(:downtime, artefact: edition.artefact)
- end
-
- def create_downtime
- downtime
- end
-
- def next_year
- (Time.zone.now + 1.year).year
- end
-
- def last_year
- (Time.zone.now - 1.year).year
- end
-
- def downtime_params
- {
- 'artefact_id': edition.artefact.id,
- 'start_time(4i)': 11,
- 'start_time(5i)': 0,
- 'start_time(3i)': 14,
- 'start_time(2i)': 3,
- 'start_time(1i)': next_year,
- 'end_time(4i)': 15,
- 'end_time(5i)': 0,
- 'end_time(3i)': 14,
- 'end_time(2i)': 3,
- 'end_time(1i)': next_year,
- 'message': "foo",
- }
- end
-
- def invalid_params
- downtime_params.merge('end_time(1i)': last_year)
- end
-end
diff --git a/test/integration/downtime_integration_test.rb b/test/integration/downtime_integration_test.rb
index 1c7a0004b..1639c4fcc 100644
--- a/test/integration/downtime_integration_test.rb
+++ b/test/integration/downtime_integration_test.rb
@@ -14,9 +14,6 @@ class DowntimeIntegrationTest < JavascriptIntegrationTest
WebMock.reset!
stub_any_publishing_api_put_content
stub_any_publishing_api_publish
-
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, true)
end
test "Scheduling new downtime" do
@@ -84,14 +81,6 @@ def enter_date_and_time(prefix, time)
fill_in "downtime[#{prefix}_time(5i)]", with: time.min.to_s
end
- def legacy_enter_start_time(start_time)
- complete_date_inputs("downtime_start_time", start_time)
- end
-
- def legacy_enter_end_time(end_time)
- complete_date_inputs("downtime_end_time", end_time)
- end
-
def complete_date_inputs(input_id, time)
select time.year.to_s, from: "#{input_id}_1i"
select time.strftime("%B"), from: "#{input_id}_2i"
diff --git a/test/integration/downtime_with_invalid_dates_test.rb b/test/integration/downtime_with_invalid_dates_test.rb
index 108165200..50853ae58 100644
--- a/test/integration/downtime_with_invalid_dates_test.rb
+++ b/test/integration/downtime_with_invalid_dates_test.rb
@@ -14,9 +14,6 @@ class DowntimeWithInvalidDates < ActionDispatch::IntegrationTest
WebMock.reset!
stub_any_publishing_api_put_content
stub_any_publishing_api_publish
-
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, true)
end
test "Scheduling new downtime with invalid dates" do
diff --git a/test/integration/legacy_downtime_integration_test.rb b/test/integration/legacy_downtime_integration_test.rb
deleted file mode 100644
index 7015e3ad4..000000000
--- a/test/integration/legacy_downtime_integration_test.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-require "integration_test_helper"
-
-class LegacyDowntimeIntegrationTest < JavascriptIntegrationTest
- setup do
- setup_users
-
- @edition = FactoryBot.create(
- :transaction_edition,
- :published,
- title: "Apply to become a driving instructor",
- slug: "apply-to-become-a-driving-instructor",
- )
-
- WebMock.reset!
- stub_any_publishing_api_put_content
- stub_any_publishing_api_publish
-
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, false)
- end
-
- test "Rescheduling downtime" do
- DowntimeScheduler.stubs(:schedule_publish_and_expiry)
- create_downtime
-
- visit root_path
- click_link "Downtime"
- click_link "Edit downtime"
- enter_end_time first_of_july_next_year_at_nine_thirty_pm_bst
-
- assert_match("This service will be unavailable from midday to 9:30pm on #{day} 1 July.", page.find_field("Message").value)
- click_on "Re-schedule downtime message"
-
- assert page.has_content?("downtime message re-scheduled")
- assert page.has_content?("midday to 9:30pm on 1 July")
- end
-
- test "Cancelling downtime" do
- PublishingApiWorkflowBypassPublisher.stubs(:call)
- create_downtime
-
- visit root_path
- click_link "Downtime"
- click_link "Edit downtime"
- click_on "Cancel downtime"
-
- assert page.has_content?("downtime message cancelled")
- assert_no_downtime_scheduled
- end
-
- def enter_start_time(start_time)
- complete_date_inputs("downtime_start_time", start_time)
- end
-
- def enter_end_time(end_time)
- complete_date_inputs("downtime_end_time", end_time)
- end
-
- def complete_date_inputs(input_id, time)
- select time.year.to_s, from: "#{input_id}_1i"
- select time.strftime("%B"), from: "#{input_id}_2i"
- select time.day.to_s, from: "#{input_id}_3i"
- select time.hour.to_s, from: "#{input_id}_4i"
- select time.strftime("%M"), from: "#{input_id}_5i"
- end
-
- def next_year
- Time.zone.now.next_year.year
- end
-
- def date_in_the_past
- Time.zone.local(Time.zone.now.last_year.year, 1, 1, 12, 0)
- end
-
- def first_of_july_next_year_at_midday_bst
- Time.zone.local(next_year, 7, 1, 12, 0)
- end
-
- def first_of_july_next_year_at_six_pm_bst
- Time.zone.local(next_year, 7, 1, 18, 0)
- end
-
- def first_of_july_next_year_at_nine_thirty_pm_bst
- Time.zone.local(next_year, 7, 1, 21, 30)
- end
-
- def day
- first_of_july_next_year_at_six_pm_bst.strftime("%A")
- end
-
- def create_downtime
- Downtime.create!(
- artefact: @edition.artefact,
- start_time: first_of_july_next_year_at_midday_bst,
- end_time: first_of_july_next_year_at_six_pm_bst,
- message: "foo",
- )
- end
-
- def assert_no_downtime_scheduled
- assert_equal 0, Downtime.count
- end
-end
diff --git a/test/integration/legacy_downtime_with_invalid_dates_test.rb b/test/integration/legacy_downtime_with_invalid_dates_test.rb
deleted file mode 100644
index 990a6f198..000000000
--- a/test/integration/legacy_downtime_with_invalid_dates_test.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require "integration_test_helper"
-
-class LegacyDowntimeWithInvalidDates < ActionDispatch::IntegrationTest
- setup do
- setup_users
-
- @edition = FactoryBot.create(
- :transaction_edition,
- :published,
- title: "Apply to become a driving instructor",
- slug: "apply-to-become-a-driving-instructor",
- )
-
- WebMock.reset!
- stub_any_publishing_api_put_content
- stub_any_publishing_api_publish
-
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, false)
- end
-
- def enter_start_time(start_time)
- complete_date_inputs("downtime_start_time", start_time)
- end
-
- def enter_end_time(end_time)
- complete_date_inputs("downtime_end_time", end_time)
- end
-
- def complete_date_inputs(input_id, time)
- select time.year.to_s, from: "#{input_id}_1i"
- select time.strftime("%B"), from: "#{input_id}_2i"
- select time.day.to_s, from: "#{input_id}_3i"
- select pad_digit_to_two_digits(time.hour.to_s), from: "#{input_id}_4i"
- select time.strftime("%M"), from: "#{input_id}_5i"
- end
-
- def pad_digit_to_two_digits(hour_string)
- hour_string.length == 1 ? "0#{hour_string}" : hour_string
- end
-end
diff --git a/test/integration/routes_test.rb b/test/integration/routes_test.rb
index 3dbcf2054..b64af01f5 100644
--- a/test/integration/routes_test.rb
+++ b/test/integration/routes_test.rb
@@ -1,25 +1,14 @@
require "integration_test_helper"
class RoutesTest < ActionDispatch::IntegrationTest
- should "route to downtimes controller when 'design_system_downtime_edit' toggle is enabled" do
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, true)
+ should "route to downtimes controller for edit downtime" do
edition = FactoryBot.create(:edition)
edition_id = edition.id.to_s
assert_routing("/editions/#{edition_id}/downtime/edit", controller: "downtimes", action: "edit", edition_id:)
end
- should "route to legacy downtimes controller when 'design_system_downtime_edit' toggle is disabled" do
- test_strategy = Flipflop::FeatureSet.current.test!
- test_strategy.switch!(:design_system_downtime_edit, false)
- edition = FactoryBot.create(:edition)
- edition_id = edition.id.to_s
-
- assert_routing("/editions/#{edition_id}/downtime/edit", controller: "legacy_downtimes", action: "edit", edition_id:)
- end
-
- should "route to new downtimes controller" do
+ should "route to new downtimes controller new downtime" do
assert_routing("/editions/1/downtime/new", controller: "downtimes", action: "new", edition_id: "1")
end
end