Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: alphagov/e-petitions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.30
Choose a base ref
...
head repository: alphagov/e-petitions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Feb 2, 2016

  1. Update rspec-rails to 3.4.2

    The changes in rspec-rails 3.4.1 to fix the problems with Rails 4.2.5.1
    introduced a performance regression due to template lookup not being
    cached. Timing tests show that it doesn't really affect our controller
    specs (probably due to the large amounts of factories created) but it's
    a minimal change so worth having.
    pixeltrix committed Feb 2, 2016
    Copy the full SHA
    36bfadc View commit details

Commits on Feb 12, 2016

  1. Use Ruby instead of SQL to migrate data

    During testing on preview the migration took approximately 40 minutes
    to run during which time no inserts would be possible. Iterating over
    all of the rows in Ruby and updating them one by one is much slower
    but doesn't lock the whole table. Tests on a MacBook Pro showed the
    migration to take about 4-5 hours but can be left running in the
    background whilst petitions are still being signed.
    pixeltrix committed Feb 12, 2016
    Copy the full SHA
    fa3948a View commit details

Commits on Feb 14, 2016

  1. Merge pull request #438 from alphagov/migration-tasks

    Use Ruby instead of SQL to migrate data
    pixeltrix committed Feb 14, 2016
    Copy the full SHA
    8316246 View commit details
  2. Retry signature validation if the schema changes

    When a schema change occurs on the signatures table the prepared statement
    cache for the lock becomes invalid and the PostgreSQL adapter will raise
    PG::InFailedSqlTransaction. Because the transaction is already invalid any
    attempt to deallocate the statement fails - see rails/rails#12330.
    
    Whilst any general approach that retries the transaction block after
    clearing the cache is not a workable solution it's one that can work
    in this instance. We only retry the once - if clearing the cache doesn't
    help then the cause of the transaction failure is somewhere else.
    pixeltrix committed Feb 14, 2016
    Copy the full SHA
    c0ed0e4 View commit details

Commits on Feb 17, 2016

  1. Don't load all petitions on the home page

    The none? method on relations isn't optimised until Rails 5.0 so
    use the alternative method empty? which is optimised.
    pixeltrix committed Feb 17, 2016
    Copy the full SHA
    13d6e32 View commit details
  2. Fix migrations task for country petition journals

    A `TRUNCATE` followed by an `INSERT ... FROM` doesn't really work that
    well on a busy site like the petitions website because new journals will
    start to appear before the `INSERT` completes. Fix this by doing it in
    Ruby and locking the journals before calculating the signatures.
    
    To do this in a performant manner we need an index on the petition_id
    and location_code for the signatures table. We need to do this
    concurrently otherwise it will block writes to the table, preventing
    anyone from signing any petitions.
    pixeltrix committed Feb 17, 2016
    Copy the full SHA
    53a8921 View commit details
  3. Merge pull request #443 from alphagov/fix-journals-migration-task

    Fix migrations task for country petition journals
    alanth committed Feb 17, 2016
    Copy the full SHA
    5f03442 View commit details
  4. If there's no sitting MP hide the link

    When the first MP in the API response has a non-empty `<EndDate>` element
    then either the MP has stepped down or passed away. In this scenario we
    should update the constituency record to clear the MP details and not
    show any link on the local search results page.
    pixeltrix committed Feb 17, 2016
    Copy the full SHA
    11fc547 View commit details

Commits on Feb 21, 2016

  1. Merge pull request #432 from alphagov/update-rspec-rails-to-3-4-2

    Update rspec-rails to 3.4.2
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    41e7757 View commit details
  2. Merge pull request #442 from alphagov/fix-petition-loading-on-home-page

    Don't load all petitions on the home page
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    e7370b2 View commit details
  3. Merge pull request #440 from alphagov/retry-validate-on-schema-change

    Retry signature validation if the schema changes
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    c4dc5db View commit details
  4. Merge pull request #444 from alphagov/fix-mp-passing-away

    If there's no sitting MP hide the link
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    261a33c View commit details
  5. Promote feedback model to a full AR model for persistence

    In #421 we moved email sending to custom jobs so that we could provide
    better error handling. However, the feedback email wasn't done since
    that was based on a custom Active Model model. To work around this
    change the model to an Active Record model so that it is persisted to
    the database and Active Job can serialize it via Global ID.
    
    This has the added benefit of storing the feedback should the email sent
    to the feedback address somehow get lost due to spam filtering, etc.
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    c666abb View commit details
  6. Revert "Update rspec-rails to 3.4.2"

    This reverts commit 36bfadc.
    
    Upgrading rspec-core to 3.4.2 caused CodeDeploy to fail to find the gem
    during `bundle install` from vendor/cache in the AfterInstall phase.
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    4573ced View commit details
  7. Merge pull request #441 from alphagov/promote-feedback-to-ar-model

    Promote feedback model to a full AR model for persistence
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    63859fc View commit details
  8. Copy the full SHA
    7a57c7a View commit details
  9. Copy the full SHA
    175f1f2 View commit details
  10. Merge pull request #439 from alphagov/cleanup-country-columns-again

    Cleanup country columns again
    pixeltrix committed Feb 21, 2016
    Copy the full SHA
    46661c3 View commit details

