Skip to content

Commit

Permalink
Merge pull request #1822 from DFE-Digital/remove-unused-code
Browse files Browse the repository at this point in the history
Remove remaining, unused direct CRM integration code
  • Loading branch information
ethax-ross authored Jul 23, 2021
2 parents d7423d9 + 44ff27a commit ec00929
Show file tree
Hide file tree
Showing 96 changed files with 68 additions and 5,717 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Get Short SHA
id: sha
run: echo ::set-output name=short::$(echo $GITHUB_SHA | cut -c -7)

- name: Set DOCKER_IMAGE environment variable
id: docker
run: |
Expand All @@ -53,7 +53,7 @@ jobs:
echo ::set-output name=DOCKER_IMAGE::${{ env.DOCKER_REPOSITORY }}:review-${{steps.sha.outputs.short }}
echo ::set-output name=DOCKER_MASTER::""
fi
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
Expand All @@ -70,9 +70,9 @@ jobs:
${{ steps.docker.outputs.DOCKER_IMAGE }}
${{ steps.docker.outputs.DOCKER_MASTER }}
push: true
build-args:
build-args:
SHA=${{ steps.sha.outputs.short }}

- name: Slack Notification
if: failure() && github.ref == 'refs/heads/master'
uses: rtCamp/action-slack-notify@master
Expand All @@ -81,7 +81,7 @@ jobs:
SLACK_MESSAGE: 'There has been a failure building the application'
SLACK_TITLE: 'Failure Building Application'
SLACK_WEBHOOK: ${{ steps.azSecret.outputs.SLACK-WEBHOOK }}

spec_tests:
name: Unit Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}

- name: Lint Ruby
run: docker run -t --rm -v ${PWD}/out:/app/out -e RAILS_ENV=test ${{needs.build.outputs.DOCKER_IMAGE}} rubocop app config lib features spec spec_external --format json --out=/app/out/rubocop-result.json
run: docker run -t --rm -v ${PWD}/out:/app/out -e RAILS_ENV=test ${{needs.build.outputs.DOCKER_IMAGE}} rubocop app config lib features spec --format json --out=/app/out/rubocop-result.json

- name: Keep Rubocop output
if: always()
Expand All @@ -126,7 +126,7 @@ jobs:
path: ${{ github.workspace }}/out/rubocop-result.json

- name: Run Specs
run: docker-compose -f docker-compose-paas.yml run --rm db-tasks rspec --format documentation --format RspecSonarqubeFormatter --out /app/out/test-report.xml
run: docker-compose -f docker-compose-paas.yml run --rm db-tasks rspec --format documentation --format RspecSonarqubeFormatter --out /app/out/test-report.xml
env:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}

Expand Down Expand Up @@ -225,8 +225,8 @@ jobs:
env:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}

- name: Run Cucumber Tests
run: docker-compose -f docker-compose-paas.yml run --rm -e DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL db-tasks cucumber --profile=${PROFILE} --format RspecSonarqubeFormatter --out /app/out/test-report.xml
- name: Run Cucumber Tests
run: docker-compose -f docker-compose-paas.yml run --rm -e DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL db-tasks cucumber --profile=${PROFILE} --format RspecSonarqubeFormatter --out /app/out/test-report.xml
env:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}
PROFILE: continuous_integration
Expand Down Expand Up @@ -268,19 +268,19 @@ jobs:
password: ${{ steps.azSecret.outputs.ACTIONS-API-ACCESS-TOKEN }}

- name: Bring up Docker compose Stack
run: docker-compose -f docker-compose-paas.yml -f docker-compose-chrome.yml up -d
run: docker-compose -f docker-compose-paas.yml -f docker-compose-chrome.yml up -d
env:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}

