Skip to content

ministryofjustice/prison-visits-public

Repository files navigation

Maintainability Test Coverage

Visit someone in prison

A service for booking a social visit to a prisoner in England or Wales

Live application

Production application is made available through GOV.UK and can be found at https://www.gov.uk/prison-visits

Technical Information

This a Ruby on Rails application that contains the public interface for booking a prison visit.

It is stateless and relies entirely on the prison visits booking API exposed by ministryofjustice/prison-visits-2.

The codebase was split from ministryofjustice/prison-visits-2, which previously was also responsible for serving the public interface.

Dependencies

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-public and ministryofjustice/prison-visits-2

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

  2. Install the direnv package

    pvb2 $ brew install direnv
  3. 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
  4. Create a .env file in the root of the folder and add any necessary environment variables. Load your environment variables into your current session ...

    pvb-public $ direnv allow .
  5. In separate terminal windows start up ministryofjustice/prison-visits-2 and Sidekiq. The latter processes jobs in the background.

    pvb-public $ bundle exec sidekiq
    pvb-public $ rails server
  6. In another terminal window start up ministryofjustice/prison-visits-public on port 4000

    pvb-public $ rails server -p 4000

Running the test suite

pvb-public $ rspec spec

Testing approach

During testing, the approach is to stub/mock API calls at the level of the API client, rather than at the HTTP level, since this is considerably cleaner, and decouples API changes. An example of this approach can be seen in prisoner_step_spec.rb.

The API client is then tested by recording real API interactions using VCR. The only tests recording VCR cassettes should be defined in api_spec.rb. If the API changes the appropriate cassettes should be deleted and re-recorded.

Further Technical Information

Licence

MIT Licence (MIT)