Commits on Feb 23, 2016

  1. Remove be_valid_asset gem

    pixeltrix committed Feb 23, 2016
    Copy the full SHA
    b0bfa90 View commit details
  2. Copy the full SHA
    d420d39 View commit details
  3. Copy the full SHA
    75da6f4 View commit details
  4. Copy the full SHA
    09f6778 View commit details
  5. Copy the full SHA
    abf0b5c View commit details
  6. Only use @javascript where necessary

    The HTML that comes back from phantomjs isn't the HTML that
    was served so we can't check if it's valid XML.
    pixeltrix committed Feb 23, 2016
    Copy the full SHA
    29fb82f View commit details
  7. Don't validate CSS

    pixeltrix committed Feb 23, 2016
    Copy the full SHA
    f0e6ef8 View commit details
  8. Copy the full SHA
    90e4528 View commit details

Commits on Feb 24, 2016

  1. Fix redirect to login for delayed-web gem

    In 0bd5c2e the url helper used for authentication redirects was changed
    from admin_login_path to admin_login_url but as the delayed-web config
    was missed from that change it was generating a 500 error instead.
    pixeltrix committed Feb 24, 2016
    Copy the full SHA
    6eebce5 View commit details

Commits on Feb 29, 2016

  1. Copy the full SHA
    dbb533d View commit details

Commits on Mar 1, 2016

  1. Use HTML parser to validate document markup

    As the status of polyglot markup is either deprecated or undefined it's
    better to use a HTML parser to validate the markup. The issue is that it
    seems that Nokogiri doesn't support any HTML5 tags so we need to filter
    out the errors created by those. Adding the tags to Nokogiri directly
    appears to be non-trivial.
    pixeltrix committed Mar 1, 2016
    Copy the full SHA
    5cee223 View commit details

Commits on Mar 2, 2016

  1. Merge pull request #445 from alphagov/remove-be-valid-asset

    Remove be_valid_asset gem
    h-lame committed Mar 2, 2016
    Copy the full SHA
    10ea56b View commit details
  2. Merge pull request #446 from alphagov/fix-admin-login-redirect-in-dj-web

    Fix redirect to login for delayed-web gem
    h-lame committed Mar 2, 2016
    Copy the full SHA
    7074e7e View commit details
  3. Merge pull request #447 from alphagov/update-to-rails-4-2-5-2

    Update to Ruby on Rails 4.2.5.2
    h-lame committed Mar 2, 2016
    Copy the full SHA
    28681e1 View commit details

Commits on Apr 11, 2016

  1. Use round instead of floor to calculate number of days

    If the time span covered the date when the clocks went forward
    then the number of days was off by one.
    pixeltrix committed Apr 11, 2016
    Copy the full SHA
    4faaba1 View commit details
  2. Make session cookie last for two weeks to work around iOS bug

    Mobile Safari has a tendency to use cached form values even when the
    cache control headers tell it otherwise. However the session cookie
    has expired so when the form is submitted the CSRF token is invalid.
    
    See rails/rails#21948 for further details.
    
    Fixes #451.
    pixeltrix committed Apr 11, 2016
    Copy the full SHA
    fe9db94 View commit details

Commits on Apr 12, 2016

  1. Merge pull request #453 from alphagov/fix-422-errors-on-ios

    Fix 422 errors on iOS
    h-lame committed Apr 12, 2016
    Copy the full SHA
    a335379 View commit details

Commits on Apr 13, 2016

  1. Enable CSRF protection in test mode

    The default is to disable CSRF protection in test mode but without it
    enabled we can't test what the session cookie expiry date is set to.
    pixeltrix committed Apr 13, 2016
    Copy the full SHA
    a5749c7 View commit details
  2. Only test the right cookie

    There may be multiple Set-Cookie headers so we need to split them
    on the new line character and find the right one.
    pixeltrix committed Apr 13, 2016
    Copy the full SHA
    e4de47e View commit details
  3. Add test for #453 session cookie expiry date change

    This is somewhat akin to testing Rails functionality but it's here so
    that it doesn't get changed back again as it's not the Rails default.
    pixeltrix committed Apr 13, 2016
    Copy the full SHA
    73af0d3 View commit details
  4. Merge pull request #454 from alphagov/really-fix-422-errors

    Add tests for #453
    h-lame committed Apr 13, 2016
    Copy the full SHA
    e3696eb View commit details
  5. Copy the full SHA
    e07ce24 View commit details

