Browse Source
* CLDC-2862: first attempt at creating maintenance page * CLDC-2907: try turning off maintenance mode to see if tests pass * CLDC-2862: write tests for MaintenanceController * CLDC-2862: test header bar links hidden in maintenance mode * CLDC-2862: lint * CLDC-2862: add requests tests * CLDC-2862: try disabling schduled job in maintenance mode * CLDC-2862: turn on maintenance mode temporarily * CLDC-2862: turn off maintenance mode again * CLDC-2862: ensure cookies, notices etc still available in maintenance mode * CLDC-2862: update content on maintenance page * CLDC-2862: destroy sidekiq cron jobs on shutdown * CLDC-2862: turn maintenance mode back on * CLDC-2862: try destroying cron jobs on startup * CLDC-2862: try destroying cron jobs on shutdown again, but with fix * CLDC-2862: turn maintenance mode off again * CLDC-2862: move job destruction to sidekiq server startup * CLDC-2862: turn MM back on * CLDC-2862: turn MM off again * CLDC-2862: update 'contact the helpdesk' content * CLDC-2862: check notices/statements still viewable in MM * CLDC-2862: check cookies page still viewable in MM * CLDC-2862: confirm cookie banner visible regardless of MM * CLDC-2862: reenable MM * CLDC-2862: turn maintenance mode off againpull/2021/head
SamSeed-Softwire
1 year ago
committed by
GitHub
12 changed files with 270 additions and 30 deletions
@ -0,0 +1,7 @@
|
||||
class MaintenanceController < ApplicationController |
||||
def service_unavailable |
||||
if current_user |
||||
sign_out |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
<h1 class="govuk-heading-l govuk-!-width-two-thirds"> |
||||
Sorry, the service is unavailable |
||||
</h1> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds-from-desktop"> |
||||
<p class="govuk-body">You will be able to use the service from 9am on Thursday 16 November 2023.</p> |
||||
<p class="govuk-body">Changes from the page you were on have not been saved. Changes on pages where you have selected 'save and continue' have been saved.</p> |
||||
<p class="govuk-body"><%= govuk_link_to "Contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %> if you need help.</p> |
||||
</div> |
||||
</div> |
@ -0,0 +1,27 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe MaintenanceController do |
||||
let(:user) { FactoryBot.create(:user) } |
||||
|
||||
describe "GET #service_unavailable" do |
||||
context "when maintenance mode is enabled" do |
||||
it "logs the user out" do |
||||
allow(FeatureToggle).to receive(:maintenance_mode_enabled?).and_return(true) |
||||
sign_in user |
||||
expect(controller).to be_user_signed_in |
||||
get :service_unavailable |
||||
expect(controller).not_to be_user_signed_in |
||||
end |
||||
end |
||||
|
||||
context "when maintenance mode is disabled" do |
||||
it "doesn't log the user out" do |
||||
allow(FeatureToggle).to receive(:maintenance_mode_enabled?).and_return(false) |
||||
sign_in user |
||||
expect(controller).to be_user_signed_in |
||||
get :service_unavailable |
||||
expect(controller).to be_user_signed_in |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,42 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe CookiesController, type: :request do |
||||
let(:headers) { { "Accept" => "text/html" } } |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
|
||||
describe "when maintenance mode is disabled" do |
||||
describe "render cookies page" do |
||||
before do |
||||
get "/cookies", headers:, params: {} |
||||
end |
||||
|
||||
it "returns a 200" do |
||||
expect(response).to have_http_status(:success) |
||||
end |
||||
|
||||
it "returns the page" do |
||||
expect(page).to have_title("Cookies") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "when maintenance mode is enabled" do |
||||
before do |
||||
allow(FeatureToggle).to receive(:maintenance_mode_enabled?).and_return(true) |
||||
end |
||||
|
||||
describe "render cookies page" do |
||||
before do |
||||
get "/cookies", headers:, params: {} |
||||
end |
||||
|
||||
it "returns a 200" do |
||||
expect(response).to have_http_status(:success) |
||||
end |
||||
|
||||
it "returns the page" do |
||||
expect(page).to have_title("Cookies") |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,85 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe MaintenanceController, type: :request do |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
let(:user) { FactoryBot.create(:user) } |
||||
|
||||
before do |
||||
sign_in user |
||||
end |
||||
|
||||
describe "when maintenance mode is enabled" do |
||||
before do |
||||
allow(FeatureToggle).to receive(:maintenance_mode_enabled?).and_return(true) |
||||
end |
||||
|
||||
context "when a user visits a page other than the maintenance page" do |
||||
before do |
||||
get "/lettings-logs" |
||||
end |
||||
|
||||
it "redirects the user to the maintenance page" do |
||||
expect(response).to redirect_to(service_unavailable_path) |
||||
follow_redirect! |
||||
expect(page).to have_content("Sorry, the service is unavailable") |
||||
end |
||||
|
||||
it "the cookie banner is visible" do |
||||
follow_redirect! |
||||
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.") |
||||
end |
||||
end |
||||
|
||||
context "when a user visits the maintenance page" do |
||||
before do |
||||
get "/service-unavailable" |
||||
end |
||||
|
||||
it "keeps the user on the maintenance page" do |
||||
expect(response).not_to redirect_to(service_unavailable_path) |
||||
expect(page).to have_content("Sorry, the service is unavailable") |
||||
end |
||||
|
||||
it "the cookie banner is visible" do |
||||
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "when maintenance mode is disabled" do |
||||
before do |
||||
allow(FeatureToggle).to receive(:maintenance_mode_enabled?).and_return(false) |
||||
end |
||||
|
||||
context "when a user visits a page other than the maintenance page" do |
||||
before do |
||||
get "/lettings-logs" |
||||
end |
||||
|
||||
it "doesn't redirect the user to the maintenance page" do |
||||
expect(response).not_to redirect_to(service_unavailable_path) |
||||
expect(page).to have_content("Create a new lettings log") |
||||
end |
||||
|
||||
it "the cookie banner is visible" do |
||||
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.") |
||||
end |
||||
end |
||||
|
||||
context "when a user visits the maintenance page" do |
||||
before do |
||||
get "/service-unavailable" |
||||
end |
||||
|
||||
it "redirects the user to the start page" do |
||||
expect(response).to redirect_to(root_path) |
||||
end |
||||
|
||||
it "the cookie banner is visible" do |
||||
follow_redirect! |
||||
follow_redirect! |
||||
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.") |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue