BrentBarnes / 8-Bit-Flight-Booker

A Ruby-on-Rails app where users can book flights for multiple passengers
0 stars 0 forks source link
activerecord complex-forms ruby-on-rails seeding

8-Bit Flight Booker

This is a project from the Advanced Forms and Active Record section in The Odin Project's Ruby on Rains curriculum. The original project can be found here: Flight Booker Project

Functionality

Screenshots

Loading/Search Page
Flight Booker home page
Search Results
Flight booker search results
Passenger Information
Flight booker passenger details
Final Booking
Flight booker final booking
Mailer

When booking two passengers, it will send confirmation emails to each passenger. Booking two passengers First passenger email Second passenger email
Tests
Passing tests

Local Installation

To get started with the app, make sure you have Rails and Git installed on your machine
Clone the repo to your local machine:

$ git clone git@github.com:BrentBarnes/Odin-Flight-Booker.git

Then, install the needed gems:

$ bundle install

Next, migrate the database:

$ rails db:migrate

Load sample airports and flights:

$ rails db:seed

Finally, on root path run a local server:

$ rails server

Open browser to view application:

localhost:3000

Run The Tests

Tests Include

Search Flights

  1. Valid inputs: Expect page to have content "From: San Francisco, CA | To: New York City, NY | Date: Monday, August 01"
  2. Invalid inputs: Expect page to have content "No flights found. Please make sure you have selected an option for each field."

Create Passengers

  1. Valid inputs: Expect page to have content "Your flight has successfully been booked. Welcome aboard!"
  2. Invalid inputs: Expect page to have content "You must fill out all fields"

After local installation, run:

$ bundle exec rspec spec/features/

Data Model Associations

class Airport < ApplicationRecord
  has_many :departing_flights, class_name: "Flight", foreign_key: :departure_airport_id
  has_many :arriving_flights, class_name: "Flight", foreign_key: :arrival_airport_id
end
class Flight < ApplicationRecord
  belongs_to :departure_airport, class_name: "Airport"
  belongs_to :arrival_airport, class_name: "Airport"
  has_many :bookings
  has_many :passengers
end
class Booking < ApplicationRecord
  belongs_to :flight
  has_many :passengers
  accepts_nested_attributes_for :passengers
end
class Passenger < ApplicationRecord
  belongs_to :booking
end