Commits on Apr 14, 2016

  1. Copy the full SHA
    2cae76e View commit details
  2. Add relative dates

    leandroalemao committed Apr 14, 2016
    Copy the full SHA
    5094590 View commit details
  3. Support new /records schema

     Response for `/records` resource from country register will be changed very soon. It will start returning new map based response specified in register specification (https://openregister.github.io/specification/#records-resource) rather than current array based response.
    
      Changes in the PR confirms that the e-petitions is forward compatible with the new-schema from country register. This will keep e-petitions code working for both new and old schema. It allow allows country register to publish new response independently.
    
      Same set of tests are added for the new schema and implemented the solution to support both schemas. The old-schema tests/code can be  deleted after country register starts publishing the new-schema.
    om-sharma committed Apr 14, 2016
    Copy the full SHA
    eff28f6 View commit details
  4. Copy the full SHA
    8db8df9 View commit details

Commits on Apr 18, 2016

  1. Copy the full SHA
    4700c6f View commit details

Commits on Apr 22, 2016

  1. Merge pull request #457 from om-sharma/forward-compatible

    Support new `/records` resource schema from country register
    alanth committed Apr 22, 2016
    Copy the full SHA
    e868405 View commit details
  2. Merge pull request #455 from om-sharma/document-user-creation

    Documentation to create `epets` user  to setup development environment
    alanth committed Apr 22, 2016
    Copy the full SHA
    dd800e2 View commit details
  3. Merge pull request #456 from leandroalemao/add_debate_date_to_awaitin…

    …g_debate_petitions_view
    
    Add scheduled debate date to awaiting debate petitions view
    pixeltrix committed Apr 22, 2016
    Copy the full SHA
    077ced0 View commit details
  4. Change 'To be debated on' to 'Scheduled for debate on'

    Sometimes things change at the last minute due to emergencies, etc. so
    clarify that the debate is scheduled and not a cast-iron guarantee that
    it will actually take place.
    pixeltrix committed Apr 22, 2016
    Copy the full SHA
    d3f69e6 View commit details
  5. Merge pull request #459 from alphagov/change-debate-wording

    Change 'To be debated on' to 'Scheduled for debate on'
    alanth committed Apr 22, 2016
    Copy the full SHA
    5e0e785 View commit details
Showing 1,628 changed files with 90,794 additions and 19,321 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/log/*
/pkg/*
/tmp/*
/node_modules/*
10 changes: 7 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# This file contains only items shared by all environments. You should probably
# place options in .env.development or .env.test or similar instead of here

PETITION_DURATION=6
MINIMUM_NUMBER_OF_SPONSORS=5
MAXIMUM_NUMBER_OF_SPONSORS=20
THRESHOLD_FOR_MODERATION=5
THRESHOLD_FOR_RESPONSE=10000
THRESHOLD_FOR_DEBATE=100000
EPETITIONS_HOST=petitions.localhost
EPETITIONS_PORT=3000
EPETITIONS_PROTOCOL=http
MODERATE_HOST=moderate.petitions.localhost
GEOIP_DB_PATH=/path/to/GeoLite2-Country.mmdb
SMTP_HOST=mailcatcher.localhost
SMTP_PORT=1025
8 changes: 1 addition & 7 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
DATABASE_URL=postgres://postgres@localhost/epets_development
SECRET_KEY_BASE=FA11FA11FA11FA11FA11
EPETITIONS_HOST=localhost
EPETITIONS_PORT=3000
EPETITIONS_PROTOCOL=http
MODERATE_HOST=localhost
SITE_TITLE="Petition parliament (Development)"
MEMCACHE_SERVERS=localhost:11211
GEOIP_DB_PATH=/app/tmp/GeoIP/GeoLite2-Country.mmdb
4 changes: 1 addition & 3 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
DATABASE_URL=postgres://postgres@localhost/epets_test
SECRET_KEY_BASE=FA11FA11FA11FA11FA11
EPETITIONS_HOST=petition.parliament.uk
EPETITIONS_PORT=443
EPETITIONS_PROTOCOL=https
MODERATE_HOST=moderate.petition.parliament.uk
SITE_TITLE="Petition parliament (Test)"
MEMCACHE_SERVERS=localhost:11211
INLINE_UPDATES=true
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.sh text eol=lf
bin/* text eol=lf
55 changes: 55 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: 2
updates:
- package-ecosystem: bundler
ignore:
- dependency-name: "rails"
update-types: ["version-update:semver-minor"]
- dependency-name: "*"
update-types: ["version-update:semver-major"]
directory: /
schedule:
interval: daily
versioning-strategy: increase-if-necessary
open-pull-requests-limit: 10
groups:
aws:
applies-to: version-updates
patterns:
- "aws-*"
update-types:
- "minor"
- "patch"
rails:
applies-to: version-updates
patterns:
- "action*"
- "active*"
- "rails"
- "railties"
update-types:
- "patch"

- package-ecosystem: npm
directory: /
schedule:
interval: daily
versioning-strategy: increase-if-necessary

# Ruby needs to be upgraded manually in multiple places, so cannot be upgraded by Dependabot.
- package-ecosystem: docker
ignore:
- dependency-name: ruby
directory: /docker/mailcatcher
schedule:
interval: weekly
- package-ecosystem: docker
ignore:
- dependency-name: ruby
directory: /docker/ruby
schedule:
interval: weekly

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
107 changes: 107 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Build

on:
workflow_call:
inputs:
description:
type: string
required: true
command:
type: string
required: true
spec_opts:
type: string
required: false
default: ""
cucumber_format:
type: string
required: false
default: ""
cucumber_opts:
type: string
required: false
default: ""
save_screenshots:
type: boolean
required: false
default: false
save_logs:
type: boolean
required: false
default: false

jobs:
build:
runs-on: ubuntu-24.04

services:
postgres:
image: postgres:16
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
PGUSER: postgres
PGPASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Update repository lists
shell: bash
run: |
sudo apt-get update
- name: Install packages
shell: bash
run: |
sudo apt-get -yqq install libpq-dev imagemagick libvips
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
cache-version: 1

- name: Setup database
shell: bash
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/epets_test
RAILS_ENV: test
run: |
bundle exec rake db:setup
- name: Save screenshots
if: ${{ inputs.save_screenshots && failure() }}
uses: actions/upload-artifact@v4
with:
name: selenium-screenshots-public
path: ${{ github.workspace }}/tmp/capybara/*.png
retention-days: 7
if-no-files-found: ignore

- name: Save rails logs
if: ${{ inputs.save_logs && failure() }}
uses: actions/upload-artifact@v4
with:
name: rails-logs-public
path: ${{ github.workspace }}/log/test.log
retention-days: 7
if-no-files-found: ignore

- name: ${{ inputs.description }}
shell: bash
env:
CUCUMBER_FORMAT: "${{ inputs.cucumber_format }}"
CUCUMBER_OPTS: "${{ inputs.cucumber_opts }}"
DATABASE_URL: postgres://postgres:postgres@localhost:5432/epets_test
RAILS_ENV: test
SPEC_OPTS: "${{ inputs.spec_opts }}"
run: |
bundle exec ${{ inputs.command }}
103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
bundle-audit:
uses: ./.github/workflows/build.yml
with:
description: "Check bundle for known CVEs"
command: "rake bundle:audit"

brakeman:
uses: ./.github/workflows/build.yml
with:
description: "Analyse code for vulnerabilities"
command: "rake brakeman:check"

spec-admin-controllers:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec:controllers"
spec_opts: "-f doc --force-color -P spec/controllers/admin/*_spec.rb"

spec-public-controllers:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec:controllers"
spec_opts: "-f doc --force-color -P spec/controllers/*_spec.rb"

spec-jobs:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec:jobs"
spec_opts: "-f doc --force-color -P spec/jobs/**/*_spec.rb"

spec-mailers:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec"
spec_opts: "-f doc --force-color -P spec/mailers/**/*_spec.rb"

spec-models:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec"
spec_opts: "-f doc --force-color -P spec/models/**/*_spec.rb"

spec-requests:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec"
spec_opts: "-f doc --force-color -P spec/{requests,routing}/**/*_spec.rb"

spec-other:
uses: ./.github/workflows/build.yml
with:
description: "Run specs"
command: "rake spec"
spec_opts: "-f doc --force-color -P spec/{helpers,lib,presenters,tasks,validators,views}/**/*_spec.rb"

javascript:
uses: ./.github/workflows/build.yml
with:
description: "Run javascript specs"
command: "rake jasmine:ci"

cucumber-admin:
uses: ./.github/workflows/build.yml
with:
description: "Run cucumber specs"
command: "rake cucumber"
cucumber_format: "pretty"
cucumber_opts: "--tags @admin --profile default"
save_screenshots: true
save_logs: true

cucumber-public:
uses: ./.github/workflows/build.yml
with:
description: "Run cucumber specs"
command: "rake cucumber"
cucumber_format: "pretty"
cucumber_opts: "--tags 'not @admin' --profile default"
save_screenshots: true
save_logs: true

lighthouse:
uses: ./.github/workflows/e2e.yml
with:
description: "Run lighthouse specs"
command: "rake lighthouse:ci"
save_reports: true
save_logs: true
Loading