This is the code base for the Senedd's petitions service (https://petitions.senedd.wales).
We recommend using Docker Desktop to get setup quickly. If you'd prefer not to use Docker then you'll need Ruby (3.0+), Node (14+), PostgreSQL (11+) and Memcached (1.5+) installed.
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 welshpets.local
127.0.0.1 cymraegpets.local
127.0.0.1 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 welshpets.lvh.me
and override the default domains using a .env.local
file:
EPETITIONS_HOST_EN=welshpets.lvh.me
EPETITIONS_HOST_CY=cymraegpets.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_cy
and moderate_url
columns on the record in the sites
table.
docker compose run --rm web rake db:prepare
docker compose run --rm web rake wpets:add_sysadmin_user
docker compose run --rm web rake wpets:geography:import
docker compose run --rm web rails runner 'FetchMembersJob.perform_now'
docker compose run --rm web rails runner 'Site.enable_signature_counts!(interval: 10)'
docker compose up
Once the services have started you can access the front end and back end.
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
Dyma sylfaen cod gwasanaeth deisebau Senedd (https://deisebau.senedd.cymru).
Rydym yn argymell defnyddio [Docker Desktop] 1 i gael setup yn gyflym. Os byddai'n well gennych beidio â defnyddio Docker yna bydd angen Ruby (3.0+), Node (14+), PostgreSQL (11+) a Memcached (1.5+) arnoch chi wedi'u gosod.
Mae'r rhaglen yn defnyddio parthau i wahaniaethu rhwng gwahanol agweddau felly bydd angen i chi osod y cofnodion DNS canlynol yn eich ffeil /etc/hosts
leol:
127.0.0.1 welshpets.local
127.0.0.1 cymraegpets.local
127.0.0.1 moderatepets.local
Os nad ydych chi am olygu eich ffeil /etc/hosts
neu os ydych chi ar Windows yna gallwch ddefnyddio DNS cerdyn gwyllt cyhoeddus fel welshpets.lvh.me
a diystyru'r parthau diofyn gan ddefnyddio .env.local
ffeil:
EPETITIONS_HOST_EN=welshpets.lvh.me
EPETITIONS_HOST_CY=cymraegpets.lvh.me
MODERATE_HOST=moderatepets.lvh.me
Os gwnewch hyn cyn rhedeg yr ap am y tro cyntaf, bydd yn codi'r rhain yn awtomatig, fel arall bydd angen i chi ddefnyddio cleient PostgreSQL i olygu'r colofnau url_en
, url_cy
a moderate_url
ar y cofnod yn y bwrdd safleoedd
.
docker compose run --rm web rake db:setup
docker compose run --rm web rake wpets:add_sysadmin_user
docker compose run --rm web rails runner 'Site.enable_signature_counts!(interval: 10)'
docker compose up
Unwaith y bydd y gwasanaethau wedi cychwyn gallwch gael mynediad i'r pen blaen a'r pen cefn.
Gallwch chi redeg y gyfres brawf lawn gan ddefnyddio'r gorchymyn canlynol:
docker compose run --rm web rake
Gellir rhedeg specs unigol gan ddefnyddio'r gorchymyn canlynol:
docker compose run --rm web rspec spec/models/site_spec.rb
Yn yr un modd, gellir rhedeg nodweddion ciwcymbr unigol gan ddefnyddio'r gorchymyn canlynol:
docker compose run --rm web cucumber features/suzie_views_a_petition.feature