Skip to content

Make It Cheaper tech task. June 2019.

Notifications You must be signed in to change notification settings

Pacyfik/code_test

 
 

Repository files navigation

Make it Cheaper Code Test

1. Fork this project to your GitHub

2. Do the test

3. When finished

  • provide a git URL to allow us to read/run your code
  • and/or create a pull request

4. Your app must start by running the following commands

  • bundle install
  • rake db:create db:migrate (If you use a database. It's possible to do the test without any database)
  • rails s

Test

bundle exec rspec

Environments variables

Check .env.example

  • LEAD_API_PGUID="CFFBF53F-6D89-4B5B-8B36-67A97F18EDEB"
  • LEAD_API_PACCNAME="MicDevtest"
  • LEAD_API_PPARTNER="MicDevtest"
  • LEAD_API_ACCESS_TOKEN=provided_by_make_it_cheaper

Docker

If you prefer you can use docker to run and work with the application. You will need docker and docker-compose installed.

To build and run the image and the server

docker-compose up --build

To run the rails console

docker-compose run web bundle exec rails console

To get a shell inside the container

docker-compose run web /bin/bash

Solution notes

  • I've included only the most basic validations in LeadForm as generally I'm not really sure I should duplicate the validations done by the API, especially since they could change in the future,
  • the Swagger docs for the API endpoint show that a 401 unauthorized response from the API returns a json with message and errors fields but it actually returns only the message field. I've added some code that takes that into account (see LeadAPI#errors_from_response).

About

Make It Cheaper tech task. June 2019.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 72.2%
  • HTML 22.4%
  • JavaScript 3.7%
  • Other 1.7%