Skip to content

Commit

Permalink
ER-764 Remove deprecated non-CMS files (#774)
Browse files Browse the repository at this point in the history
* - Retire unused libraries, content, environment variables, tests, and code
- Add missing specs, correct inaccurate specs and boost coverage over 90%
- Rename methods and objects to be semantic and consistent
- Refactor helpers and controllers simplifying logic
- Dry up training controllers moving common logic into a module
- Prune, consolidate and organise locales for fewer microcopy resources
- Update documentation, pipelines, docker and linting exemptions
- Replace remaining ActiveHash objects
- Namespace new models used in the registration journey
- Add migration and seeding task for CMS powered user setting options
- Add setting, role and authority data debugging panel
- Make verbose console output optional

* Extra relevant user journey tickets

* Retest using genuine content

* Revert to demo content in review
  • Loading branch information
peterdavidhamilton authored Aug 21, 2023
1 parent ea243e5 commit 33b5bed
Show file tree
Hide file tree
Showing 373 changed files with 2,322 additions and 22,940 deletions.
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# ------------------------------------------------------------------------------

VERBOSE=true

# automated queries of secure pages
BOT_TOKEN=bot

Expand Down Expand Up @@ -62,9 +64,6 @@ GOOGLE_CLOUD_BUCKET=
DASHBOARD_UPDATE=y # optional upload activation for local dev
DASHBOARD_UPDATE_INTERVAL=*/5 * * * *

# alternative content
TRAINING_MODULES=demo-modules

# Contentful
CONTENTFUL=true
# (overrides)
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
DATABASE_URL: postgres://postgres:password@localhost:5432/test
DOMAIN: recovery.app
TRAINING_MODULES: demo-modules
BOT_TOKEN: bot_token

services:
Expand Down Expand Up @@ -76,24 +75,17 @@ jobs:
-
name: Compile assets
run: bundle exec rails assets:precompile
# -
# name: Validate content
# run: bundle exec rails eyfs:cms:validate
-
name: Run rubocop
run: bundle exec rubocop
-
name: Run test suite (YAML)
name: Run test suite
run: bundle exec rspec
env:
CONTENTFUL: false
-
name: Validate content (CMS)
run: bundle exec rails eyfs:cms:validate
-
name: Run test suite (CMS)
run: bundle exec rspec

# Re-test CMS question response data migration feature
name: Run rubocop
run: bundle exec rubocop
# -
# name: Run test suite (CMS)
# name: Run test suite
# run: bundle exec rspec
# env:
# DISABLE_USER_ANSWER: true
1 change: 0 additions & 1 deletion .github/workflows/tf-azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ env:
TF_VAR_webapp_config_rails_master_key: ${{ secrets.WEBAPP_CONFIG_RAILS_MASTER_KEY }}
TF_VAR_webapp_config_rails_max_threads: ${{ vars.WEBAPP_CONFIG_RAILS_MAX_THREADS }}
TF_VAR_webapp_config_rails_serve_static_files: ${{ vars.WEBAPP_CONFIG_RAILS_SERVE_STATIC_FILES }}
TF_VAR_webapp_config_training_modules: ${{ vars.WEBAPP_CONFIG_TRAINING_MODULES }}
TF_VAR_webapp_config_web_concurrency: ${{ vars.WEBAPP_CONFIG_WEB_CONCURRENCY }}

jobs:
Expand Down
11 changes: 4 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'lib/seed_course_entries.rb'

# Offense count: 1
Lint/ShadowedException:
Exclude:
Expand Down Expand Up @@ -48,16 +43,18 @@ Rails/Output:
- 'app/jobs/dashboard_job.rb'
- 'app/jobs/fill_page_views_job.rb'
- 'app/models/concerns/to_csv.rb'
- 'app/services/contentful_data_integrity.rb'
- 'app/services/content_integrity.rb'
- 'app/services/dashboard.rb'

# Offense count: 7
# Offense count: 10
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowImplicitReturn, AllowedReceivers.
Rails/SaveBang:
Exclude:
- 'app/controllers/registrations_controller.rb'
- 'app/controllers/training/responses_controller.rb'
- 'app/forms/users/setting_type_form.rb'
- 'config/sitemap.rb'
- 'lib/content_seed.rb'
- 'lib/seed_images.rb'
- 'spec/forms/users/setting_type_form_spec.rb'
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ gem 'slim-rails'
# Headless CMS
gem 'contentful_rails'

# Create models from static data such as hashes or YAML
gem 'active_hash'

# TODO: add ey-recovery to https://github.com/DFE-Digital/govuk-components
gem 'govuk-components'
gem 'govuk_design_system_formbuilder'
Expand All @@ -65,9 +62,6 @@ gem 'govuk_notify_rails'
gem 'sentry-rails'
gem 'sentry-ruby'

# Validate and normalise user postcodes
gem 'uk_postcode'

# Manage seeds
gem 'dibber'

Expand Down
5 changes: 0 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_hash (3.1.1)
activesupport (>= 5.0.0)
activejob (7.0.6)
activesupport (= 7.0.6)
globalid (>= 0.3.6)
Expand Down Expand Up @@ -755,7 +753,6 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
uk_postcode (2.1.8)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
Expand Down Expand Up @@ -799,7 +796,6 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
active_hash
ahoy_matey
better_errors
binding_of_caller
Expand Down Expand Up @@ -856,7 +852,6 @@ DEPENDENCIES
time (>= 0.2.2)
turbo-rails
tzinfo-data
uk_postcode
uri (>= 0.12.1)
web-console
yard-junk
Expand Down
20 changes: 20 additions & 0 deletions app/builders/early_years_recovery_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,24 @@ def question_check_box(option)
disabled: option.disabled?,
checked: option.checked?
end

def select_trainee_setting
govuk_collection_select :setting_type_id,
Trainee::Setting.all, :name, :title,
options: { include_blank: true },
label: { text: I18n.t('register_setting.label'), class: 'govuk-visually-hidden' },
data: { controller: 'autocomplete', 'autocomplete-message-value': I18n.t('register_setting.not_found') },
aria: { label: 'registration setting type' },
form_group: { classes: %w[data-hj-suppress] }
end

def select_trainee_authority
govuk_collection_select :local_authority,
Trainee::Authority.all, :name, :name,
options: { include_blank: true },
label: { text: I18n.t('register_authority.label'), class: 'govuk-visually-hidden' },
data: { controller: 'autocomplete', 'autocomplete-message-value': I18n.t('register_authority.not_found') },
aria: { label: 'registration local authority' },
form_group: { classes: %w[data-hj-suppress] }
end
end
8 changes: 2 additions & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :set_analytics_tracking_id,
:set_hotjar_site_id,
:set_internal_mailbox_email_address,
:prepare_cms

helper_method :timeout_timer,
helper_method :current_user,
:timeout_timer,
:debug?

default_form_builder(EarlyYearsRecoveryFormBuilder)
Expand Down Expand Up @@ -51,10 +51,6 @@ def set_hotjar_site_id
@hotjar_id = Rails.configuration.hotjar_site_id
end

def set_internal_mailbox_email_address
@internal_mailbox = Rails.configuration.internal_mailbox
end

# @return [Boolean] do not run accessibility tests with debug panels visible
def debug?
Rails.application.debug? && !bot?
Expand Down
44 changes: 0 additions & 44 deletions app/controllers/assessment_results_controller.rb

This file was deleted.

13 changes: 6 additions & 7 deletions app/controllers/close_accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ class CloseAccountsController < ApplicationController

def show; end

def new
current_user
end
def new; end

def update
if current_user.valid_password?(user_password_params[:current_password])
Expand All @@ -23,15 +21,16 @@ def reset_password

def close_account
current_user.send_account_closed_notification
User.new(email: @internal_mailbox).send_account_closed_internal_notification(current_user.email)

# TODO: refactor this internal user mailer logic
User.new(email: Rails.configuration.internal_mailbox).send_account_closed_internal_notification(current_user.email)

current_user.redact!
sign_out current_user
redirect_to user_close_account_path
end

def edit_reason
current_user
end
def edit_reason; end

def update_reason
current_user.context = :close_account
Expand Down
63 changes: 39 additions & 24 deletions app/controllers/concerns/learning.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
#
# OPTIMIZE: potentially dry-er course content controllers
#
module Learning
# def mod_name
# params[:training_module_id]
# end
# @return [String]
def mod_name
params[:training_module_id]
end

# def content_name
# params[:id]
# end
# @return [String]
def content_name
params[:id]
end

# def mod
# Training::Module.by_name(mod_name)
# end
# @return [Training::Module]
def mod
Training::Module.by_name(mod_name)
end

# def content
# mod.page_by_name(content_name)
# end
# @return [Training::Page, Training::Video, Training::Question]
def content
mod.page_by_name(content_name)
end

# def module_progress
# ContentfulModuleOverviewDecorator.new(progress)
# end
# @return [ModuleOverviewDecorator]
def module_progress
ModuleOverviewDecorator.new(progress_service)
end

# def progress_bar
# ContentfulModuleProgressBarDecorator.new(progress)
# end
# @return [ModuleProgressBarDecorator]
def progress_bar
ModuleProgressBarDecorator.new(progress_service)
end

# def progress
# helpers.cms_module_progress(mod)
# end
# @return [AssessmentProgress]
def assessment
helpers.assessment_progress_service(mod)
end

# @return [ModuleProgress]
def progress_service
helpers.module_progress_service(mod)
end

# @note memoization ensures validation errors work
# @return [UserAnswer, Response]
def current_user_response
@current_user_response ||= current_user.response_for(content)
end
end
Loading

0 comments on commit 33b5bed

Please sign in to comment.