Skip to content

Webapp to manage the workflow in Parliamentary Questions

License

Notifications You must be signed in to change notification settings

ministryofjustice/parliamentary-questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


MoJ logo

Parliamentary Questions

repo standards badge

Introduction

Webapp to manage the workflow Parliamentary Questions

Development

Working on the Code

Work should be based off of, and PRed to, the main branch. We use the GitHub PR approval process so once your PR is ready you'll need to have one person approve it, and the CI tests passing, before it can be merged.

Basic Setup

Cloning This Repository

Clone this repository then cd into the new directory

$ git clone [email protected]:ministryofjustice/parliamentary-questions.git
$ cd parliamentary-questions

Installing the app for development

Latest Version of Ruby

If you don't have rbenv already installed, install it as follows:

$ brew install rbenv ruby-build
$ rbenv init

Follow the instructions printed out from the rbenv init command and update your ~/.bash_profile or equivalent file accordingly, then start a new terminal and navigate to the repo directory.

Use rbenv to install the latest version of ruby as defined in .ruby-version (make sure you are in the repo path):

$ rbenv install

Dependencies

Postgresql

$ brew install postgresql

Setup

Use the following commands to install gems and javascript packages then create the database

$ bin/setup

Seeds

Mock data can be automatically imported by running the following rake task (it will make use of a mock API server running on localhost:8888 so make sure this port is free):

''' $ bundle exec rake pqa:import_dummy_data


Finally, a rake task is also provided to load PQ&A XML data into the system.

$ bundle exec rake pqa:import_from_xml[path/to/question_file.xml]


#### Running locally:

To just run the web server without any background jobs (usually sufficient):

$ bin/rails server


The site will be accessible at http://localhost:3000.

#### Running the tests

In order to run the tests, you can use:

```sh
bundle exec rake

This will run specs and rubocop linting. Or you can run them individually, with rake rubocop and rake spec.

User authentication

It's done using devise and devise invitable:

For development you can create users with a rake task.

# default user
rake user:create

# admin user
rake user:create_admin

# specific email, password, name
rake "user:create_admin[[email protected], 123456789, admin]"

Emails

Emails are sent using the GOVUK Notify service.

Please refer to the readmein the mailers folder for details of how to get an account and obtain an API key.

Exceptions

Any exceptions raised in any deployed environment will be sent to Sentry.

Environment Variables

This is an up to date list of the environment variables used by the app. Refer to the provisioning code for the actual values expected to be set on each specific environment.

For local development, the only mandatory variables are PQ_REST_API_HOST, DEVISE_SENDER and TEST_USER_PASS. PQ_REST_API_HOST should be set to http://localhost:8888, as it is the default hostname/port used by the mock implementation of Parliament's Question and Answer API. TEST_USER_PASS can be set to any value. DEVISE_SENDER can be set to [email protected]. Instructions on setting up the GOVUK_NOTIFY_API_KEY can be found in the mailer readme.

Variable Name Required for local development Description
PQ_REST_API_HOST y Hostname of the Parlamentary Question and Answers API
PQ_REST_API_USERNAME n Username
PQ_REST_API_PASSWORD n Password
DEVISE_SECRET n Secret Devise Token
DEVISE_SENDER y Email address used for signup/signin/password related notifications
SENDING_HOST n Host for URLs in emails
CA_CERT n Absolute Path of the system's SSL certificates dir (e.g. /etc/ssl/certs)
ASSET_HOST n Host where Rails' assets pipeline will deploy the assets
TEST_USER n The current application version tag
TEST_USER_PASS y The password for the test users created by rake db:staging:sync and smoke tests
GOVUK_NOTIFY_API_KEY y A key required to send emails via GovUK Notify

You can add the env variables required for local development to your bash_profile using the format:

export [NAME_OF_VARIABLE]=[VALUE-OF-VARIABLE]

for example:

export GOVUK_NOTIFY_API_KEY=a-super-great-key