ScottishParliament / e-petitions

This is the code base for the Scottish Parliament's e-petitions service

Home Page:https://petitions.parliament.scot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scottish Petitions

This is the code base for the Scottish Parliament's petitions service (https://petitions.parliament.scot).

Setup

We recommend using Docker Desktop to get setup quickly. If you'd prefer not to use Docker then you'll need Ruby (2.7+), Node (14+), PostgreSQL (12+) and Memcached (1.5+) installed.

DNS

The application uses domains to differentiate between different aspects so you'll need to setup the following DNS records in your local /etc/hosts file:

127.0.0.1     scotspets.local albapets.local moderatepets.local

If you don't want to edit your /etc/hosts file or you're on Windows then you can use a public wildcard DNS like scotspets.lvh.me and override the default domains using a .env.local file:

EPETITIONS_HOST_EN=scotspets.lvh.me
EPETITIONS_HOST_GD=albapets.lvh.me
MODERATE_HOST=moderatepets.lvh.me

If you do this before running the app for the first time it will automatically pick these up, otherwise you'll need to use a PostgreSQL client to edit the url_en, url_gd and moderate_url columns on the record in the sites table.

Create the database

docker compose run --rm web rake db:prepare

Create an admin user

docker compose run --rm web rake spets:add_sysadmin_user

Load the postcode, constituency and region data

docker compose run --rm web rake spets:geography:import

Fetch the member list

docker compose run --rm web rails runner 'FetchMembersJob.perform_now'

Enable signature counting

docker-compose run --rm web rails runner 'Site.enable_signature_counts!(interval: 10)'

Start the services

docker compose up

Once the services have started you can access the front end and back end.

Tests

Before running any tests the database needs to be prepared:

docker compose run --rm web rake db:test:prepare

You can run the full test suite using following command:

docker compose run --rm web rake

Individual specs can be run using the following command:

docker compose run --rm web rspec spec/models/site_spec.rb

Similarly, individual cucumber features can be run using the following command:

docker compose run --rm web cucumber features/suzie_views_a_petition.feature

Specs can be automatically run on file changes with guard:

docker compose run --rm web bundle exec guard

About

This is the code base for the Scottish Parliament's e-petitions service

https://petitions.parliament.scot

License:MIT License


Languages

Language:Ruby 77.4%Language:HTML 10.1%Language:SCSS 6.3%Language:Gherkin 5.3%Language:JavaScript 0.6%Language:Shell 0.1%Language:Dockerfile 0.0%Language:CSS 0.0%