/festalab-challenge

Technical challenge of FestaLab

Primary LanguageRuby

FestaLab Challenge

๐Ÿ”ง Pre-requisites

Before running the project, you must have the following tools installed on your machine:

Also, you will need to clone the repository:

# Clone the repository
git clone https://github.com/mateuseap/festalab-challenge

# Enter the root directory
cd festalab-challenge

๐Ÿš€ Project Setup

๐Ÿณ Database Configuration with Docker

Set up a PostgreSQL Docker container to manage the project's database:

# Run the Postgres Docker container
docker run --name festalab-pg -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres

โš™๏ธ Setting the Environment Variables

Create a file named .env in the project directory and copy the contents of .env.example into it. Fill in the necessary credentials in the .env file.

โฌ‡๏ธ Installing Dependencies

Now, it's time to install the project dependencies. Just run the command below:

# Install dependencies
bundle install

Ensure you are located in the correct project directory (/festalab-challenge) when executing the above command. Once the dependencies are installed, you're ready to proceed to the next steps of the setup process.

๐Ÿ› ๏ธ Database Initialization and Migrations

Initialize the databases and apply migrations with a single command:

# Create databases and run migrations
rails db:create db:migrate

This command ensures the databases are set up correctly and applies any pending migrations.

๐Ÿƒ Running the App

To run the App, just use the command below (make sure you're in /festalab-challenge directory):

# Running the Rails server
bin/dev

Then, open http://localhost:3000/ to view it in the browser.

App

๐Ÿงช Running Tests

Use the following commands to run tests, once you've completed the project setup process:

# Run controllers tests
rails test:controllers

# Run models tests
rails test:models

# Run all tests
rails test

Tests

๐Ÿ› ๏ธ Database Operations

๐ŸŒฑ Database Seeding

Seed the database with initial data using the following command:

# Seed the database
rails db:seed

This command will populate the database with predefined users from the seeds.rb file.

๐Ÿ”„ Apply Pending Migrations

If you need to apply any pending migrations, use the command below:

# Run migrations
rails db:migrate

This command will run any pending migrations that haven't been applied to the databases yet, ensuring your database schema is up-to-date.

โ›” Reset Databases

If you need to reset your databases by dropping the existing ones and recreating them, use the following command:

# Drop existing databases and recreate
rails db:drop db:create db:migrate

Note: Resetting databases will delete all existing data. Use with caution.