Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow RatesQuery date to be set using environment variable #2412

Merged

Conversation

chrisroos
Copy link
Contributor

This will allow us to deploy rates changes to Heroku and ask someone from the content team/department to factcheck the changes. This was previously hard because the RatesQuery defaulted to today's date.

This was suggested by @floehopper in a comment on the Trello card about updating the rates for register-a-birth.

I tested that this was working as expected by setting the RATES_QUERY_DATE environment variable and viewing an outcome for the register-a-birth Smart Answer.

Before

$ rails s
$ open http://localhost:3000/register-a-birth/y/afghanistan/mother/yes/same_country#pay

pr-2412-before

Observe that it's displaying the latest rates available in births_and_deaths_document_return_fees.yml.

After

$ RATES_QUERY_DATE=2015-07-30 rails s
$ open http://localhost:3000/register-a-birth/y/afghanistan/mother/yes/same_country#pay

pr-2412-after

Observe that it's displaying the earlier rates available in births_and_deaths_document_return_fees.yml.

@ikennaokpala
Copy link
Contributor

@chrisroos great piece of work.. should be good to go for #2407 et al.

I tested this locally with:

RATES_QUERY_DATE=2015-07-30 GOVUK_APP_DOMAIN=integration.publishing.service.gov.uk PLEK_SERVICE_CONTENTAPI_URI=https://www.gov.uk/api PLEK_SERVICE_STATIC_URI=https://assets-origin.integration.publishing.service.gov.uk  bundle exec rails s -p 4000

I suppose one would have to update this (RATES_QUERY_DATE) manually on heroku for factcheck..

@chrisroos
Copy link
Contributor Author

Thanks, @ikennaokpala!

I suppose one would have to update this (RATES_QUERY_DATE) manually on heroku for factcheck..

That's correct. You've reminded me that I should update the docs to explain how to do this. I'll do that as part of this branch and then get this merged.

chrisroos added 20 commits April 1, 2016 12:01
The test is already in the `SmartAnswer::Calculators` namespace so we don't
need to prefix `RatesQuery`.
To avoid having to stub a private method in our tests.
I want RatesQuery#initialize to take an array of rates so that it's easier to
test without having to amend external YAML files of data.
So that it accepts an array of rates hashes, instead of a filename. This should
make it easier to test some changes I want to make to this class.
I _think_ this makes it clearer that we want #rates to return different values
when called with different arguments.
I think `date` is clear enough as a parameter name.
I want a test around the existing behaviour before changing the implementation.

Note the use of `Date.today - 1.day` and `Date.today + 1.day` to obtain
yesterday's and today's dates. I initially used `Date.yesterday` and
`Date.tomorrow` but in some cases found that `Date.tomorrow` returned
the same date as `Date.today` (see below). It's possile that this is
related to timezones but I haven't spent any time investigating.

    $ rails c
    >> Time.now
    => 2016-04-01 12:18:53 +1300
    >> Date.yesterday
    => Wed, 30 Mar 2016
    >> Date.today
    => Fri, 01 Apr 2016
    >> Date.tomorrow
    => Fri, 01 Apr 2016
In preparation for adding support for setting the date using an environment
variable.
This should make it possible to deploy rate changes to Heroku and have them
factchecked by people in the content team/department.
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    calculate-employee-redundancy-pay
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    calculate-married-couples-allowance
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    calculate-statutory-sick-pay
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    calculate-your-redundancy-pay
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    marriage-abroad
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    maternity-paternity-calculator
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    register-a-birth
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    register-a-death
The regression tests are passing so I'm happy to update the checksum
data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    state-pension-through-partner
Add instructions for setting `RATES_QUERY_DATE` on Heroku.
@chrisroos chrisroos force-pushed the allow-rates-query-date-to-be-set-using-environment-variable branch from bfb0bd6 to 0bc9e19 Compare March 31, 2016 23:47
@chrisroos
Copy link
Contributor Author

I've updated the factcheck docs in 0bc9e19.

I've rebased this on master and force pushed (there were no commit-comments) in preparation for merging.

@chrisroos chrisroos merged commit a18f98b into master Mar 31, 2016
@chrisroos chrisroos deleted the allow-rates-query-date-to-be-set-using-environment-variable branch March 31, 2016 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants