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
- 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:
- 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.
These instructions will provide a copy of the project up and running on your local machine for development and testing purposes.
To get started with the app, first clone the repo and cd into the directory:
## GitHub Repository
git clone git@github.com:rvlaraujo/rails_music_collection_app.git
cd rails_music_collection_app
## GitLab Repository
git clone git@gitlab.com:rvlaraujo/rails_music_collection_app.git
cd rails_music_collection_app
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
Following the instructions in the links under to configure the PostgreSQL in your environment:
Following the instructions in the links under to configure the Ruby and Rails in your environment:
- Install Ruby On Rails on Ubuntu 21.04 Hirsute Hippo (e outras versões), com rbenv ou rvm
- Install Ruby On Rails on macOS 11.0 Big Sur
- Install Ruby On Rails on Windows 10
In the root of project, run the following command:
bundle install
In the root of project, run the following command:
yarn add bootstrap jquery @popperjs/core bootstrap-icons
For create the database, runs the migrations and seeds, runs the following command:
rails db:setup
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:
rails server
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
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.
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.
Comments and feedback are welcome.