A Rails API to replace the previous service API for the Repairs Hub.
| Dependency | Version |
|---|---|
| Ruby | 2.7.2 |
| Rails | 6.0.3 |
| Postgresql | 1.2.3 |
$ git clone git@github.com:LBHackney-IT/repairs-api.git$ bundle install$ rails db:prepareYou can run the full test suite using following command:
$ rspecYou can run all the tasks set in the rakefile bundle_audit brakeman rubocop spec using :
$ rake- Initially we have installed pry-byebug to development and test group on our Gemfile
group :development, :test do
# ..
gem 'pry-byebug'
# ..
end- Add binding.pry to the desired place you want to have a look on your rails code:
def index
binding.pry
end$ rails server$ rails consoleWe use Github Actions as part of our continuous integration process to build, run and test the application.
To run the app locally, you’ll need to have the Rails master key and test key set within the app. Copy the master key password from the Hackney Repairs V2 folder in Unboxed’s 1Password and save it to a master.key file in the config directory (i.e. where credentials.yml.enc lives). Save the password from the test key to config/credentials/test.key Read https://edgeguides.rubyonrails.org/security.html#custom-credentials for more info on this approach.
If using a service such as Postman API to test API requests, you will need the JWT token and endpoint url which can also be found in the Hackney Repairs V2 1password vault.
We use webmock to mock real network interactions, for example the Hackney platform APIs.
docker build -t repairs-api-production -f Dockerfile .Replace railsmasterkey in the command below.
docker run --rm -it -p 3000:3000 -e DATABASE_URL=postgres://postgres@host.docker.internal:5432/repairs_api_development -e RAILS_SERVE_STATIC_FILES=true -e RAILS_ENV=production -e RAILS_LOG_TO_STDOUT=true -e RAILS_MASTER_KEY=railsmasterkey repairs-api-production:latest bundle exec rails sdocker run --rm -it -e DATABASE_URL=postgres://postgres@host.docker.internal:5432/repairs_api_development -e RAILS_SERVE_STATIC_FILES=true -e RAILS_ENV=production -e RAILS_LOG_TO_STDOUT=true repairs-api-production:latest /bin/bash