Skip to content

ministryofjustice/prison-visits-2

Repository files navigation

Maintainability Test Coverage prison-visits-2 repo standards badge

Online visit requests

A staff service for reviewing social visit requests to visit a prisoner in England or Wales.

Live application

Production application can be found at https://staff.prisonvisits.service.justice.gov.uk accessed via DPS.

Technical Information

This is a Ruby on Rails application that has two main roles. It exposes:

  1. A public interface for staff to manage prison visit bookings.
  2. An API for booking prison visits. The consumer of this API is ministryofjustice/prison-visits-public.

This is a full rewrite from the ground up, using a database instead of serialised data in URLs in emails. The CSS and JavaScript has largely been ported intact from the previous application.

The source of the predecessor can be found at ministryofjustice/prison-visits.

Dependencies

  • ministryofjustice/prison-visits-public - this a separate Ruby on Rails application that contains the public interface for booking a prison visit.
  • If on a Mac install Xcode from the App Store
  • HMPPS Auth - for logging into the bookings management interface.
  • Sidekiq - for background processing.
  • Redis - for managing queues (required by Sidekiq)
  • Postgres - for persisting data
  • direnv - for managing environment variables and storing credentials.
  • NOMIS API access - prison and offender data is accessed via the National Offender Management Information System. An authentication token is required to access this.
  • (Optional) Transifex Client - for managing site translation. See additional documentation for setup and updating translations.

Ruby version

This application uses Ruby v3.2.2. Use RVM or similar to manage your ruby environment and sets of dependencies.

Running the application

Note - You will need to spin up both ministryofjustice/prison-visits-2 and ministryofjustice/prison-visits-public

  1. Install gems (dependencies) locally. To do this you will need to first install Bundler

  2. Install packages with [yarn] https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable

  3. Install the direnv package

    pvb2 $ brew install direnv
  4. Enable direnv for you shell

    BASH

    Add the following line at the end of the ~/.bashrc file:

    eval "$(direnv hook bash)"

    Make sure it appears even after rvm, git-prompt and other shell extensions that manipulate the prompt.

    ZSH

    Add the following line at the end of the ~/.zshrc file:

    eval "$(direnv hook zsh)"
    FISH

    Add the following line at the end of the ~/.config/fish/config.fish file:

    direnv hook fish | source
  5. Create a .env file in the root of the folder and add any necessary environment variables. Load your environment variables into your current session ...

    pvb2 $ direnv allow .
  6. Install Postgres

    pvb2 $ brew install postgres
    
  7. Install Redis

    pvb2 $ brew install redis
  8. In separate terminal windows spin up ministryofjustice/prison-visits-2 and Sidekiq. The latter processes jobs in the background. Make sure you have the necessary environment variables declared to run Sidekiq. See additional documentation on queues.

    pvb2 $ bundle exec sidekiq
    pvb2 $ rails server
  9. In another terminal window spin up ministryofjustice/prison-visits-public on port 4000

    pvb-public $ rails server -p 4000

Rake tasks

  1. Set up database and seed with prison data

    pvb2 $ rake db:setup
  2. Seed database with visits data

    pvb2 $ rake pvb:populate:visits

Running the test suite

pvb2 $ rails spec

Further technical information

Licence

MIT Licence (MIT)