Programming Challenge

Objective

Implement a ToDo-Service which can be used via a RESTful API. For an example frontend application have a look here.

Key features:

  • Store ToDo-Items in a database (use any database driver you like, e.g. SQLite)
  • A ToDo-Item consists of at least a title (string, required) and read flag
  • Provide a CRUD- and RESTful-API-Endpoint for a ToDo-List
  • Write tests for your API & Models
  • Write meaningful commit messages

Nice to haves:

Installation

Prerequisites

The installation process assumes that you are running on macOS with homebrew installed.

Project Setup

# install system dependencies via Homebrew
$ brew install mysql
$ brew install ruby-build rbenv rbenv-readline rbenv-ctags
$ rbenv install `cat .ruby-version`

# install the local ruby version and do the setup
$ git clone <path-to-this-git-repository>
$ bin/bootstrap

# start the project
$ bin/foreman start

Git Hooks (powered by overcommit)

In case you bootstrap the project via bin/setup, you can skip this. Otherwise, you have the run the following command after cloning this repository to activate the Git Hooks.

There is also a custom commit hook, called commit-msg. This will aid the developer with the commit message format. When working on a feature branch (e.g. feature/ABC-870-something-awesome), this hook will add the ticket ID before the actual commit message.

$ bundle exec overcommit --install

# We are using a custom pre-commit hook for overcommit: It has to be "signed"
# before overcommit executes it...
$ bundle exec overcommit --sign commit-msg

This project uses two hooks:

  1. pre-push -- it runs rspec before you push. Your push is rejected if one or more tests fail. Please fix all failing tests and try again.
  2. pre-commit -- it runs rubocop to lint and style-check the entire codebase. Your commit is rejected if rubocop detected any offenses. Please fix all offenses and try again.

Development

This project follows the gitflow branching model. Also, we broadly follow the Github Flow with regard to pull-requests and code reviews.

$ brew install git-flow
$ git flow init -d

.env (poweredby dotenv)

The project uses .env-files for configuration. There is the hierarchy on how they get loded:

# taken from https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/rails.rb

Dotenv.load(
  root.join(".env.local"),
  root.join(".env.#{Rails.env}"),
  root.join(".env")
)

As a rule:

  • The .env-file MUST have every basic configuration defined (this is your starting point when wirking with the repository)
  • The .env.#{Rails.env}-files SHALL ONLY have environment specific overrides
  • The .env.local may have any configuration needed to run locally