- name: Run Cucumber Tests
- name: Run Cucumber Tests
run: |-
docker-compose -f docker-compose-paas.yml -f docker-compose-chrome.yml run --rm \
-e RAILS_ENV \
-e SELENIUM_HUB_HOSTNAME \
-e DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL \
-e CUC_DRIVER \
-e APP_URL \
school-experience cucumber -t @javascript --profile=${PROFILE} --format RspecSonarqubeFormatter --out /app/out/test-report.xml
school-experience cucumber -t @javascript --profile=${PROFILE} --format RspecSonarqubeFormatter --out /app/out/test-report.xml
env:
IMAGE: ${{needs.build.outputs.DOCKER_IMAGE}}
PROFILE: selenium
Expand Down Expand Up @@ -485,7 +485,7 @@ jobs:
echo "replacer.full_list(0).matchtype=REQ_HEADER" >> ./options.prop
echo "replacer.full_list(0).matchstr=Authorization" >> ./options.prop
echo "replacer.full_list(0).regex=false" >> ./options.prop
echo "replacer.full_list(0).replacement=Basic ${BASE}" >> ./options.prop
echo "replacer.full_list(0).replacement=Basic ${BASE}" >> ./options.prop
- name: ZAP Scan
uses: zaproxy/[email protected]
Expand Down
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Metrics/BlockLength:
Exclude:
- config/**/*
- spec/**/*
- spec_external/**/*

Layout/ArgumentAlignment:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ need to get the DfE Sign-in team to approve you for a school.
It's best to lint just your app directories and not those belonging to the framework, e.g.

```bash
bundle exec rubocop app config lib features spec spec_external
bundle exec rubocop app config lib features spec
```

You can copy the `script/pre-commit` to `.git/hooks/pre-commit` and `git` will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ def perform_matchback
end
end

def direct_matchback
token = @personal_information.create_signin_token(gitis_crm)

if token
verification_email(token).despatch_later!
redirect_to candidates_school_registrations_sign_in_path
else
redirect_to new_candidates_school_registrations_contact_information_path
end
end

def personal_information_params
if candidate_signed_in?
params.fetch(:candidates_registrations_personal_information, {}).permit \
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/candidates/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ class Candidates::SessionsController < ApplicationController
include GitisAuthentication

def new
@candidates_session = Candidates::Session.new(gitis_crm)
@candidates_session = Candidates::Session.new
end

def create
@candidates_session = Candidates::Session.new(gitis_crm, retrieve_params)
@candidates_session = Candidates::Session.new(retrieve_params)
@verification_code = Candidates::VerificationCode.new(retrieve_params)

if @candidates_session.valid?
Expand Down
17 changes: 2 additions & 15 deletions app/controllers/concerns/gitis_access.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
module GitisAccess
extend ActiveSupport::Concern

included do
class_attribute :use_gitis_cache
self.use_gitis_cache = false
end

def gitis_crm
Bookings::Gitis::Factory.crm read_from_cache: use_gitis_cache
end

def assign_gitis_contacts(models)
return models if models.empty?

Bookings::Gitis::ContactFetcher \
.new(gitis_crm)
.assign_to_models(models)
Bookings::Gitis::ContactFetcher.new.assign_to_models(models)
end

def assign_gitis_contact(candidate)
Bookings::Gitis::ContactFetcher \
.new(gitis_crm)
.assign_to_model(candidate)
Bookings::Gitis::ContactFetcher.new.assign_to_model(candidate)
end
end
2 changes: 1 addition & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def show
end

def privacy_policy
@policy_id = Bookings::Gitis::PrivacyPolicy.default
@policy_id = Rails.application.config.x.gitis.privacy_policy_id
end

def schools_privacy_policy; end
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/schools/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class BaseController < ApplicationController
self.forgery_protection_origin_check = false

include GitisAccess
self.use_gitis_cache = true

include DFEAuthentication
before_action :require_auth
Expand All @@ -17,8 +16,6 @@ class BaseController < ApplicationController

