unoduetre / satchel

Satchel code task

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

satchel code test

These setup instructions are for Linux. Instructions for OSX are similar. If you want to set it up on Windows, you are on your own.

Setup

This application uses PostgreSQL as the DBMS. Ensure your user has the required permissions to connect to and create new databases. These instructions assume your user can connect to PostgreSQL through a local Unix socket, so no password is necessary. E.g. the following entry in your pg_hba.conf configuration file should be enough:

local postgres <your_user_name> peer

Check if your user can connect to PostgreSQL.

$ psql postgres
...
postgres=> 

Check if your user has permissions to create databases.

postgres=> \dg
...
 <your_user_name> | Create DB | {}
...

Create databases.

$ createdb -E UTF8 -O $USER satchel_development
$ createdb -E UTF8 -O $USER satchel_test

To allow your user to connect to the databases, add the following two lines to your pg_hba.conf

local satchel_development <your_user_name> peer
local satchel_test <your_user_name> peer

Reload your postgresql configuration. Depending on your operating system the instructions might be different, but it should be similar to (as root):

# service postgresql reload

Check if you can connect to the databases.

$ psql satchel_development
...
satchel_development=>
$ psql satchel_development
...
satchel_test=>

Clone this repository:

git clone https://github.com/unoduetre/satchel.git
cd satchel

Install ruby version (assumes you use rbenv, other ruby version managers can be used as well).

$ rbenv install

Initialize the database.

$ ./bin/rails db:setup

As this was not a part of the requirements, I have not configured Docker Compose setup, but please, let me know if you need that as well.

Running

First you might want to generate some data in the database. Open Rails console and run:

$ ./bin/rails c
Loading development environment (Rails 7.1.1)
[1] pry(main)> 10.times { FactoryBot.create(:item) }

Exit Rails console and run:

$ ./bin/dev

Then go to http://localhost:3000 in your browser.

Testing

Run:

$ ./bin/rspec

Test coverage is also generated by that command. It is available in coverage/index.html.

Other checks

Check code standards:

$ ./bin/rubocop

Check security issues:

$ ./bin/brakeman
$ bundle audit

About

Satchel code task

License:MIT License


Languages

Language:Ruby 78.7%Language:HTML 13.8%Language:Dockerfile 2.9%Language:JavaScript 2.8%Language:CSS 1.3%Language:Shell 0.5%