diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..bb56daf
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,31 @@
+# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
+
+# Ignore git directory.
+/.git/
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore all environment files (except templates).
+/.env*
+!/.env*.erb
+
+# Ignore all default key files.
+/config/master.key
+/config/credentials/*.key
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+# Ignore pidfiles, but keep the directory.
+/tmp/pids/*
+!/tmp/pids/.keep
+
+# Ignore storage (uploaded files in development and any SQLite databases).
+/storage/*
+!/storage/.keep
+/tmp/storage/*
+!/tmp/storage/.keep
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..8dc4323
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,9 @@
+# See https://git-scm.com/docs/gitattributes for more about git attribute files.
+
+# Mark the database schema as having been generated.
+db/schema.rb linguist-generated
+
+# Mark any vendored files as having been vendored.
+vendor/* linguist-vendored
+config/credentials/*.yml.enc diff=rails_credentials
+config/credentials.yml.enc diff=rails_credentials
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
new file mode 100644
index 0000000..560212b
--- /dev/null
+++ b/.github/workflows/linters.yml
@@ -0,0 +1,30 @@
+name: Linters
+
+on: pull_request
+
+env:
+ FORCE_COLOR: 1
+
+jobs:
+ rubocop:
+ name: Rubocop
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-ruby@v1
+ with:
+ ruby-version: 3.1.x
+ - name: Setup Rubocop
+ run: |
+ gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
+ [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
+ - name: Rubocop Report
+ run: rubocop --color
+ nodechecker:
+ name: node_modules checker
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v3
+ - name: Check node_modules existence
+ run: |
+ if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7e6b54f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,33 @@
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile '~/.gitignore_global'
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore all environment files (except templates).
+/.env*
+!/.env*.erb
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+# Ignore pidfiles, but keep the directory.
+/tmp/pids/*
+!/tmp/pids/
+!/tmp/pids/.keep
+
+# Ignore storage (uploaded files in development and any SQLite databases).
+/storage/*
+!/storage/.keep
+/tmp/storage/*
+!/tmp/storage/
+!/tmp/storage/.keep
+
+# Ignore master key for decrypting credentials and more.
+/config/master.key
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..c99d2e7
--- /dev/null
+++ b/.rspec
@@ -0,0 +1 @@
+--require spec_helper
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..07baeb4
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,60 @@
+AllCops:
+ NewCops: enable
+ Exclude:
+ - "db/**/*"
+ - "bin/*"
+ - "config/**/*"
+ - "Guardfile"
+ - "Rakefile"
+ - "node_modules/**/*"
+
+ DisplayCopNames: true
+
+Layout/LineLength:
+ Max: 120
+Metrics/MethodLength:
+ Include:
+ - "app/controllers/*"
+ - "app/models/*"
+ Max: 20
+Metrics/AbcSize:
+ Include:
+ - "app/controllers/*"
+ - "app/models/*"
+ Max: 50
+Metrics/ClassLength:
+ Max: 150
+Metrics/BlockLength:
+ AllowedMethods: ['describe']
+ Max: 30
+
+Style/Documentation:
+ Enabled: false
+Style/ClassAndModuleChildren:
+ Enabled: false
+Style/EachForSimpleLoop:
+ Enabled: false
+Style/AndOr:
+ Enabled: false
+Style/DefWithParentheses:
+ Enabled: false
+Style/FrozenStringLiteralComment:
+ EnforcedStyle: never
+
+Layout/HashAlignment:
+ EnforcedColonStyle: key
+Layout/ExtraSpacing:
+ AllowForAlignment: false
+Layout/MultilineMethodCallIndentation:
+ Enabled: true
+ EnforcedStyle: indented
+Lint/RaiseException:
+ Enabled: false
+Lint/StructNewOverride:
+ Enabled: false
+Style/HashEachMethods:
+ Enabled: false
+Style/HashTransformKeys:
+ Enabled: false
+Style/HashTransformValues:
+ Enabled: false
\ No newline at end of file
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..9e79f6c
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+ruby-3.2.2
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..11d58b9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,59 @@
+# syntax = docker/dockerfile:1
+
+# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
+ARG RUBY_VERSION=3.2.2
+FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
+
+# Rails app lives here
+WORKDIR /rails
+
+# Set production environment
+ENV RAILS_ENV="production" \
+ BUNDLE_DEPLOYMENT="1" \
+ BUNDLE_PATH="/usr/local/bundle" \
+ BUNDLE_WITHOUT="development"
+
+
+# Throw-away build stage to reduce size of final image
+FROM base as build
+
+# Install packages needed to build gems
+RUN apt-get update -qq && \
+ apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
+
+# Install application gems
+COPY Gemfile Gemfile.lock ./
+RUN bundle install && \
+ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
+ bundle exec bootsnap precompile --gemfile
+
+# Copy application code
+COPY . .
+
+# Precompile bootsnap code for faster boot times
+RUN bundle exec bootsnap precompile app/ lib/
+
+
+# Final stage for app image
+FROM base
+
+# Install packages needed for deployment
+RUN apt-get update -qq && \
+ apt-get install --no-install-recommends -y curl libvips postgresql-client && \
+ rm -rf /var/lib/apt/lists /var/cache/apt/archives
+
+# Copy built artifacts: gems, application
+COPY --from=build /usr/local/bundle /usr/local/bundle
+COPY --from=build /rails /rails
+
+# Run and own only the runtime files as a non-root user for security
+RUN useradd rails --create-home --shell /bin/bash && \
+ chown -R rails:rails db log storage tmp
+USER rails:rails
+
+# Entrypoint prepares the database.
+ENTRYPOINT ["/rails/bin/docker-entrypoint"]
+
+# Start the server by default, this can be overwritten at runtime
+EXPOSE 3000
+CMD ["./bin/rails", "server"]
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..7f63e0d
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,63 @@
+source 'https://rubygems.org'
+
+ruby '3.2.2'
+
+# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
+gem 'rails', '~> 7.1.1'
+
+gem 'rubocop', '>= 1.0', '< 2.0'
+
+gem 'rack-cors'
+
+gem 'devise'
+
+gem 'bcrypt', '~> 3.1', '>= 3.1.16'
+
+# Use postgresql as the database for Active Record
+gem 'pg', '~> 1.1'
+
+# Use the Puma web server [https://github.com/puma/puma]
+gem 'puma', '>= 5.0'
+
+# Build JSON APIs with ease [https://github.com/rails/jbuilder]
+# gem "jbuilder"
+
+# Use Redis adapter to run Action Cable in production
+# gem "redis", ">= 4.0.1"
+
+# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
+# gem "kredis"
+
+# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
+# gem "bcrypt", "~> 3.1.7"
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: %i[windows jruby]
+
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', require: false
+
+# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
+# gem "image_processing", "~> 1.2"
+
+# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
+# gem "rack-cors"
+
+group :development, :test do
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
+ gem 'debug', platforms: %i[mri windows]
+ gem 'factory_bot_rails'
+ gem 'faker'
+ gem 'rspec-rails', '~> 5.0'
+ gem 'shoulda-matchers', '~> 4.0'
+end
+
+group :development do
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
+ # gem "spring"
+
+ gem 'capybara'
+ gem 'database_cleaner'
+ gem 'selenium-webdriver'
+ gem 'web-console'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..f7c8e63
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,315 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (7.1.1)
+ actionpack (= 7.1.1)
+ activesupport (= 7.1.1)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ zeitwerk (~> 2.6)
+ actionmailbox (7.1.1)
+ actionpack (= 7.1.1)
+ activejob (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ mail (>= 2.7.1)
+ net-imap
+ net-pop
+ net-smtp
+ actionmailer (7.1.1)
+ actionpack (= 7.1.1)
+ actionview (= 7.1.1)
+ activejob (= 7.1.1)
+ activesupport (= 7.1.1)
+ mail (~> 2.5, >= 2.5.4)
+ net-imap
+ net-pop
+ net-smtp
+ rails-dom-testing (~> 2.2)
+ actionpack (7.1.1)
+ actionview (= 7.1.1)
+ activesupport (= 7.1.1)
+ nokogiri (>= 1.8.5)
+ rack (>= 2.2.4)
+ rack-session (>= 1.0.1)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.2)
+ rails-html-sanitizer (~> 1.6)
+ actiontext (7.1.1)
+ actionpack (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ globalid (>= 0.6.0)
+ nokogiri (>= 1.8.5)
+ actionview (7.1.1)
+ activesupport (= 7.1.1)
+ builder (~> 3.1)
+ erubi (~> 1.11)
+ rails-dom-testing (~> 2.2)
+ rails-html-sanitizer (~> 1.6)
+ activejob (7.1.1)
+ activesupport (= 7.1.1)
+ globalid (>= 0.3.6)
+ activemodel (7.1.1)
+ activesupport (= 7.1.1)
+ activerecord (7.1.1)
+ activemodel (= 7.1.1)
+ activesupport (= 7.1.1)
+ timeout (>= 0.4.0)
+ activestorage (7.1.1)
+ actionpack (= 7.1.1)
+ activejob (= 7.1.1)
+ activerecord (= 7.1.1)
+ activesupport (= 7.1.1)
+ marcel (~> 1.0)
+ activesupport (7.1.1)
+ base64
+ bigdecimal
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ connection_pool (>= 2.2.5)
+ drb
+ i18n (>= 1.6, < 2)
+ minitest (>= 5.1)
+ mutex_m
+ tzinfo (~> 2.0)
+ addressable (2.8.5)
+ public_suffix (>= 2.0.2, < 6.0)
+ ast (2.4.2)
+ base64 (0.1.1)
+ bcrypt (3.1.19)
+ bigdecimal (3.1.4)
+ bindex (0.8.1)
+ bootsnap (1.16.0)
+ msgpack (~> 1.2)
+ builder (3.2.4)
+ capybara (3.39.2)
+ addressable
+ matrix
+ mini_mime (>= 0.1.3)
+ nokogiri (~> 1.8)
+ rack (>= 1.6.0)
+ rack-test (>= 0.6.3)
+ regexp_parser (>= 1.5, < 3.0)
+ xpath (~> 3.2)
+ concurrent-ruby (1.2.2)
+ connection_pool (2.4.1)
+ crass (1.0.6)
+ database_cleaner (2.0.2)
+ database_cleaner-active_record (>= 2, < 3)
+ database_cleaner-active_record (2.1.0)
+ activerecord (>= 5.a)
+ database_cleaner-core (~> 2.0.0)
+ database_cleaner-core (2.0.1)
+ date (3.3.3)
+ debug (1.8.0)
+ irb (>= 1.5.0)
+ reline (>= 0.3.1)
+ devise (4.9.3)
+ bcrypt (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (>= 4.1.0)
+ responders
+ warden (~> 1.2.3)
+ diff-lcs (1.5.0)
+ drb (2.1.1)
+ ruby2_keywords
+ erubi (1.12.0)
+ factory_bot (6.2.1)
+ activesupport (>= 5.0.0)
+ factory_bot_rails (6.2.0)
+ factory_bot (~> 6.2.0)
+ railties (>= 5.0.0)
+ faker (3.2.1)
+ i18n (>= 1.8.11, < 2)
+ globalid (1.2.1)
+ activesupport (>= 6.1)
+ i18n (1.14.1)
+ concurrent-ruby (~> 1.0)
+ io-console (0.6.0)
+ irb (1.8.3)
+ rdoc
+ reline (>= 0.3.8)
+ json (2.6.3)
+ language_server-protocol (3.17.0.3)
+ loofah (2.21.4)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.12.0)
+ mail (2.8.1)
+ mini_mime (>= 0.1.1)
+ net-imap
+ net-pop
+ net-smtp
+ marcel (1.0.2)
+ matrix (0.4.2)
+ mini_mime (1.1.5)
+ minitest (5.20.0)
+ msgpack (1.7.2)
+ mutex_m (0.1.2)
+ net-imap (0.4.2)
+ date
+ net-protocol
+ net-pop (0.1.2)
+ net-protocol
+ net-protocol (0.2.1)
+ timeout
+ net-smtp (0.4.0)
+ net-protocol
+ nio4r (2.5.9)
+ nokogiri (1.15.4-x86_64-darwin)
+ racc (~> 1.4)
+ nokogiri (1.15.4-x86_64-linux)
+ racc (~> 1.4)
+ orm_adapter (0.5.0)
+ parallel (1.23.0)
+ parser (3.2.2.4)
+ ast (~> 2.4.1)
+ racc
+ pg (1.5.4)
+ psych (5.1.1.1)
+ stringio
+ public_suffix (5.0.3)
+ puma (6.4.0)
+ nio4r (~> 2.0)
+ racc (1.7.1)
+ rack (3.0.8)
+ rack-cors (2.0.1)
+ rack (>= 2.0.0)
+ rack-session (2.0.0)
+ rack (>= 3.0.0)
+ rack-test (2.1.0)
+ rack (>= 1.3)
+ rackup (2.1.0)
+ rack (>= 3)
+ webrick (~> 1.8)
+ rails (7.1.1)
+ actioncable (= 7.1.1)
+ actionmailbox (= 7.1.1)
+ actionmailer (= 7.1.1)
+ actionpack (= 7.1.1)
+ actiontext (= 7.1.1)
+ actionview (= 7.1.1)
+ activejob (= 7.1.1)
+ activemodel (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ bundler (>= 1.15.0)
+ railties (= 7.1.1)
+ rails-dom-testing (2.2.0)
+ activesupport (>= 5.0.0)
+ minitest
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.6.0)
+ loofah (~> 2.21)
+ nokogiri (~> 1.14)
+ railties (7.1.1)
+ actionpack (= 7.1.1)
+ activesupport (= 7.1.1)
+ irb
+ rackup (>= 1.0.0)
+ rake (>= 12.2)
+ thor (~> 1.0, >= 1.2.2)
+ zeitwerk (~> 2.6)
+ rainbow (3.1.1)
+ rake (13.0.6)
+ rdoc (6.5.0)
+ psych (>= 4.0.0)
+ regexp_parser (2.8.2)
+ reline (0.3.9)
+ io-console (~> 0.5)
+ responders (3.1.1)
+ actionpack (>= 5.2)
+ railties (>= 5.2)
+ rexml (3.2.6)
+ rspec-core (3.12.2)
+ rspec-support (~> 3.12.0)
+ rspec-expectations (3.12.3)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.12.0)
+ rspec-mocks (3.12.6)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.12.0)
+ rspec-rails (5.1.2)
+ actionpack (>= 5.2)
+ activesupport (>= 5.2)
+ railties (>= 5.2)
+ rspec-core (~> 3.10)
+ rspec-expectations (~> 3.10)
+ rspec-mocks (~> 3.10)
+ rspec-support (~> 3.10)
+ rspec-support (3.12.1)
+ rubocop (1.57.2)
+ json (~> 2.3)
+ language_server-protocol (>= 3.17.0)
+ parallel (~> 1.10)
+ parser (>= 3.2.2.4)
+ rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.8, < 3.0)
+ rexml (>= 3.2.5, < 4.0)
+ rubocop-ast (>= 1.28.1, < 2.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 2.4.0, < 3.0)
+ rubocop-ast (1.30.0)
+ parser (>= 3.2.1.0)
+ ruby-progressbar (1.13.0)
+ ruby2_keywords (0.0.5)
+ rubyzip (2.3.2)
+ selenium-webdriver (4.15.0)
+ rexml (~> 3.2, >= 3.2.5)
+ rubyzip (>= 1.2.2, < 3.0)
+ websocket (~> 1.0)
+ shoulda-matchers (4.5.1)
+ activesupport (>= 4.2.0)
+ stringio (3.0.8)
+ thor (1.3.0)
+ timeout (0.4.0)
+ tzinfo (2.0.6)
+ concurrent-ruby (~> 1.0)
+ unicode-display_width (2.5.0)
+ warden (1.2.9)
+ rack (>= 2.0.9)
+ web-console (4.2.1)
+ actionview (>= 6.0.0)
+ activemodel (>= 6.0.0)
+ bindex (>= 0.4.0)
+ railties (>= 6.0.0)
+ webrick (1.8.1)
+ websocket (1.2.10)
+ websocket-driver (0.7.6)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.5)
+ xpath (3.2.0)
+ nokogiri (~> 1.8)
+ zeitwerk (2.6.12)
+
+PLATFORMS
+ x86_64-darwin-22
+ x86_64-linux
+
+DEPENDENCIES
+ bcrypt (~> 3.1, >= 3.1.16)
+ bootsnap
+ capybara
+ database_cleaner
+ debug
+ devise
+ factory_bot_rails
+ faker
+ pg (~> 1.1)
+ puma (>= 5.0)
+ rack-cors
+ rails (~> 7.1.1)
+ rspec-rails (~> 5.0)
+ rubocop (>= 1.0, < 2.0)
+ selenium-webdriver
+ shoulda-matchers (~> 4.0)
+ tzinfo-data
+ web-console
+
+RUBY VERSION
+ ruby 3.2.2p53
+
+BUNDLED WITH
+ 2.4.21
diff --git a/MIT.md b/MIT.md
new file mode 100644
index 0000000..505484e
--- /dev/null
+++ b/MIT.md
@@ -0,0 +1,7 @@
+Copyright 2023, Claudia Rojas & Pablo Bonasera
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
+
+The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infragments. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or on connection with the Software or the use or others dealing in the software.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..91b3ffc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
Final Capstone Back End
+
+
+
+# π Table of Contents
+
+- [π Table of Contents](#-table-of-contents)
+- [π final\_capstone\_back\_end ](#-final_capstone_back_end-)
+ - [π ER Diagram ](#-er-diagram-)
+ - [π» Link to Demo ](#-link-to-demo-)
+ - [π» link to front end ](#-link-to-front-end-)
+ - [π» link to Kanban board information ](#-link-to-kanban-board-information-)
+ - [π Built With ](#-built-with-)
+ - [Tech Stack ](#tech-stack-)
+ - [Key Features ](#key-features-)
+ - [π» Getting Started ](#-getting-started-)
+ - [Prerequisites](#prerequisites)
+ - [Setup](#setup)
+ - [Install](#install)
+ - [Database Setup](#database-setup)
+ - [Usage](#usage)
+ - [π¬ Running Tests ](#-running-tests-)
+ - [Test Suite](#test-suite)
+ - [π» API Documentation ](#-api-documentation-)
+ - [π₯ Authors ](#-authors-)
+ - [π Future Features ](#-future-features-)
+ - [π€ Contributing ](#-contributing-)
+ - [βοΈ Show your support ](#οΈ-show-your-support-)
+ - [π Acknowledgments ](#-acknowledgments-)
+ - [β FAQ (OPTIONAL) ](#-faq-optional-)
+ - [π License ](#-license-)
+
+
+# π Final Capstone Back End
+
+**final_capstone_back_end** The back-end component of this final capstone project is developed using Ruby on Rails, configured to serve as an API. This API is designed to facilitate reservations or appointments for test drives of cars. It leverages a PostgreSQL database to manage and store reservation data.
+
+## π ER Diagram
+
+
+
+## π» Link to Demo
+
+[Link to Demo](https://driver-front.onrender.com/)
+
+(back to top)
+
+## π» Link to front end
+
+
+[Link to Front End](https://github.com/ClaudiaRojasSoto/Final-Capstone-Front-End)
+
+(back to top)
+
+## π» link to Kanban board information
+
+[Link to Kanban Board](https://github.com/ClaudiaRojasSoto/Final-Capstone-Back-End/projects/1)
+
+[Initial state](https://github.com/ClaudiaRojasSoto/Final-Capstone-Back-End/issues/16)
+
+This project was completed by two of the three original Team members:
+
+- Claudia Rojas
+- Pablo Bonasera
+
+(back to top)
+
+## π Built With
+
+### Tech Stack
+
+
+ Technologies
+
+
+
+Linters
+
+
+
+
+### Key Features
+
+- [x] **Ruby on Rails**
+- [x] **API Endpoint**
+- [x] **Professional Documentation**
+- [x] **Linting for Code Quality**
+- [x] **Postgres Database**
+- [x] **Git Version Control**
+
+
+(back to top)
+
+
+## π» Getting Started
+
+To get a local copy up and running, follow these steps:
+
+### Prerequisites
+
+Before you begin, ensure you have the following prerequisites installed on your system:
+
+- Ruby: You need Ruby to run the Ruby on Rails application.
+- Bundler: Bundler is used to manage gem dependencies for your Ruby project.
+
+### Setup
+
+In your terminal, navigate to the folder of your choice and clone the repository with the following commands:
+
+```sh
+cd my-folder
+git clone https://github.com/ClaudiaRojasSoto/final_capstone_back_end.git
+
+```
+
+### Install
+
+After cloning the project, change into the project directory:
+
+```sh
+cd final_capstone_back_end
+
+```
+
+Install this project with:
+
+- gem install rails
+- bundle install
+
+### Database Setup
+
+Create and migrate your database with:
+
+```sh
+
+rails db:create
+rails db:migrate
+
+```
+### Usage
+
+To run the project, execute the following command:
+
+```sh
+
+rails server
+or
+rails s
+
+```
+This should start your local server on http://localhost:3000/. Now, you can use the REST API client of your choice to interact with the API.
+
+(back to top)
+
+
+## π¬ Running Tests
+
+To run tests, navigate to the directory where the project is located on your machine, open your terminal, and follow these steps:
+
+### Test Suite
+
+This project contains a suite of unit tests which you can run to ensure everything is functioning as expected. To run these tests, you need RSpec installed.
+
+To install RSpec if you haven't already, run:
+
+```sh
+gem install rspec
+
+```
+
+After you've installed RSpec, you can run the tests with:
+
+```sh
+
+rspec
+
+```
+
+(back to top)
+
+## π» API Documentation
+
+
+
+[Run in Postman](https://winter-desert-419071.postman.co/workspace/My-Workspace~efdb5aba-9d35-41c3-848e-87060938ceb9/collection/19270283-b003a584-76ab-4464-8520-ecbd8d4677df?action=share&creator=19270283)
+
+
+
+
+
+
+(back to top)
+
+## π₯ Authors
+
+π€ **Claudia Rojas**
+
+- GitHub: [@ClaudiaRojas](https://github.com/ClaudiaRojasSoto)
+- LinkedIn: [@ClaudiaRojas](https://www.linkedin.com/in/claudia-rojas-soto/)
+
+π€ **Pablo Bonasera**
+
+- GitHub: [@PabloBona](https://github.com/PabloBona)
+- LinkedIn: [Pablo Bonasera](https://www.linkedin.com/in/pablo-bonasera/)
+
+
+(back to top)
+
+
+## π Future Features
+
+- [ ] **Implement proper user authentication from the front-end to the server**
+- [ ] **Add authorizations to users**
+
+
+(back to top)
+
+## π€ Contributing
+
+Contributions, issues, and feature requests are welcome!
+
+Feel free to check the [issues page](https://github.com/ClaudiaRojasSoto/final_capstone_back_end/issues).
+
+(back to top)
+
+
+## βοΈ Show your support
+
+If you like this project please feel free to send me corrections for make it better I would feel glad to read your comments.
+And think If you enjoy gift me a star.
+
+(back to top)
+
+## π Acknowledgments
+
+- Behance and Murat Korkmaz for the [original design](https://www.behance.net/gallery/26425031/Vespa-Responsive-Redesign)
+- Microverse for providing the opportunity to learn in a collaborative environment.
+- React.js Documentation for valuable resources on React development.
+- GitHub for version control and collaboration tools.
+
+(back to top)
+
+## β FAQ (OPTIONAL)
+
+
+- **Can I use with a templeate your project?**
+
+ - Of course I would feel honored
+
+- **Your project is free license?**
+
+ - Yeah, you can use it completely
+
+(back to top)
+
+
+## π License
+
+This project is licensed under the MIT License - you can click here to have more details [MIT](MIT.md).
+
+(back to top)
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..9a5ea73
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative "config/application"
+
+Rails.application.load_tasks
diff --git a/api.png b/api.png
new file mode 100644
index 0000000..daf6deb
Binary files /dev/null and b/api.png differ
diff --git a/app.png b/app.png
new file mode 100644
index 0000000..58cff8c
Binary files /dev/null and b/app.png differ
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..d672697
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..0ff5442
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/app/controllers/api/cars_controller.rb b/app/controllers/api/cars_controller.rb
new file mode 100644
index 0000000..4516af1
--- /dev/null
+++ b/app/controllers/api/cars_controller.rb
@@ -0,0 +1,49 @@
+class Api::CarsController < ApplicationController
+ skip_before_action :set_current_user, only: [:create]
+ def index
+ @reservations = current_user.reservations.includes(:car).where(cars: { removed: false })
+ @cars = Car.all
+ cars_json = @cars.map do |car|
+ car_attributes = car.attributes
+ car_attributes['image_url'] = url_for(car.image) if car.image.attached?
+ car_attributes
+ end
+ render json: cars_json
+ end
+
+ def show
+ @car = Car.find(params[:id])
+ image_url = url_for(@car.image) if @car.image.attached?
+ # rubocop:disable Style/HashSyntax
+ render json: { car: @car.attributes, image_url: image_url }
+ # rubocop:enable Style/HashSyntax
+ end
+
+ def create
+ @car = Car.new(car_params)
+
+ ActiveRecord::Base.transaction do
+ if @car.save
+ @car.image.attach(params[:image]) if params[:image].present?
+
+ render json: { message: 'Car created successfully' }, status: :created
+ else
+ render json: { errors: @car.errors.full_messages }, status: :unprocessable_entity
+ end
+ end
+ end
+
+ def destroy
+ @car = Car.find(params[:id])
+ @car.destroy
+ render json: { message: 'Car deleted successfully' }, status: :ok
+ end
+
+ private
+
+ def car_params
+ params.require(:car).permit(:name, :description, :deposit, :finance_fee,
+ :option_to_purchase_fee, :total_amount_payable,
+ :duration, :removed, :image)
+ end
+end
diff --git a/app/controllers/api/reservations_controller.rb b/app/controllers/api/reservations_controller.rb
new file mode 100644
index 0000000..44672fb
--- /dev/null
+++ b/app/controllers/api/reservations_controller.rb
@@ -0,0 +1,67 @@
+class Api::ReservationsController < ApplicationController
+ before_action :set_car, only: [:create]
+ before_action :set_reservation, only: %i[show update destroy]
+
+ def user_reservations
+ @reservations = current_user.reservations
+ response = @reservations.map(&:reservation_with_car)
+ render json: response
+ end
+
+ def index
+ @reservations = current_user.reservations
+ render json: @reservations
+ end
+
+ def show
+ render json: @reservation
+ end
+
+ def create
+ @reservation = Reservation.new(reservation_params)
+ @reservation.user = current_user
+ @reservation.car = @car
+
+ if @car.available?(@reservation.start_time, @reservation.end_time)
+ if @reservation.save
+ render json: {
+ success: true,
+ reservation_id: @reservation.id,
+ user_name: current_user.name,
+ car_info: @car.attributes
+ }
+ else
+ render json: { error: @reservation.errors.full_messages }, status: :unprocessable_entity
+ end
+ else
+ render json: { error: 'Car is not available for reservation' }, status: :unprocessable_entity
+ end
+ end
+
+ def update
+ if @reservation.update(reservation_params)
+ render json: { success: true, reservation: @reservation }
+ else
+ render json: { error: @reservation.errors.full_messages }, status: :unprocessable_entity
+ end
+ end
+
+ def destroy
+ @reservation.destroy
+ render json: { success: true, message: 'Reservation was successfully deleted.' }
+ end
+
+ private
+
+ def set_car
+ @car = Car.find(params[:car_id])
+ end
+
+ def reservation_params
+ params.require(:reservation).permit(:start_time, :end_time, :city)
+ end
+
+ def set_reservation
+ @reservation = Reservation.find(params[:id])
+ end
+end
diff --git a/app/controllers/api/sessions_controller.rb b/app/controllers/api/sessions_controller.rb
new file mode 100644
index 0000000..a223c01
--- /dev/null
+++ b/app/controllers/api/sessions_controller.rb
@@ -0,0 +1,19 @@
+class Api::SessionsController < ApplicationController
+ def create
+ puts "Debugging Params: #{params.inspect}"
+ user = User.find_by(email: params[:email])
+ puts "Debugging User: #{user.inspect}"
+
+ if user&.authenticate(params[:password])
+ session[:user_id] = user.id
+ render json: { success: true, user_id: user.id }
+ else
+ render json: { error: 'User not found or wrong password' }, status: :unauthorized
+ end
+ end
+
+ def destroy
+ session[:user_id] = nil
+ render json: { success: true }
+ end
+end
diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb
new file mode 100644
index 0000000..360bb7d
--- /dev/null
+++ b/app/controllers/api/users_controller.rb
@@ -0,0 +1,40 @@
+class Api::UsersController < ApplicationController
+ before_action :set_current_user, only: [:current]
+ def index
+ @users = User.all
+ render json: @users
+ end
+
+ def show
+ @user = User.find(params[:id])
+ render json: @user
+ end
+
+ def create
+ @user = User.new(user_params)
+ if @user.save
+ session[:user_id] = @user.id
+ render json: { success: true, user_id: @user.id, message: 'Sign in was successful!' }, status: :created
+ else
+ render json: { error: @user.errors.full_messages }, status: :unprocessable_entity
+ end
+ end
+
+ def current
+ if @current_user
+ render json: @current_user
+ else
+ render json: { error: 'Not logged in' }, status: :unauthorized
+ end
+ end
+
+ private
+
+ def set_current_user
+ @current_user = User.find(session[:user_id]) if session[:user_id]
+ end
+
+ def user_params
+ params.require(:user).permit(:name, :email, :password)
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..ef62f0e
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,13 @@
+class ApplicationController < ActionController::API
+ before_action :set_current_user
+
+ def current_user
+ @current_user ||= User.find_by(id: session[:user_id])
+ end
+
+ private
+
+ def set_current_user
+ @current_user = current_user
+ end
+end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 0000000..ed2d410
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,3 @@
+class UsersController < ApplicationController
+ def index; end
+end
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000..d394c3d
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,7 @@
+class ApplicationJob < ActiveJob::Base
+ # Automatically retry jobs that encountered a deadlock
+ # retry_on ActiveRecord::Deadlocked
+
+ # Most jobs are safe to ignore if the underlying records are no longer available
+ # discard_on ActiveJob::DeserializationError
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..286b223
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000..b63caeb
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ primary_abstract_class
+end
diff --git a/app/models/car.rb b/app/models/car.rb
new file mode 100644
index 0000000..bd2bb6f
--- /dev/null
+++ b/app/models/car.rb
@@ -0,0 +1,23 @@
+class Car < ApplicationRecord
+ has_many :reservations, dependent: :destroy
+
+ has_one_attached :image
+
+ validates :name, presence: true
+ validates :description, presence: true
+ validates :deposit, presence: true
+ validates :finance_fee, presence: true
+ validates :option_to_purchase_fee, presence: true
+ validates :total_amount_payable, presence: true
+ validates :duration, presence: true
+ validates :removed, inclusion: { in: [true, false] }
+
+ def available?(start_time, end_time)
+ overlapping_reservations = reservations.where(
+ 'start_time < ? AND end_time > ?',
+ end_time,
+ start_time
+ )
+ overlapping_reservations.empty?
+ end
+end
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/models/reservation.rb b/app/models/reservation.rb
new file mode 100644
index 0000000..f0033d8
--- /dev/null
+++ b/app/models/reservation.rb
@@ -0,0 +1,22 @@
+class Reservation < ApplicationRecord
+ belongs_to :user
+ belongs_to :car
+
+ validates :start_time, :end_time, :city, presence: true
+ validate :start_time_must_be_in_the_future
+
+ def reservation_with_car
+ {
+ reservation: attributes,
+ car: car.attributes
+ }
+ end
+
+ private
+
+ def start_time_must_be_in_the_future
+ return if start_time.blank?
+
+ errors.add(:start_time, "can't be in the past") if start_time < Time.current
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..4fca429
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,8 @@
+class User < ApplicationRecord
+ has_secure_password
+ has_many :reservations
+
+ validates :name, presence: true
+ validates :email, presence: true, uniqueness: true
+ validates :password, presence: { message: 'This is a custom password can\'t be blank message.' }, on: :create
+end
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000..3aac900
--- /dev/null
+++ b/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000..37f0bdd
--- /dev/null
+++ b/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 0000000..42c7fd7
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,109 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
+
+ def env_var_version
+ ENV["BUNDLER_VERSION"]
+ end
+
+ def cli_arg_version
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ bundler_version = nil
+ update_index = nil
+ ARGV.each_with_index do |a, i|
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ bundler_version = a
+ end
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+ bundler_version = $1
+ update_index = i
+ end
+ bundler_version
+ end
+
+ def gemfile
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ return gemfile if gemfile && !gemfile.empty?
+
+ File.expand_path("../Gemfile", __dir__)
+ end
+
+ def lockfile
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
+ end
+
+ def lockfile_version
+ return unless File.file?(lockfile)
+ lockfile_contents = File.read(lockfile)
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+ Regexp.last_match(1)
+ end
+
+ def bundler_requirement
+ @bundler_requirement ||=
+ env_var_version ||
+ cli_arg_version ||
+ bundler_requirement_for(lockfile_version)
+ end
+
+ def bundler_requirement_for(version)
+ return "#{Gem::Requirement.default}.a" unless version
+
+ bundler_gem_version = Gem::Version.new(version)
+
+ bundler_gem_version.approximate_recommendation
+ end
+
+ def load_bundler!
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+ activate_bundler
+ end
+
+ def activate_bundler
+ gem_error = activation_error_handling do
+ gem "bundler", bundler_requirement
+ end
+ return if gem_error.nil?
+ require_error = activation_error_handling do
+ require "bundler/version"
+ end
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
+ exit 42
+ end
+
+ def activation_error_handling
+ yield
+ nil
+ rescue StandardError, LoadError => e
+ e
+ end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint
new file mode 100755
index 0000000..67ef493
--- /dev/null
+++ b/bin/docker-entrypoint
@@ -0,0 +1,8 @@
+#!/bin/bash -e
+
+# If running the rails server then create or migrate existing database
+if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
+ ./bin/rails db:prepare
+fi
+
+exec "${@}"
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 0000000..efc0377
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000..4fbf10b
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative "../config/boot"
+require "rake"
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000..3cd5a9d
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require "fileutils"
+
+# path to your application root.
+APP_ROOT = File.expand_path("..", __dir__)
+
+def system!(*args)
+ system(*args, exception: true)
+end
+
+FileUtils.chdir APP_ROOT do
+ # This script is a way to set up or update your development environment automatically.
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
+ # Add necessary setup steps to this file.
+
+ puts "== Installing dependencies =="
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
+ # end
+
+ puts "\n== Preparing database =="
+ system! "bin/rails db:prepare"
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! "bin/rails log:clear tmp:clear"
+
+ puts "\n== Restarting application server =="
+ system! "bin/rails restart"
+end
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000..ad1fbf2
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,6 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
+Rails.application.load_server
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 0000000..638c80f
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,34 @@
+require_relative "boot"
+
+require "rails/all"
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module FinalCapstoneBackEnd
+ class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 7.1
+
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
+ config.autoload_lib(ignore: %w(assets tasks))
+
+ # Configuration for the application, engines, and railties goes here.
+ #
+ # These settings can be overridden in specific environments using the files
+ # in config/environments, which are processed later.
+ #
+ # config.time_zone = "Central Time (US & Canada)"
+ # config.eager_load_paths << Rails.root.join("extras")
+
+ # Only loads a smaller set of middleware suitable for API only apps.
+ # Middleware like session, flash, cookies can be added back manually.
+ # Skip views, helpers and assets when generating a new resource.
+ config.api_only = true
+ config.middleware.use ActionDispatch::Cookies # Added this line
+ config.middleware.use ActionDispatch::Session::CookieStore # Added this line
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 0000000..988a5dd
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,4 @@
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
+
+require "bundler/setup" # Set up gems listed in the Gemfile.
+require "bootsnap/setup" # Speed up boot time by caching expensive operations.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000..f2f2cad
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: test
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: final_capstone_back_end_production
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
new file mode 100644
index 0000000..b3baafa
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+hAMsQeXRg/cvleA8Kk13DbBsjUOjI9VjtKfKRZeogkZWmd41D7yACbA0yhuM7z1kCfi9m8wgymw9soxwGwv6/WmmHEMQTUMGMLxpsQ84bE80d/yIHEMVAvGjvYmS1ITYy7+McElWJ80+XuT4dO7CUgBBApKPlm0Im40XuNV02ld6lVPBVtq9u1zJ+9hoLRoYOmSo7tStQrDypbtGaxg6ifHDu75nzAzTKifDw7CnKbkEkPcvWUpacMy01z1W1XGC3xW1EhR8ejB8ZoUWKFsh81vodD2nvPrlwwrm1keH6NViOre9WusuQoVKI744UBgp1J6La9ujLbfuUspc04fO7UCwmcOxrbsFTZ/Dbj+OdLKEYMIZg/bfR4bZV1qNN15WATPxLj8TbXpK0P5I6jOyNnyH+KMg--RJbmBNkT+v1staIj--LPuxVzc38D6DizARIH9RGw==
\ No newline at end of file
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000..7bde612
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,84 @@
+# PostgreSQL. Versions 9.3 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On macOS with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem "pg"
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see Rails configuration guide
+ # https://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: final_capstone_back_end_development
+
+ # The specified database role being used to connect to PostgreSQL.
+ # To create additional roles in PostgreSQL see `$ createuser --help`.
+ # When left blank, PostgreSQL will use the default role. This is
+ # the same name as the operating system user running Rails.
+ #username: final_capstone_back_end
+
+ # The password associated with the PostgreSQL role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: final_capstone_back_end_test
+
+# As with config/credentials.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password or a full connection URL as an environment
+# variable when you boot the app. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# If the connection URL is provided in the special DATABASE_URL environment
+# variable, Rails will automatically merge its configuration values on top of
+# the values provided in this file. Alternatively, you can specify a connection
+# URL environment variable explicitly:
+#
+# production:
+# url: <%= ENV["MY_APP_DATABASE_URL"] %>
+#
+# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full overview on how database connection configuration can be specified.
+#
+production:
+ <<: *default
+ database: final_capstone_back_end_production
+ username: final_capstone_back_end
+ password: <%= ENV["FINAL_CAPSTONE_BACK_END_DATABASE_PASSWORD"] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 0000000..cac5315
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative "application"
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 0000000..e701c0d
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,71 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
+ # In the development environment your application's code is reloaded any time
+ # it changes. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.enable_reloading = true
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable server timing
+ config.server_timing = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join("tmp/caching-dev.txt").exist?
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # Highlight code that enqueued background job in logs.
+ config.active_job.verbose_enqueue_logs = true
+
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Uncomment if you wish to allow Action Cable access from any origin.
+ # config.action_cable.disable_request_forgery_protection = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 0000000..e99a554
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,90 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.enable_reloading = false
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it).
+ config.public_file_server.enabled = true
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.asset_host = "http://assets.example.com"
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain.
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = "wss://example.com/cable"
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
+
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
+ # config.assume_ssl = true
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ config.force_ssl = true
+
+ # Log to STDOUT by default
+ config.logger = ActiveSupport::Logger.new(STDOUT)
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Info include generic and useful information about system operation, but avoids logging too much
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
+ # want to log everything, set the level to "debug".
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment).
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "final_capstone_back_end_production"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+
+ # Enable DNS rebinding protection and other `Host` header attacks.
+ # config.hosts = [
+ # "example.com", # Allow requests from example.com
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
+ # ]
+ # Skip DNS rebinding protection for the default health check endpoint.
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 0000000..0dda9f9
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,64 @@
+require "active_support/core_ext/integer/time"
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # While tests run files are not watched, reloading is not necessary.
+ config.enable_reloading = false
+
+ # Eager loading loads your entire application. When running a single test locally,
+ # this is usually not necessary, and can slow down your test suite. However, it's
+ # recommended that you enable it in continuous integration systems to ensure eager
+ # loading is working properly before deploying your code.
+ config.eager_load = ENV["CI"].present?
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+ config.cache_store = :null_store
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = :rescuable
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory.
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb
new file mode 100644
index 0000000..4e0034a
--- /dev/null
+++ b/config/initializers/cors.rb
@@ -0,0 +1,9 @@
+Rails.application.config.middleware.insert_before 0, Rack::Cors do
+ allow do
+ origins 'http://localhost:3001'
+ resource '*',
+ headers: :any,
+ methods: [:get, :post, :put, :patch, :delete, :options, :head],
+ credentials: true
+ end
+end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
new file mode 100644
index 0000000..8c51dc2
--- /dev/null
+++ b/config/initializers/devise.rb
@@ -0,0 +1,313 @@
+# frozen_string_literal: true
+
+# Assuming you have not yet modified this file, each configuration option below
+# is set to its default value. Note that some are commented out while others
+# are not: uncommented lines are intended to protect your configuration from
+# breaking changes in upgrades (i.e., in the event that future versions of
+# Devise change the default values for those options).
+#
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+ # The secret key used by Devise. Devise uses this key to generate
+ # random tokens. Changing this key will render invalid all existing
+ # confirmation, reset password and unlock tokens in the database.
+ # Devise will use the `secret_key_base` as its `secret_key`
+ # by default. You can change it below and use your own secret key.
+ # config.secret_key = '33ecd5075b4af2bc6c0ad66ea4bf05a64112604a82dcd7e48aa68d4fe8459f570cec4a9a089b916ab79126224c9b954cb4f862e376cfcee8dd18d2e10a66f120'
+
+ # ==> Controller configuration
+ # Configure the parent class to the devise controllers.
+ # config.parent_controller = 'DeviseController'
+
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class
+ # with default "from" parameter.
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = 'Devise::Mailer'
+
+ # Configure the parent class responsible to send e-mails.
+ # config.parent_mailer = 'ActionMailer::Base'
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [:email]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [:email]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [:email]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
+ # enable it only for database authentication.
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
+ # enable this with :database unless you are using a custom strategy.
+ # The supported strategies are:
+ # :database = Support basic authentication with authentication key + password
+ # config.http_authenticatable = false
+
+ # If 401 status code should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. 'Application' by default.
+ # config.http_authentication_realm = 'Application'
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # particular strategies by setting this option.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # By default, Devise cleans up the CSRF token on authentication to
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
+ # requests for sign in and sign up, you need to get a new CSRF token
+ # from the server. You can disable this option at your own risk.
+ # config.clean_up_csrf_token_on_authentication = true
+
+ # When false, Devise will not attempt to reload routes on eager load.
+ # This can reduce the time taken to boot the app but if your application
+ # requires the Devise mappings to be loaded during boot time the application
+ # won't boot properly.
+ # config.reload_routes = true
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
+ # using other algorithms, it sets how many times you want the password to be hashed.
+ # The number of stretches used for generating the hashed password are stored
+ # with the hashed password. This allows you to change the stretches without
+ # invalidating existing passwords.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+ config.stretches = Rails.env.test? ? 1 : 12
+
+ # Set up a pepper to generate the hashed password.
+ # config.pepper = 'cb68259e84b3e1053daaa9b801f065679c76a60403af285154d99333d2aed5dc6bda9f10652bbbee2c1fa669d5d4a0b910856cea12f6baa81f029cd088175466'
+
+ # Send a notification to the original email when the user's email is changed.
+ # config.send_email_changed_notification = false
+
+ # Send a notification email when the user's password is changed.
+ # config.send_password_change_notification = false
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming their account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming their account,
+ # access will be blocked just in the third day.
+ # You can also set it to nil, which will allow the user to access the website
+ # without confirming their account.
+ # Default is 0.days, meaning the user cannot access the website without
+ # confirming their account.
+ # config.allow_unconfirmed_access_for = 2.days
+
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
+ # If true, requires any email changes to be confirmed (exactly the same way as
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
+ # db field (see migrations). Until confirmed, new email is stored in
+ # unconfirmed_email column, and copied to email column on successful confirmation.
+ config.reconfirmable = true
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [:email]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # Invalidates all the remember me tokens when the user signs out.
+ config.expire_all_remember_me_on_sign_out = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # secure: true in order to force SSL only cookies.
+ # config.rememberable_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length.
+ config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [:email]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # Warn on the last attempt before the account is locked.
+ # config.last_attempt_warning = true
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [:email]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 6.hours
+
+ # When set to false, does not sign a user in automatically after their password is
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
+ # config.sign_in_after_reset_password = true
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
+ # for default behavior) and :restful_authentication_sha1 (then you should set
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
+ #
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
+ # config.encryptor = :sha512
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Set this configuration to false if you want /users/sign_out to sign out
+ # only the current scope. By default, Devise signs out all scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The "*/*" below is required to match Internet Explorer requests.
+ # config.navigational_formats = ['*/*', :html, :turbo_stream]
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.intercept_401 = false
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
+ # end
+
+ # ==> Mountable engine configurations
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+ # is mountable, there are some extra configurations to be taken into account.
+ # The following options are available, assuming the engine is mounted as:
+ #
+ # mount MyEngine, at: '/my_engine'
+ #
+ # The router that invoked `devise_for`, in the example above, would be:
+ # config.router_name = :my_engine
+ #
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
+ # so you need to do it manually. For the users scope, it would be:
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
+
+ # ==> Hotwire/Turbo configuration
+ # When using Devise with Hotwire/Turbo, the http status for error responses
+ # and some redirects must match the following. The default in Devise for existing
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
+ # these new defaults that match Hotwire/Turbo behavior.
+ # Note: These might become the new default in future versions of Devise.
+ config.responder.error_status = :unprocessable_entity
+ config.responder.redirect_status = :see_other
+
+ # ==> Configuration for :registerable
+
+ # When set to false, does not sign a user in automatically after their password is
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
+ # config.sign_in_after_change_password = true
+end
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..c2d89e2
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
+# Use this to limit dissemination of sensitive information.
+# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
+Rails.application.config.filter_parameters += [
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 0000000..3860f65
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym "RESTful"
+# end
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
new file mode 100644
index 0000000..260e1c4
--- /dev/null
+++ b/config/locales/devise.en.yml
@@ -0,0 +1,65 @@
+# Additional translations at https://github.com/heartcombo/devise/wiki/I18n
+
+en:
+ devise:
+ confirmations:
+ confirmed: "Your email address has been successfully confirmed."
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
+ failure:
+ already_authenticated: "You are already signed in."
+ inactive: "Your account is not activated yet."
+ invalid: "Invalid %{authentication_keys} or password."
+ locked: "Your account is locked."
+ last_attempt: "You have one more attempt before your account is locked."
+ not_found_in_database: "Invalid %{authentication_keys} or password."
+ timeout: "Your session expired. Please sign in again to continue."
+ unauthenticated: "You need to sign in or sign up before continuing."
+ unconfirmed: "You have to confirm your email address before continuing."
+ mailer:
+ confirmation_instructions:
+ subject: "Confirmation instructions"
+ reset_password_instructions:
+ subject: "Reset password instructions"
+ unlock_instructions:
+ subject: "Unlock instructions"
+ email_changed:
+ subject: "Email Changed"
+ password_change:
+ subject: "Password Changed"
+ omniauth_callbacks:
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+ success: "Successfully authenticated from %{kind} account."
+ passwords:
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+ updated: "Your password has been changed successfully. You are now signed in."
+ updated_not_active: "Your password has been changed successfully."
+ registrations:
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
+ signed_up: "Welcome! You have signed up successfully."
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
+ updated: "Your account has been updated successfully."
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
+ sessions:
+ signed_in: "Signed in successfully."
+ signed_out: "Signed out successfully."
+ already_signed_out: "Signed out successfully."
+ unlocks:
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+ errors:
+ messages:
+ already_confirmed: "was already confirmed, please try signing in"
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000..6c349ae
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,31 @@
+# Files in the config/locales directory are used for internationalization and
+# are automatically loaded by Rails. If you want to use locales other than
+# English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t "hello"
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t("hello") %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more about the API, please read the Rails Internationalization guide
+# at https://guides.rubyonrails.org/i18n.html.
+#
+# Be aware that YAML interprets the following case-insensitive strings as
+# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
+# must be quoted to be interpreted as strings. For example:
+#
+# en:
+# "yes": yup
+# enabled: "ON"
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000..afa809b
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,35 @@
+# This configuration file will be evaluated by Puma. The top-level methods that
+# are invoked here are part of Puma's configuration DSL. For more information
+# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
+
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
+threads min_threads_count, max_threads_count
+
+# Specifies that the worker count should equal the number of processors in production.
+if ENV["RAILS_ENV"] == "production"
+ require "concurrent-ruby"
+ worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
+ workers worker_count if worker_count > 1
+end
+
+# Specifies the `worker_timeout` threshold that Puma will use to wait before
+# terminating a worker in development environments.
+worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
+# Allow puma to be restarted by `bin/rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000..c1d5dd3
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,19 @@
+Rails.application.routes.draw do
+ namespace :api do
+ get 'users/current', to: 'users#current'
+
+ resources :cars do
+ member do
+ get 'image'
+ end
+ resources :reservations, only: [:create, :index]
+ end
+
+ resources :users, only: [:index, :create, :show]
+ post 'login', to: 'sessions#create'
+ delete 'logout', to: 'sessions#destroy'
+
+ resources :reservations, only: [:show, :update, :destroy]
+ get 'user_reservations', to: 'reservations#user_reservations'
+ end
+end
diff --git a/config/storage.yml b/config/storage.yml
new file mode 100644
index 0000000..4942ab6
--- /dev/null
+++ b/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name-<%= Rails.env %>
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/db/migrate/20231025213602_devise_create_users.rb b/db/migrate/20231025213602_devise_create_users.rb
new file mode 100644
index 0000000..b5e6b59
--- /dev/null
+++ b/db/migrate/20231025213602_devise_create_users.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class DeviseCreateUsers < ActiveRecord::Migration[7.1]
+ def change
+ create_table :users do |t|
+ ## Database authenticatable
+ t.string :email, null: false, default: ""
+ t.string :encrypted_password, null: false, default: ""
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ # t.integer :sign_in_count, default: 0, null: false
+ # t.datetime :current_sign_in_at
+ # t.datetime :last_sign_in_at
+ # t.string :current_sign_in_ip
+ # t.string :last_sign_in_ip
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+
+ t.timestamps null: false
+ end
+
+ # add_index :users, :email, unique: true
+ # add_index :users, :reset_password_token, unique: true
+ # add_index :users, :confirmation_token, unique: true
+ # add_index :users, :unlock_token, unique: true
+ end
+end
diff --git a/db/migrate/20231025215248_create_cars.rb b/db/migrate/20231025215248_create_cars.rb
new file mode 100644
index 0000000..f9a0083
--- /dev/null
+++ b/db/migrate/20231025215248_create_cars.rb
@@ -0,0 +1,16 @@
+class CreateCars < ActiveRecord::Migration[7.1]
+ def change
+ create_table :cars do |t|
+ t.string :name
+ t.text :description
+ t.integer :deposit
+ t.integer :finance_fee
+ t.integer :option_to_purchase_fee
+ t.integer :total_amount_payable
+ t.integer :duration
+ t.boolean :removed
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231025215755_create_reservations.rb b/db/migrate/20231025215755_create_reservations.rb
new file mode 100644
index 0000000..fcc89ec
--- /dev/null
+++ b/db/migrate/20231025215755_create_reservations.rb
@@ -0,0 +1,14 @@
+class CreateReservations < ActiveRecord::Migration[7.1]
+ def change
+ create_table :reservations do |t|
+ t.references :user, null: false, foreign_key: true
+ t.references :car, null: false, foreign_key: true
+ t.datetime :start_time
+ t.datetime :end_time
+ t.boolean :available
+ t.string :city
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231026145702_remove_available_from_reservations.rb b/db/migrate/20231026145702_remove_available_from_reservations.rb
new file mode 100644
index 0000000..f739e50
--- /dev/null
+++ b/db/migrate/20231026145702_remove_available_from_reservations.rb
@@ -0,0 +1,5 @@
+class RemoveAvailableFromReservations < ActiveRecord::Migration[7.1]
+ def change
+ remove_column :reservations, :available
+ end
+end
diff --git a/db/migrate/20231026184727_create_active_storage_tables.active_storage.rb b/db/migrate/20231026184727_create_active_storage_tables.active_storage.rb
new file mode 100644
index 0000000..e4706aa
--- /dev/null
+++ b/db/migrate/20231026184727_create_active_storage_tables.active_storage.rb
@@ -0,0 +1,57 @@
+# This migration comes from active_storage (originally 20170806125915)
+class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
+ def change
+ # Use Active Record's configured type for primary and foreign keys
+ primary_key_type, foreign_key_type = primary_and_foreign_key_types
+
+ create_table :active_storage_blobs, id: primary_key_type do |t|
+ t.string :key, null: false
+ t.string :filename, null: false
+ t.string :content_type
+ t.text :metadata
+ t.string :service_name, null: false
+ t.bigint :byte_size, null: false
+ t.string :checksum
+
+ if connection.supports_datetime_with_precision?
+ t.datetime :created_at, precision: 6, null: false
+ else
+ t.datetime :created_at, null: false
+ end
+
+ t.index [ :key ], unique: true
+ end
+
+ create_table :active_storage_attachments, id: primary_key_type do |t|
+ t.string :name, null: false
+ t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
+ t.references :blob, null: false, type: foreign_key_type
+
+ if connection.supports_datetime_with_precision?
+ t.datetime :created_at, precision: 6, null: false
+ else
+ t.datetime :created_at, null: false
+ end
+
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
+ t.foreign_key :active_storage_blobs, column: :blob_id
+ end
+
+ create_table :active_storage_variant_records, id: primary_key_type do |t|
+ t.belongs_to :blob, null: false, index: false, type: foreign_key_type
+ t.string :variation_digest, null: false
+
+ t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
+ t.foreign_key :active_storage_blobs, column: :blob_id
+ end
+ end
+
+ private
+ def primary_and_foreign_key_types
+ config = Rails.configuration.generators
+ setting = config.options[config.orm][:primary_key_type]
+ primary_key_type = setting || :primary_key
+ foreign_key_type = setting || :bigint
+ [primary_key_type, foreign_key_type]
+ end
+end
diff --git a/db/migrate/20231026205125_remove_devise_columns_from_users.rb b/db/migrate/20231026205125_remove_devise_columns_from_users.rb
new file mode 100644
index 0000000..461f505
--- /dev/null
+++ b/db/migrate/20231026205125_remove_devise_columns_from_users.rb
@@ -0,0 +1,10 @@
+class RemoveDeviseColumnsFromUsers < ActiveRecord::Migration[7.1]
+ def change
+ remove_column :users, :email
+ remove_column :users, :encrypted_password
+ remove_column :users, :reset_password_token
+ remove_column :users, :reset_password_sent_at
+ remove_column :users, :remember_created_at
+
+ end
+end
diff --git a/db/migrate/20231026205913_add_name_email_and_password_to_users.rb b/db/migrate/20231026205913_add_name_email_and_password_to_users.rb
new file mode 100644
index 0000000..8824e3f
--- /dev/null
+++ b/db/migrate/20231026205913_add_name_email_and_password_to_users.rb
@@ -0,0 +1,7 @@
+class AddNameEmailAndPasswordToUsers < ActiveRecord::Migration[7.1]
+ def change
+ add_column :users, :name, :string
+ add_column :users, :email, :string
+ add_column :users, :password, :string
+ end
+end
diff --git a/db/migrate/20231026225531_rename_password_column_in_users.rb b/db/migrate/20231026225531_rename_password_column_in_users.rb
new file mode 100644
index 0000000..3c3528e
--- /dev/null
+++ b/db/migrate/20231026225531_rename_password_column_in_users.rb
@@ -0,0 +1,5 @@
+class RenamePasswordColumnInUsers < ActiveRecord::Migration[7.1]
+ def change
+ rename_column :users, :password, :password_digest
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..ae390ec
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,82 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema[7.1].define(version: 2023_10_26_225531) do
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "active_storage_attachments", force: :cascade do |t|
+ t.string "name", null: false
+ t.string "record_type", null: false
+ t.bigint "record_id", null: false
+ t.bigint "blob_id", null: false
+ t.datetime "created_at", null: false
+ t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
+ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
+ end
+
+ create_table "active_storage_blobs", force: :cascade do |t|
+ t.string "key", null: false
+ t.string "filename", null: false
+ t.string "content_type"
+ t.text "metadata"
+ t.string "service_name", null: false
+ t.bigint "byte_size", null: false
+ t.string "checksum"
+ t.datetime "created_at", null: false
+ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
+ end
+
+ create_table "active_storage_variant_records", force: :cascade do |t|
+ t.bigint "blob_id", null: false
+ t.string "variation_digest", null: false
+ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
+ end
+
+ create_table "cars", force: :cascade do |t|
+ t.string "name"
+ t.text "description"
+ t.integer "deposit"
+ t.integer "finance_fee"
+ t.integer "option_to_purchase_fee"
+ t.integer "total_amount_payable"
+ t.integer "duration"
+ t.boolean "removed"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "reservations", force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.bigint "car_id", null: false
+ t.datetime "start_time"
+ t.datetime "end_time"
+ t.string "city"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["car_id"], name: "index_reservations_on_car_id"
+ t.index ["user_id"], name: "index_reservations_on_user_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "name"
+ t.string "email"
+ t.string "password_digest"
+ end
+
+ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
+ add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
+ add_foreign_key "reservations", "cars"
+ add_foreign_key "reservations", "users"
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000..354ef85
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,28 @@
+Car.delete_all
+
+Car.create([
+ {
+ id: 1,
+ name: "Car 1",
+ description: "This is a description for Car 1",
+ deposit: 1000,
+ finance_fee: 200,
+ option_to_purchase_fee: 300,
+ total_amount_payable: 1500,
+ duration: 12,
+ removed: false,
+ image: "image_url_1"
+ },
+ {
+ id: 2,
+ name: "Car 2",
+ description: "This is a description for Car 2",
+ deposit: 2000,
+ finance_fee: 200,
+ option_to_purchase_fee: 300,
+ total_amount_payable: 1500,
+ duration: 12,
+ removed: false,
+ image: "image_url_2"
+ },
+])
\ No newline at end of file
diff --git a/diagram1.jpeg b/diagram1.jpeg
new file mode 100644
index 0000000..bfce535
Binary files /dev/null and b/diagram1.jpeg differ
diff --git a/documentation/Full Stack Capstone Project.postman_collection.json b/documentation/Full Stack Capstone Project.postman_collection.json
new file mode 100644
index 0000000..c61e206
--- /dev/null
+++ b/documentation/Full Stack Capstone Project.postman_collection.json
@@ -0,0 +1,477 @@
+{
+ "info": {
+ "_postman_id": "c8aa6272-86a4-41fb-b5ec-171e9242b734",
+ "name": "Full Stack Capstone Project",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_exporter_id": "19270283"
+ },
+ "item": [
+ {
+ "name": "http://localhost:3000/api/cars/3",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/cars/3",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars",
+ "3"
+ ]
+ },
+ "description": "Delete a car"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars/6",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/cars/6",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars",
+ "6"
+ ]
+ },
+ "description": "Catch a car by id"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/cars",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars"
+ ]
+ },
+ "description": "Catch all the cars"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/users",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"user\": {\n \"name\": \"ccc\",\n \"email\": \"ccc@ccc.com\",\n \"password\": \"123456\"\n }\n}\n",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "http://localhost:3000/api/users",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "users"
+ ]
+ },
+ "description": "Sign in users (create an user)"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/login",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"email\": \"bbb@bbb.com\",\n \"password\": \"123456\"\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "http://localhost:3000/api/login",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "login"
+ ]
+ },
+ "description": "Login an user (to open a session)"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/logout",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/logout",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "logout"
+ ]
+ },
+ "description": "Log out current user"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/user_reservations",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/user_reservations",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "user_reservations"
+ ]
+ },
+ "description": "All the reservations and cars reserved for the user..."
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars/2/reservations",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"reservation\": {\n \"start_time\": \"2023-10-28T14:00:00Z\",\n \"end_time\": \"2023-10-29T14:00:00Z\",\n \"city\": \"Copiapo\"\n }\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "http://localhost:3000/api/cars/2/reservations",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars",
+ "2",
+ "reservations"
+ ]
+ },
+ "description": "Add reservation with autocomplete"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/reservations/2",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/reservations/2",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "reservations",
+ "2"
+ ]
+ },
+ "description": "delete reservation"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars/4",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/cars/4",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars",
+ "4"
+ ]
+ },
+ "description": "Delete a car"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "car[name]",
+ "value": "Car 5",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[description]",
+ "value": "This is a description for Car 5",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[deposit]",
+ "value": "1400",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[finance_fee]",
+ "value": "300",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[option_to_purchase_fee]",
+ "value": "500",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[total_amount_payable]",
+ "value": "1250",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[duration]",
+ "value": "17",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[removed]",
+ "value": "false",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[image]",
+ "contentType": "",
+ "type": "file",
+ "src": "/Users/claudiapatriciarojassoto/Desktop/car-5.png"
+ }
+ ]
+ },
+ "url": {
+ "raw": "http://localhost:3000/api/cars",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars"
+ ]
+ },
+ "description": "Add a car with hash"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/cars",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "car[name]",
+ "value": "Car 111",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[description]",
+ "value": "This is a description for Car 5",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[deposit]",
+ "value": "1400",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[finance_fee]",
+ "value": "300",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[option_to_purchase_fee]",
+ "value": "500",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[total_amount_payable]",
+ "value": "1250",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[duration]",
+ "value": "17",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[removed]",
+ "value": "false",
+ "contentType": "",
+ "type": "text"
+ },
+ {
+ "key": "car[image]",
+ "contentType": "",
+ "type": "file",
+ "src": "/Users/claudiapatriciarojassoto/Desktop/car-5.png"
+ }
+ ]
+ },
+ "url": {
+ "raw": "http://localhost:3000/api/cars",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "cars"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/users",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/users",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "users"
+ ]
+ },
+ "description": "List all the users"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/users/2",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/users/2",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "users",
+ "2"
+ ]
+ },
+ "description": "List a ser information by id"
+ },
+ "response": []
+ },
+ {
+ "name": "http://localhost:3000/api/users/current",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://localhost:3000/api/users/current",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "3000",
+ "path": [
+ "api",
+ "users",
+ "current"
+ ]
+ },
+ "description": "Give details about the current user."
+ },
+ "response": []
+ }
+ ]
+}
diff --git a/initial_state_kanban.png b/initial_state_kanban.png
new file mode 100644
index 0000000..c49823d
Binary files /dev/null and b/initial_state_kanban.png differ
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/public/images/car-4.png b/public/images/car-4.png
new file mode 100644
index 0000000..6dce6c4
Binary files /dev/null and b/public/images/car-4.png differ
diff --git a/public/images/car-5.png b/public/images/car-5.png
new file mode 100644
index 0000000..e3e6661
Binary files /dev/null and b/public/images/car-5.png differ
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..c19f78a
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1 @@
+# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/spec/controllers/api/cars_controller_spec.rb b/spec/controllers/api/cars_controller_spec.rb
new file mode 100644
index 0000000..b86e7a7
--- /dev/null
+++ b/spec/controllers/api/cars_controller_spec.rb
@@ -0,0 +1,52 @@
+require 'rails_helper'
+
+RSpec.describe 'Api::Cars', type: :request do
+ let!(:user1) { FactoryBot.create(:user) }
+
+ before do
+ allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user1)
+ end
+
+ let!(:car1) { FactoryBot.create(:car, name: 'Car 1') }
+ let!(:car2) { FactoryBot.create(:car, name: 'Car 2') }
+
+ describe 'GET /api/cars' do
+ it 'returns all cars' do
+ get '/api/cars', headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+
+ cars = JSON.parse(response.body)
+ expect(cars.length).to eq(2)
+ end
+ end
+
+ describe 'GET /api/cars/:id' do
+ it 'returns a specific car' do
+ get "/api/cars/#{car1.id}", headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+
+ fetched_car = JSON.parse(response.body)['car']
+ expect(fetched_car['name']).to eq('Car 1')
+ end
+ end
+
+ describe 'POST /api/cars' do
+ it 'creates a new car' do
+ car_attributes = attributes_for(:car)
+ post '/api/cars', params: { car: car_attributes }, headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:created)
+ new_car = JSON.parse(response.body)
+ expect(new_car['message']).to eq('Car created successfully')
+ end
+ end
+
+ describe 'DELETE /api/cars/:id' do
+ it 'deletes a specific car' do
+ delete "/api/cars/#{car1.id}", headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:ok)
+
+ deleted_car = JSON.parse(response.body)
+ expect(deleted_car['message']).to eq('Car deleted successfully')
+ end
+ end
+end
diff --git a/spec/controllers/api/reservations_controller_spec.rb b/spec/controllers/api/reservations_controller_spec.rb
new file mode 100644
index 0000000..173f81a
--- /dev/null
+++ b/spec/controllers/api/reservations_controller_spec.rb
@@ -0,0 +1,61 @@
+require 'rails_helper'
+
+RSpec.describe 'Api::Reservations', type: :request do
+ let!(:user) { FactoryBot.create(:user) }
+ let!(:car) { FactoryBot.create(:car) }
+ let!(:reservation) { FactoryBot.create(:reservation, user:, car:) }
+
+ before do
+ allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
+ end
+
+ describe 'GET /api/user_reservations' do
+ it 'returns all reservations' do
+ get '/api/user_reservations', headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+ reservations = JSON.parse(response.body)
+ expect(reservations.length).to eq(1)
+ end
+ end
+
+ describe 'GET /api/reservations/:id' do
+ it 'returns a specific reservation' do
+ get "/api/reservations/#{reservation.id}", headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+ fetched_reservation = JSON.parse(response.body)
+ expect(fetched_reservation['id']).to eq(reservation.id)
+ end
+ end
+
+ describe 'POST /api/cars/:car_id/reservations' do
+ it 'creates a new reservation' do
+ car = create(:car, :available)
+ reservation_attributes = attributes_for(:reservation)
+ post "/api/cars/#{car.id}/reservations", params: { reservation: reservation_attributes },
+ headers: { 'Accept' => 'application/json' }
+
+ expect(response).to have_http_status(:success)
+ new_reservation = JSON.parse(response.body)
+ expect(new_reservation['success']).to eq(true)
+ end
+ end
+
+ describe 'PUT /api/reservations/:id' do
+ it 'updates a specific reservation' do
+ put "/api/reservations/#{reservation.id}", params: { reservation: { city: 'New City' } },
+ headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+ updated_reservation = Reservation.find(reservation.id)
+ expect(updated_reservation.city).to eq('New City')
+ end
+ end
+
+ describe 'DELETE /api/reservations/:id' do
+ it 'deletes a specific reservation' do
+ expect do
+ delete "/api/reservations/#{reservation.id}", headers: { 'Accept' => 'application/json' }
+ end.to change(Reservation, :count).by(-1)
+ expect(response).to have_http_status(:success)
+ end
+ end
+end
diff --git a/spec/controllers/api/users_controller_spec.rb b/spec/controllers/api/users_controller_spec.rb
new file mode 100644
index 0000000..97111b1
--- /dev/null
+++ b/spec/controllers/api/users_controller_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+RSpec.describe 'Api::Users', type: :request do
+ let!(:user1) { FactoryBot.create(:user, name: 'John Doe', email: 'john@example.com', password: 'password') }
+ let!(:user2) { FactoryBot.create(:user, name: 'Jane Doe', email: 'jane@example.com', password: 'password') }
+
+ describe 'GET /api/users' do
+ it 'returns all users' do
+ get '/api/users', headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+
+ users = JSON.parse(response.body)
+ expect(users.length).to eq(2)
+ end
+ end
+
+ describe 'GET /api/users/:id' do
+ it 'returns a specific user' do
+ get "/api/users/#{user1.id}", headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:success)
+
+ fetched_user = JSON.parse(response.body)
+ expect(fetched_user['name']).to eq('John Doe')
+ end
+ end
+
+ describe 'POST /api/users' do
+ it 'creates a new user' do
+ post '/api/users', params: { user: { name: 'New User', email: 'new@example.com', password: 'password' } },
+ headers: { 'Accept' => 'application/json' }
+ expect(response).to have_http_status(:created)
+
+ new_user = JSON.parse(response.body)
+ expect(new_user['success']).to eq(true)
+ expect(new_user['message']).to eq('Sign in was successful!')
+ end
+ end
+end
diff --git a/spec/factories/cars.rb b/spec/factories/cars.rb
new file mode 100644
index 0000000..946a4ed
--- /dev/null
+++ b/spec/factories/cars.rb
@@ -0,0 +1,20 @@
+FactoryBot.define do
+ factory :car do
+ name { "Modelo de coche #{Faker::Vehicle.make_and_model}" }
+ description { Faker::Vehicle.standard_specs.join(', ') }
+ deposit { Faker::Number.decimal(l_digits: 4, r_digits: 2) }
+ finance_fee { Faker::Number.decimal(l_digits: 4, r_digits: 2) }
+ option_to_purchase_fee { Faker::Number.decimal(l_digits: 4, r_digits: 2) }
+ total_amount_payable { deposit + finance_fee + option_to_purchase_fee }
+ duration { Faker::Number.between(from: 1, to: 5) }
+ removed { [true, false].sample }
+
+ trait :available do
+ removed { false }
+
+ after(:create) do |car, _evaluator|
+ car.reservations.destroy_all
+ end
+ end
+ end
+end
diff --git a/spec/factories/reservations.rb b/spec/factories/reservations.rb
new file mode 100644
index 0000000..77c179c
--- /dev/null
+++ b/spec/factories/reservations.rb
@@ -0,0 +1,9 @@
+FactoryBot.define do
+ factory :reservation do
+ car
+ user
+ city { Faker::Address.city }
+ start_time { Time.now + 1.day }
+ end_time { Time.now + 2.days }
+ end
+end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
new file mode 100644
index 0000000..e22b739
--- /dev/null
+++ b/spec/factories/users.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+ factory :user do
+ name { 'Test User' }
+ email { 'test@example.com' }
+ password { 'secure_password' }
+ end
+end
diff --git a/spec/models/car_spec.rb b/spec/models/car_spec.rb
new file mode 100644
index 0000000..9439715
--- /dev/null
+++ b/spec/models/car_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+RSpec.describe Car, type: :model do
+ subject { build(:car) }
+
+ it { is_expected.to validate_presence_of(:name) }
+ it { is_expected.to validate_presence_of(:description) }
+ it { is_expected.to validate_presence_of(:deposit) }
+ it { is_expected.to validate_presence_of(:finance_fee) }
+ it { is_expected.to validate_presence_of(:option_to_purchase_fee) }
+ it { is_expected.to validate_presence_of(:total_amount_payable) }
+ it { is_expected.to validate_presence_of(:duration) }
+
+ it { is_expected.to have_many(:reservations).dependent(:destroy) }
+ it { is_expected.to respond_to(:image) }
+
+ describe '#available?' do
+ let(:car) { create(:car) }
+ let!(:reservation) { create(:reservation, car:, start_time: Time.now + 1.hour, end_time: Time.now + 3.hours) }
+
+ context 'when the car is available' do
+ it 'returns true' do
+ expect(car.available?(Time.now + 4.hours, Time.now + 6.hours)).to be_truthy
+ end
+ end
+
+ context 'when the car is not available' do
+ it 'returns false' do
+ expect(car.available?(Time.now + 2.hours, Time.now + 4.hours)).to be_falsy
+ end
+ end
+ end
+end
diff --git a/spec/models/reservation_spec.rb b/spec/models/reservation_spec.rb
new file mode 100644
index 0000000..ef54ecf
--- /dev/null
+++ b/spec/models/reservation_spec.rb
@@ -0,0 +1,36 @@
+require 'rails_helper'
+
+RSpec.describe Reservation, type: :model do
+ describe 'associations' do
+ it { should belong_to(:user) }
+ it { should belong_to(:car) }
+ end
+
+ describe 'validations' do
+ subject { create(:reservation, start_time: 1.day.from_now, end_time: 2.days.from_now) }
+ it { should validate_presence_of(:start_time) }
+ it { should validate_presence_of(:end_time) }
+ it { should validate_presence_of(:city) }
+
+ it 'is not valid if start_time is in the past' do
+ reservation = build(:reservation, start_time: 1.day.ago, end_time: 2.days.from_now)
+ expect(reservation).not_to be_valid
+ end
+ end
+
+ describe '#reservation_with_car' do
+ let(:user) { create(:user) }
+ let(:car) { create(:car) }
+ let(:reservation) do
+ create(:reservation, user:, car:, start_time: 1.day.from_now, end_time: 2.days.from_now)
+ end
+
+ it 'returns a hash with reservation and car attributes' do
+ result = reservation.reservation_with_car
+ expect(result).to have_key(:reservation)
+ expect(result).to have_key(:car)
+ expect(result[:reservation]).to eq(reservation.attributes)
+ expect(result[:car]).to eq(reservation.car.attributes)
+ end
+ end
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
new file mode 100644
index 0000000..f128c85
--- /dev/null
+++ b/spec/models/user_spec.rb
@@ -0,0 +1,52 @@
+require 'rails_helper'
+
+RSpec.describe User, type: :model do
+ let(:user) { build(:user) }
+
+ describe 'validations' do
+ it 'validates presence of name' do
+ user.name = nil
+ expect(user).not_to be_valid
+ expect(user.errors.messages[:name]).to include("can't be blank")
+ end
+
+ it 'validates presence of email' do
+ user.email = nil
+ expect(user).not_to be_valid
+ expect(user.errors.messages[:email]).to include("can't be blank")
+ end
+
+ it 'validates uniqueness of email' do
+ create(:user, email: 'test@example.com')
+ user.email = 'test@example.com'
+ expect(user).not_to be_valid
+ expect(user.errors.messages[:email]).to include('has already been taken')
+ end
+
+ it 'validates presence of password on create' do
+ user.password = nil
+ expect(user).not_to be_valid
+ expect(user.errors.messages[:password]).to include("This is a custom password can't be blank message.")
+ end
+ end
+
+ describe 'associations' do
+ it 'has many reservations' do
+ should have_many(:reservations)
+ end
+ end
+
+ describe 'password_authentication' do
+ it 'authenticates with a correct password' do
+ user.password = 'secure_password'
+ user.save!
+ expect(user.authenticate('secure_password')).to be_truthy
+ end
+
+ it 'does not authenticate with an incorrect password' do
+ user.password = 'secure_password'
+ user.save!
+ expect(user.authenticate('wrong_password')).to be_falsey
+ end
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
new file mode 100644
index 0000000..195f562
--- /dev/null
+++ b/spec/rails_helper.rb
@@ -0,0 +1,89 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+require 'spec_helper'
+ENV['RAILS_ENV'] ||= 'test'
+require_relative '../config/environment'
+# Prevent database truncation if the environment is production
+abort('The Rails environment is running in production mode!') if Rails.env.production?
+require 'rspec/rails'
+require 'factory_bot_rails'
+require 'shoulda/matchers'
+require 'database_cleaner'
+
+# Add additional requires below this line. Rails is not loaded until this point!
+
+# Requires supporting ruby files with custom matchers and macros, etc, in
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
+# run as spec files by default. This means that files in spec/support that end
+# in _spec.rb will both be required and run as specs, causing the specs to be
+# run twice. It is recommended that you do not name files matching this glob to
+# end with _spec.rb. You can configure this pattern with the --pattern
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
+#
+# The following line is provided for convenience purposes. It has the downside
+# of increasing the boot-up time by auto-requiring all files in the support
+# directory. Alternatively, in the individual `*_spec.rb` files, manually
+# require only the support files necessary.
+#
+# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
+
+# Checks for pending migrations and applies them before tests are run.
+# If you are not using ActiveRecord, you can remove these lines.
+begin
+ ActiveRecord::Migration.maintain_test_schema!
+rescue ActiveRecord::PendingMigrationError => e
+ puts e.to_s.strip
+ exit 1
+end
+RSpec.configure do |config|
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{Rails.root}/spec/fixtures"
+ config.include FactoryBot::Syntax::Methods
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ Shoulda::Matchers.configure do |shoulda_config|
+ shoulda_config.integrate do |with|
+ with.test_framework :rspec
+ with.library :rails
+ end
+ end
+
+ # ConfiguraciΓ³n para DatabaseCleaner
+ config.before(:suite) do
+ DatabaseCleaner.clean_with(:truncation)
+ DatabaseCleaner.strategy = :transaction
+ end
+
+ config.around(:each) do |example|
+ DatabaseCleaner.cleaning do
+ example.run
+ end
+ end
+
+ config.use_transactional_fixtures = true
+
+ config.render_views = false
+
+ # You can uncomment this line to turn off ActiveRecord support entirely.
+ # config.use_active_record = false
+
+ # RSpec Rails can automatically mix in different behaviours to your tests
+ # based on their file location, for example enabling you to call `get` and
+ # `post` in specs under `spec/controllers`.
+ #
+ # You can disable this behaviour by removing the line below, and instead
+ # explicitly tag your specs with their type, e.g.:
+ #
+ # RSpec.describe UsersController, type: :controller do
+ # # ...
+ # end
+ #
+ # The different available types are documented in the features, such as in
+ # https://relishapp.com/rspec/rspec-rails/docs
+ config.infer_spec_type_from_file_location!
+
+ # Filter lines from Rails gems in backtraces.
+ config.filter_rails_from_backtrace!
+ # arbitrary gems may also be filtered via:
+ # config.filter_gems_from_backtrace("gem name")
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..9c96a9b
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,92 @@
+# This file was generated by the `rails generate rspec:install` command. Conventionally, all
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
+# The generated `.rspec` file contains `--require spec_helper` which will cause
+# this file to always be loaded, without a need to explicitly require it in any
+# files.
+#
+# Given that it is always loaded, you are encouraged to keep this file as
+# light-weight as possible. Requiring heavyweight dependencies from this file
+# will add to the boot time of your test suite on EVERY test run, even for an
+# individual file that may not need all of that loaded. Instead, consider making
+# a separate helper file that requires the additional dependencies and performs
+# the additional setup, and require it from the spec files that actually need
+# it.
+#
+# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+RSpec.configure do |config|
+ # rspec-expectations config goes here. You can use an alternate
+ # assertion/expectation library such as wrong or the stdlib/minitest
+ # assertions if you prefer.
+ config.expect_with :rspec do |expectations|
+ # This option will default to `true` in RSpec 4. It makes the `description`
+ # and `failure_message` of custom matchers include text for helper methods
+ # defined using `chain`, e.g.:
+ # be_bigger_than(2).and_smaller_than(4).description
+ # # => "be bigger than 2 and smaller than 4"
+ # ...rather than:
+ # # => "be bigger than 2"
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end
+
+ # rspec-mocks config goes here. You can use an alternate test double
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
+ config.mock_with :rspec do |mocks|
+ # Prevents you from mocking or stubbing a method that does not exist on
+ # a real object. This is generally recommended, and will default to
+ # `true` in RSpec 4.
+ mocks.verify_partial_doubles = true
+ end
+
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
+ # have no way to turn it off -- the option exists only for backwards
+ # compatibility in RSpec 3). It causes shared context metadata to be
+ # inherited by the metadata hash of host groups and examples, rather than
+ # triggering implicit auto-inclusion in groups with matching metadata.
+ config.shared_context_metadata_behavior = :apply_to_host_groups
+
+ # The settings below are suggested to provide a good initial experience
+ # with RSpec, but feel free to customize to your heart's content.
+ # # This allows you to limit a spec run to individual examples or groups
+ # # you care about by tagging them with `:focus` metadata. When nothing
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
+ # config.filter_run_when_matching :focus
+ #
+ # # Allows RSpec to persist some state between runs in order to support
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
+ # # you configure your source control system to ignore this file.
+ # config.example_status_persistence_file_path = "spec/examples.txt"
+ #
+ # # Limits the available syntax to the non-monkey patched syntax that is
+ # # recommended. For more details, see:
+ # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
+ # config.disable_monkey_patching!
+ #
+ # # Many RSpec users commonly either run the entire suite or an individual
+ # # file, and it's useful to allow more verbose output when running an
+ # # individual spec file.
+ # if config.files_to_run.one?
+ # # Use the documentation formatter for detailed output,
+ # # unless a formatter has already been configured
+ # # (e.g. via a command-line flag).
+ # config.default_formatter = "doc"
+ # end
+ #
+ # # Print the 10 slowest examples and example groups at the
+ # # end of the spec run, to help surface which specs are running
+ # # particularly slow.
+ # config.profile_examples = 10
+ #
+ # # Run specs in random order to surface order dependencies. If you find an
+ # # order dependency and want to debug it, you can fix the order by providing
+ # # the seed, which is printed after each run.
+ # # --seed 1234
+ # config.order = :random
+ #
+ # # Seed global randomization in this process using the `--seed` CLI option.
+ # # Setting this allows you to use `--seed` to deterministically reproduce
+ # # test failures related to randomization by passing the same `--seed` value
+ # # as the one that triggered the failure.
+ # Kernel.srand config.seed
+end
diff --git a/storage/.keep b/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tmp/.keep b/tmp/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tmp/pids/.keep b/tmp/pids/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tmp/storage/.keep b/tmp/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/.keep b/vendor/.keep
new file mode 100644
index 0000000..e69de29