rescue_from MissingURN, with: :no_school_selected
rescue_from SchoolNotRegistered, with: -> { redirect_to schools_errors_not_registered_path }
rescue_from Bookings::Gitis::API::BadResponseError, with: :gitis_retrieval_error
rescue_from Bookings::Gitis::API::ConnectionFailed, with: :gitis_retrieval_error
rescue_from Faraday::ConnectionFailed, with: :gitis_retrieval_error
rescue_from GetIntoTeachingApiClient::ApiError, with: :gitis_retrieval_error

Expand Down
4 changes: 0 additions & 4 deletions app/helpers/gitis_contact_helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
module GitisContactHelper
def gitis_contact_display_phone(contact)
return contact.phone if contact.is_a?(Bookings::Gitis::Contact)

contact.secondary_telephone.presence ||
contact.telephone.presence || contact.mobile_telephone
end

def gitis_contact_display_address(contact)
return contact.address if contact.is_a?(Bookings::Gitis::Contact)

[
contact.address_line1,
contact.address_line2.presence,
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions app/jobs/cron/sync_subjects_with_gitis_job.rb

This file was deleted.

3 changes: 0 additions & 3 deletions app/jobs/gitis_job.rb

This file was deleted.

4 changes: 3 additions & 1 deletion app/models/bookings/candidate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class Bookings::Candidate < ApplicationRecord
attr_accessor :gitis_contact
alias_method :contact, :gitis_contact

GITIS_ID_FORMAT = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/.freeze

# delete_all used since there may be a lot of tokens
# and the tokens don't have any real logic
has_many :session_tokens,
Expand All @@ -19,7 +21,7 @@ class Bookings::Candidate < ApplicationRecord
foreign_key: :bookings_candidate_id,
dependent: :destroy

validates :gitis_uuid, presence: true, format: { with: Bookings::Gitis::Entity::ID_FORMAT }
validates :gitis_uuid, presence: true, format: { with: GITIS_ID_FORMAT }
validates :gitis_uuid, uniqueness: { case_sensitive: false }

scope :confirmed, -> { where.not(confirmed_at: nil) }
Expand Down
8 changes: 2 additions & 6 deletions app/models/bookings/subject_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ class SubjectSync
LIMIT = 400
BLACKLIST = YAML.load_file(Rails.root.join('db', 'data', 'gitis_subject_blacklist.yml')).freeze

def self.synchronise(crm)
new(crm).synchronise
end

def initialize(crm)
@crm = crm
def self.synchronise
new.synchronise
end

def synchronise
Expand Down
37 changes: 0 additions & 37 deletions app/models/candidates/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,4 @@ def self.signin!(token_string)

token.confirm!.candidate
end

def initialize(gitis, *args)
@gitis = gitis
super(*args)
end

def create_signin_token
return false unless lookup_contact_in_gitis

find_or_create_candidate
generate_session_token
end

private

def lookup_contact_in_gitis
contact = @gitis.find_contact_for_signin(
email: email,
firstname: firstname,
lastname: lastname,
date_of_birth: date_of_birth
)

if contact
@contact = contact
else
false
end
end

def find_or_create_candidate
@candidate = Bookings::Candidate.find_or_create_from_gitis_contact!(contact)
end

def generate_session_token
@token = @candidate.session_tokens.create!.token
end
end
6 changes: 1 addition & 5 deletions app/models/schools/csv_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ def start_of_academic_year
AcademicYear.start_for_date Time.zone.now
end

def gitis_crm
@gitis_crm ||= Bookings::Gitis::Factory.crm read_from_cache: true
end

def contact_fetcher
@contact_fetcher ||= Bookings::Gitis::ContactFetcher.new(gitis_crm)
@contact_fetcher ||= Bookings::Gitis::ContactFetcher.new
end
end
end
50 changes: 0 additions & 50 deletions app/services/bookings/gitis/accept_privacy_policy.rb

This file was deleted.

Loading

0 comments on commit ec00929

Please sign in to comment.