-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init work to transition Downtimes to Design System
- Add new feature `design_system_downtime_index_page` to the FlipFlop config - Update the routes with new constraint - Duplicate the controllers, views and test of Downtimes and append the `legacy_` prefix to them - Add new test in the routes integration test for the new feature - Create legacy integration Downtimes test - Make the new Downtimes index page use the Design System layout - Add flash back to the Design System layout for integration tests
- Loading branch information
1 parent
64025db
commit 3100f1c
Showing
9 changed files
with
243 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<% content_for :page_title, 'Downtime messages' %> | ||
|
||
<div class="page-title"> | ||
<h1>Downtime messages</h1> | ||
<p class="lead">Show a message on a published transaction start page for a specific time.</p> | ||
</div> | ||
|
||
<table class="table table-bordered table-striped" data-module="filterable-table"> | ||
<caption class="h2 remove-top-margin"> | ||
<h2 class="remove-top-margin remove-bottom-margin">Services</h2> | ||
</caption> | ||
<thead> | ||
<tr class="table-header"> | ||
<th>Service start page</th> | ||
<th>Service status</th> | ||
<th>Action</th> | ||
</tr> | ||
<tr class="if-no-js-hide table-header-secondary"> | ||
<td colspan="3"> | ||
<form> | ||
<label class="remove-bottom-margin" for="table-filter">Filter services</label> | ||
<p class="help-inline">For example ‘driving’ or ‘scheduled downtime’</p> | ||
<input id="table-filter" type="text" class="form-control normal js-filter-table-input"> | ||
</form> | ||
</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @transactions.each do |transaction| %> | ||
<tr> | ||
<td> | ||
<h3 class="publication-table-title"> | ||
<%= link_to transaction.title, Downtime.for(transaction.artefact).present? ? | ||
edit_edition_downtime_path(transaction) : | ||
new_edition_downtime_path(transaction) %> | ||
</h3> | ||
<%= link_to "/#{transaction.slug}", "#{Plek.website_root}/#{transaction.slug}", class: 'link-muted' %> | ||
</td> | ||
<% if downtime = Downtime.for(transaction.artefact) %> | ||
<td> | ||
Scheduled downtime<br /> | ||
<span class="text-muted"><%= downtime_datetime(downtime) %></span> | ||
</td> | ||
<td> | ||
<%= link_to 'Edit downtime', edit_edition_downtime_path(transaction), class: 'btn btn-info' %> | ||
</td> | ||
<% else %> | ||
<td>Live</td> | ||
<td> | ||
<%= link_to 'Add downtime', new_edition_downtime_path(transaction), class: 'btn btn-default' %> | ||
</td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
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 | ||
end | ||
|
||
test "Scheduling new downtime" do | ||
DowntimeScheduler.stubs(:schedule_publish_and_expiry) | ||
|
||
visit root_path | ||
click_link "Downtime" | ||
click_link "Apply to become a driving instructor" | ||
|
||
enter_start_time first_of_july_next_year_at_midday_bst | ||
enter_end_time first_of_july_next_year_at_six_pm_bst | ||
|
||
assert_match("midday to 6pm on #{day} 1 July", page.find_field("Message").value) | ||
click_button "Schedule downtime message" | ||
|
||
assert page.has_content?("downtime message scheduled") | ||
assert page.has_content?("Scheduled downtime") | ||
assert page.has_content?("midday to 6pm on 1 July") | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters