/rails_music_collection_app

A simple Ruby on Rails full-stack application to manage music albums, a requirement for the Moat Builders tech test.

Primary LanguageRuby

Rails Collection Music App

This is a simple Ruby on Rails full stack application to manage music albums, a requirement for the Moat Builders tech test.

More details about of the test requirements can be finding here

NOTES

  • Just keep in mind this application are not completeness of features or design;
  • Pagination feature added with kaminari;
  • The provided endpoint are not restful, so it's not possible to use Active Resource (ARes);
  • For best use of the endpoints, a Client (wrapper) for them was created. Inside each client methods, the services objects pattern (controversial, I know) is used to mount the response with one, or set of, Artist model class;
  • For authentication, the devise gem is used;
  • Because authorization is so basic, for only one action in a specific action, it was made with a method in the Albums controller
  • For tests, the following gems are used:

GETTING START

System dependencies

  • Ruby 3.0.2;
  • Rails 6.1.4;
  • Git 2.31;
  • PostgreSQL 13.4.

If you prefer to use Docker:

  • Ruby 3.0.2;
  • Git 2.31+;
  • Docker 20.10+;
  • Docker-compose 1.29.2.

Running the project

These instructions will provide a copy of the project up and running on your local machine for development and testing purposes.

Cloning the project

To get started with the app, first clone the repo and cd into the directory:

From GitHub

## GitHub Repository
git clone git@github.com:rvlaraujo/rails_music_collection_app.git
cd rails_music_collection_app

From GitLab

## GitLab Repository
git clone git@gitlab.com:rvlaraujo/rails_music_collection_app.git
cd rails_music_collection_app

Running App with Docker and Docker-compose

In the root of the project, install gems via bundler:

bundle install

Build the images with Docker-compose:

docker-compose build

Create the database, runs the migrations and seeds:

docker-compose run web rails db:setup

Precompile assets with webpacker:

docker-compose run web rails webpacker:install

When appears:

identical  config/webpacker.yml
Copying webpack core config
       exist  config/webpack
   identical  config/webpack/development.js
    conflict  config/webpack/environment.js
Overwrite /myapp/config/webpack/environment.js? (enter "h" for help) [Ynaqdhm]

Select: 'n'

Run:

docker-compose run web rails webpacker:compile

Runing the containers:

docker-compose up

Running App WITHOUT Docker and Docker-compose

Configure the PostgreSQL

Following the instructions in the links under to configure the PostgreSQL in your environment:

Installing Ruby and Rails

Following the instructions in the links under to configure the Ruby and Rails in your environment:

Install Gems

In the root of project, run the following command:

bundle install

Adding Twitter Bootstrap 5

In the root of project, run the following command:

yarn add bootstrap jquery @popperjs/core bootstrap-icons

Configure database

For create the database, runs the migrations and seeds, runs the following command:

rails db:setup

Precompile assets with webpacker

Install webpacker

rails webpacker:install

When appears:

identical  config/webpacker.yml
Copying webpack core config
       exist  config/webpack
   identical  config/webpack/development.js
    conflict  config/webpack/environment.js
Overwrite /myapp/config/webpack/environment.js? (enter "h" for help) [Ynaqdhm]

Select: 'n'

Run:

rails webpacker:compile

Runs the application

Runs:

rails server

Accessing the application

Open the browser and access http://0.0.0.0:3000

If you runs seeds.rb file, the application has 2 users:

  • Administrator
    • login: administrator
    • password: administrator
    • role: admin
  • Common User
    • login: commonuser
    • password: commonuser
    • role: user

But you are free for registration new users. After registration of a new user, you're automatically login in the application.

The main page of the application list all allowed users, provided by endpoints in the test decription

Running tests

With Docker and Docker-compose

To run all tests, just execut the following command in the root of the project:

docker-compose run web rspec --format documentation

For more informations about runs RSpec tests, see RSpec Running Specs.

WITHOUT Docker and Docker-compose

To run all tests, just execut the following command in the root of the project:

rspec --format documentation

For more informations about runs RSpec tests, see RSpec Running Specs.

CONTACT

Comments and feedback are welcome.

LinkedIn GitHub Gmail