diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 000000000..e69de29bb diff --git a/Gemfile b/Gemfile index 5efe339e6..6bfc1f339 100644 --- a/Gemfile +++ b/Gemfile @@ -37,7 +37,7 @@ gem "redis", "~> 4.0" # gem "kredis" # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" +gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] @@ -83,3 +83,8 @@ gem 'dotenv-rails' # gem 'paperclip # gem 'uniquify' # gem 'will_paginate' + +gem "geocoder", "~> 1.8" + +# dynamic map +gem "mapkick-rb" diff --git a/Gemfile.lock b/Gemfile.lock index c3e104938..cc0b2c248 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) + bcrypt (3.1.19) bindex (0.8.1) bootsnap (1.13.0) msgpack (~> 1.2) @@ -93,6 +94,7 @@ GEM dotenv (= 2.8.1) railties (>= 3.2) erubi (1.11.0) + geocoder (1.8.2) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) @@ -111,6 +113,7 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) + mapkick-rb (0.1.5) marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) @@ -223,15 +226,20 @@ GEM PLATFORMS arm64-darwin-20 + arm64-darwin-21 + arm64-darwin-22 x86_64-linux DEPENDENCIES + bcrypt (~> 3.1.7) bootsnap capybara debug dotenv-rails + geocoder (~> 1.8) importmap-rails jbuilder + mapkick-rb mysql2 (~> 0.5) puma (~> 5.0) rails (~> 7.0.3, >= 7.0.3.1) diff --git a/README.md b/README.md index 85f6c86ae..17e00d2d9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # ValetBike - +Paola Smith College CSC223: Software Engineering\ Starter App for ValetBike project +This is a change that I am making to valetbike! ## Environment Configuration diff --git a/app/assets/images/logo.svg b/app/assets/images/logo.svg new file mode 100644 index 000000000..7f4121c43 --- /dev/null +++ b/app/assets/images/logo.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/stylesheets/button.css b/app/assets/stylesheets/button.css new file mode 100644 index 000000000..9d2756567 --- /dev/null +++ b/app/assets/stylesheets/button.css @@ -0,0 +1,5 @@ + + +.button{ + background-color: rgb(132 204 22); +} \ No newline at end of file diff --git a/app/assets/stylesheets/error-messages.css b/app/assets/stylesheets/error-messages.css new file mode 100644 index 000000000..86738f4e4 --- /dev/null +++ b/app/assets/stylesheets/error-messages.css @@ -0,0 +1,20 @@ +/* Error Messages CSS */ +.error-explanation { + background-color: #fed7d7; + border: 1px solid #f98080; + color: #c53030; + padding: 1rem; + border-radius: 0.375rem; + margin-top: 1rem; + } + +.error-list { +list-style-type: disc; +padding-left: 1.25rem; +margin-top: 0.5rem; +} + +.error-message { +font-weight: bold; +} + \ No newline at end of file diff --git a/app/assets/stylesheets/flash.css b/app/assets/stylesheets/flash.css new file mode 100644 index 000000000..7279ddfdc --- /dev/null +++ b/app/assets/stylesheets/flash.css @@ -0,0 +1,19 @@ +.flash{ + padding: 20px; + color: white; + width: 90%; /* Set width to 100% of the parent element */ + opacity: 90%; + margin-left: auto; + margin-right: auto; + +} + +#notice { + background-color: var(--green-color); /* Override color for notice */ + border-color: 3px, solid, var(--dark-green-color); +} + +#alert { + background-color: var(--red-color); /* Red for alert, green for notice */ + border-color: 3px, solid, var(--dark-green-color); +} diff --git a/app/assets/stylesheets/form.css b/app/assets/stylesheets/form.css new file mode 100644 index 000000000..0c9e01034 --- /dev/null +++ b/app/assets/stylesheets/form.css @@ -0,0 +1,34 @@ +.form-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 20px; + } + +.form-group { + margin-bottom: 15px; +} + +label { + display: block; + margin-bottom: 5px; + color: var(--light-black-color); + font-weight: bold; +} + +input[type="text"], input[type="password"] { + /* Inherits styles from previous CSS */ + width: 100%; /* Adjust as necessary */ + color: black; +} + +.form-buttons { + display: flex; + justify-content: center; + margin-top: 20px; +} + +input#search_by_address { + color: black; +} \ No newline at end of file diff --git a/app/assets/stylesheets/navbar.css b/app/assets/stylesheets/navbar.css new file mode 100644 index 000000000..2d92d3ae5 --- /dev/null +++ b/app/assets/stylesheets/navbar.css @@ -0,0 +1,42 @@ +/* currently does not work...not invoked or something - ryan */ +/* change navbar background color to custom */ +#navbar { + padding-top: 2%; + padding-bottom: 4%; + z-index: 100; + background-color: var(--blue-color); + height: 5em; +} + +#navbar-content { + height: 3em; + width: 100%; +} + +@media (min-width: 80em){ + #navbar-content { + width: 70em; + } + + .logo { + + } +} + + +.white-fill { + fill: var(--medium-white-color); + +} + +.logo { + margin-left: 1em; +} + +.dropdown-menu { + z-index: 1000; /* Adjust the value as needed */ + position: relative; +} + +} + diff --git a/app/assets/stylesheets/pages.css b/app/assets/stylesheets/pages.css index 16bd64b55..f2e85b948 100644 --- a/app/assets/stylesheets/pages.css +++ b/app/assets/stylesheets/pages.css @@ -26,14 +26,38 @@ line-height: 1.75em; } +.record-row.header { + background: var(--black-color); + color:aliceblue; +} + + .record-row.even { background: var(--medium-white-color); } +.record-row.even.flexbox:hover{ + background: var(--light-black-color); + color:aliceblue; +} + .record-row.odd { background: var(--dark-white-color); } +.record-row.odd.flexbox:hover{ + background: var(--light-black-color); + color:aliceblue; +} + +.fill-block { + display: block; + height: 100%; + width: 100%; + text-decoration: none; +} + + /***********************************/ /* Responsiveness */ diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css new file mode 100644 index 000000000..edc30b656 --- /dev/null +++ b/app/assets/stylesheets/popup.css @@ -0,0 +1,32 @@ +.modal { + position: fixed; + z-index: 1000; + padding: 2em; + + /* Centering */ + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + + overflow: auto; + background-color: rgb(0,0,0); + background-color: rgba(255, 255, 255, 0.1); + border-radius: 5px; + /* Add the drop shadow */ + box-shadow: 0 0 10px 0 rgba(0,0,0,0.2), 0 5px 10px 0 rgba(0,0,0,0.19); +} + +.cancel-button { + background-color: #1530ff; + font-size: 12px; + color: white; + padding: 4px 8px; + border: none; + border-radius: 4px; + cursor: pointer; + float: right; + text-decoration: none; +} +.cancel-button:hover { + background-color: #2640fe; +} \ No newline at end of file diff --git a/app/assets/stylesheets/variables.css b/app/assets/stylesheets/variables.css index 915c14dd3..ee122e37e 100644 --- a/app/assets/stylesheets/variables.css +++ b/app/assets/stylesheets/variables.css @@ -10,4 +10,10 @@ --medium-white-color: #FDFCFD; --white-color: #FFFFFF; + --green-color: #3BD6AF; + --dark-green-color: rgb(23, 84, 4); + --orange-color: #F89356; + --blue-color: #4B719D; + --red-color: #db6363; + --dark-red-color: #7e0303; } \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12a..fe3bdfe9e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,13 @@ class ApplicationController < ActionController::Base + #declare as helper so accessable to all views + before_action :require_login + + def require_login + redirect_to new_session_path unless session.include? :user_id + end + + private + def current_user + @current_user ||= User.find(session[:user_id]) if session[:user_id] + end end diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb new file mode 100644 index 000000000..a424682e2 --- /dev/null +++ b/app/controllers/bikes_controller.rb @@ -0,0 +1,10 @@ +class BikesController < ApplicationController + def index + if params[:reverse].blank? || params[:reverse] == "0" + @bikes = Bike.all.order(identifier: :asc) + else + @bikes = Bike.all.order(identifier: :desc) + end + end + +end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb new file mode 100644 index 000000000..bd5653d1e --- /dev/null +++ b/app/controllers/categories_controller.rb @@ -0,0 +1,23 @@ +class CategoriesController < ApplicationController + def index + end + + def show + end + + def edit + end + + def create + end + + def delete + end + + def destroy + end + + def new + end + +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 000000000..95f29929c --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def index + end +end diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb new file mode 100644 index 000000000..3febffef6 --- /dev/null +++ b/app/controllers/locations_controller.rb @@ -0,0 +1,78 @@ +class LocationsController < ApplicationController + before_action :set_location, only: %i[ show edit update destroy ] + + # GET /locations or /locations.json + def index + if params[:place].present? + @locations = Location.near(params[:place], params[:distance] || 5, order: :distance) + else + @locations = Location.all + end + if !@location.nil? + puts "hello there " + params[:count] = @location.count + end + end + + # GET /locations/1 or /locations/1.json + def show + end + + # GET /locations/new + def new + @location = Location.new + end + + # GET /locations/1/edit + def edit + end + + # POST /locations or /locations.json + def create + @location = Location.new(location_params) + + respond_to do |format| + if @location.save + format.html { redirect_to location_url(@location), notice: "Location was successfully created." } + format.json { render :show, status: :created, location: @location } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @location.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /locations/1 or /locations/1.json + def update + respond_to do |format| + if @location.update(location_params) + format.html { redirect_to location_url(@location), notice: "Location was successfully updated." } + format.json { render :show, status: :ok, location: @location } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @location.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /locations/1 or /locations/1.json + def destroy + @location.destroy + + respond_to do |format| + format.html { redirect_to locations_url, notice: "Location was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_location + @location = Location.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def location_params + params.require(:location).permit(:name, :address, :latitude, :longitude) + end +end diff --git a/app/controllers/memberships_controller.rb b/app/controllers/memberships_controller.rb new file mode 100644 index 000000000..1ef59ac32 --- /dev/null +++ b/app/controllers/memberships_controller.rb @@ -0,0 +1,29 @@ +class MembershipsController < ApplicationController + def index + @membership = Membership.order(:price) + end + + def show + @membership = Membership.find(params[:id]) + end + + def new + @membership = Membership.new + end + + def edit + @membership = Membership.find(params[:id]) + end + + def update + + end + + def delete + + end + + def destroy + + end +end diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb new file mode 100644 index 000000000..dc7585d7b --- /dev/null +++ b/app/controllers/payments_controller.rb @@ -0,0 +1,39 @@ +class PaymentsController < ApplicationController + def index + if params[:reverse].blank? || params[:reverse] == "0" + @payments = Payment.all.order(id: :asc) + else + @payments = Payment.all.order(id: :desc) + end + render :index + end + + def new + @payment = Payment.new + render :new + end + + def create + @payment = Payment.new(params.require(:payment).permit(:credit_card_info, :amount)) + if @payment.save + flash[:success] = "Payment completed" + redirect_to payments_url + else + flash[:error] = "Payment failed" + redirect_to new_payment_path + end + end + + def show + end + + def update + end + + def edit + end + + def destroy + end + +end diff --git a/app/controllers/rentals_controller.rb b/app/controllers/rentals_controller.rb new file mode 100644 index 000000000..8e473b847 --- /dev/null +++ b/app/controllers/rentals_controller.rb @@ -0,0 +1,73 @@ +class RentalsController < ApplicationController + def index + if params[:reverse].blank? || params[:reverse] == "0" + @rentals = Rental.all.order(id: :asc) + else + @rentals = Rental.all.order(id: :desc) + end + render :index + end + + def new + @rental = Rental.new + render :new + end + + def create + @rental = Rental.new(params.require(:rental).permit(:rental_period, :return_by)) + @current_user = User.find(session[:user_id]) + if @current_user.has_bike.nil? + flash[:error] = "Your account has a nil rental currently...setting to false. try again" + @current_user.has_bike=false + @current_user.save + redirect_to new_rental_path + elsif @current_user.has_bike? #if has bike is true + flash[:error] = "You already have an active rental. Cannot rent multiple bikes before returning...that feature soon to be released" + redirect_to rentals_url + elsif !@current_user.has_bike #if has bike is false + @current_user.has_bike=true + @current_user.current_rental=@rental + @current_user.save + @current_user.has_bike = true + @current_user.save + puts @current_user.has_bike? + puts @current_user + puts session[:user_id] + @rental.user = @current_user + puts @rental.user + if @rental.save + flash[:success] = "Rental created" + redirect_to rentals_url + else + flash[:error] = "Rental creation failed" + redirect_to new_rental_path + end + else + flash[:error] = "Rental creation failed...your rental status is not nil, true, or false. something is majorly wrong" + end + end + + def show + @rental = Rental.find(params[:id]) + render :show + end + + def update + puts "returning rental..." + @current_user = User.find(session[:user_id]) + Rental.find(id: @current_user.current_rental.to_i).returned_at=DateTime.now + puts @current_user.current_rental.returned_at + @current_user.current_rental=nil + puts @current_user.current_rental + @current_rental.has_bike=false + puts @current_rental.has_bike + puts "rental returned...hopefully" + end + + def edit + end + + def destroy + end + +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..8257114c7 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,32 @@ +class SessionsController < ApplicationController + skip_before_action :require_login, only: [:create, :new] + + def new + + end + + def create + session_params = params.permit(:email_address, :password) + @user = User.find_by(email_address: session_params[:email_address]) + if @user && @user.authenticate(session_params[:password]) + session[:user_id] = @user.id + flash[:notice] = "You've successfully Logged In. Thank you." + redirect_to users_show_path + else + flash.now[:alert] = "Login information invalid" + render :new, status: 500 + end + end + + def destroy + logger.info("*** Logged out #{cookies[:email_address]}") + flash[:notice] = "You are now signed out" + + # do logout process here + session[:user_id] = nil + cookies[:user_name] = nil + @current_user = nil + + redirect_to login_path + end +end diff --git a/app/controllers/stations_controller.rb b/app/controllers/stations_controller.rb index 88090af16..dffb0fbf2 100644 --- a/app/controllers/stations_controller.rb +++ b/app/controllers/stations_controller.rb @@ -1,7 +1,24 @@ class StationsController < ApplicationController def index + @stations = Station.all.order(identifier: :asc) + + if params[:search_by_address] && params[:search_by_address] != "" + @stations = @stations.where("address LIKE ?", "%#{params[:search_by_address]}%") + end + puts @stations + end + + def show + @station = Station.find_by(identifier: params[:id]) + render :show + + if params[:reverse].blank? || params[:reverse] == "0" + @stations = Station.all.order(identifier: :asc) + else + @stations = Station.all.order(identifier: :desc) + end + end - end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 000000000..11852874d --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,45 @@ +class UsersController < ApplicationController + + skip_before_action :require_login, only: [:create, :new] + + #keep login + def show + @current_user = User.find(session[:user_id]) + render :show + end + + def index + @current_user = User.find(session[:user_id]) + end + + + #Sign-up + def create + # logger.info("\n\n*****attempting to create new user\n\n") + # logger.info("\n\n*****In new #{user_params}\n\n") + @user = User.new(user_params) + # logger.info("\n\n*****Set new\n\n") + if @user.save + session[:user_id] = @user.id + @user.has_bike = false + @user.save + flash[:notice] = "Welcome to your new account." + redirect_to rentals_path + else + puts "Can not create user" + flash.now[:alert] ||= "" + @user.errors.full_messages.each do |message| + flash.now[:alert] << message + ". " + end + render :new, status: 500 + end + end + + private + + def user_params + logger.info("\n\n*****attempting to create new user\n\n") + params.permit(:email_address, :password, :password_confirmation, :first_name, :last_name) + end + +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945..ed572c74d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,9 @@ module ApplicationHelper + def logged_in? + + end + + def current_user + + end end diff --git a/app/helpers/bikes_helper.rb b/app/helpers/bikes_helper.rb new file mode 100644 index 000000000..a2645e4e1 --- /dev/null +++ b/app/helpers/bikes_helper.rb @@ -0,0 +1,2 @@ +module BikesHelper +end diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb new file mode 100644 index 000000000..e06f31554 --- /dev/null +++ b/app/helpers/categories_helper.rb @@ -0,0 +1,2 @@ +module CategoriesHelper +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 000000000..23de56ac6 --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb new file mode 100644 index 000000000..bb9b712c7 --- /dev/null +++ b/app/helpers/layout_helper.rb @@ -0,0 +1,35 @@ +module LayoutHelper + def display_alerts + if flash[:alert].present? + puts "there are alerts" + content_tag(:div, class: "flash", id: "alert") do + a = flash[:alert] + puts "The alert is/are " + a + content_tag(:div, a, class: "text") + end + end + end + + def display_notices + if flash[:notice].present? + content_tag(:div, class: "flash", id: "notice") do + content_tag(:div, flash[:notice], class: "text") + end + end + end + def display_errors + if flash[:error].present? + content_tag(:div, class: "flash", id: "error") do + content_tag(:div, flash[:error], class: "text") + end + end + end + + def display_successes + if flash[:success].present? + content_tag(:div, class: "flash", id: "success") do + content_tag(:div, flash[:success], class: "text") + end + end + end + end \ No newline at end of file diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb new file mode 100644 index 000000000..46f94288a --- /dev/null +++ b/app/helpers/locations_helper.rb @@ -0,0 +1,2 @@ +module LocationsHelper +end diff --git a/app/helpers/memberships_helper.rb b/app/helpers/memberships_helper.rb new file mode 100644 index 000000000..eaf43c733 --- /dev/null +++ b/app/helpers/memberships_helper.rb @@ -0,0 +1,2 @@ +module MembershipsHelper +end diff --git a/app/helpers/payments_helper.rb b/app/helpers/payments_helper.rb new file mode 100644 index 000000000..c1b884f80 --- /dev/null +++ b/app/helpers/payments_helper.rb @@ -0,0 +1,2 @@ +module PaymentsHelper +end diff --git a/app/helpers/rentals_helper.rb b/app/helpers/rentals_helper.rb new file mode 100644 index 000000000..5a8b81508 --- /dev/null +++ b/app/helpers/rentals_helper.rb @@ -0,0 +1,2 @@ +module RentalsHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..309f8b2eb --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 000000000..2310a240d --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/javascript/application.js b/app/javascript/application.js index 0d7b49404..946ac8d66 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,3 +1,8 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers" +//map +import "mapkick/bundle" + + + diff --git a/app/javascript/controllers/flash_messages.js b/app/javascript/controllers/flash_messages.js new file mode 100644 index 000000000..db8d762e8 --- /dev/null +++ b/app/javascript/controllers/flash_messages.js @@ -0,0 +1,11 @@ +// window.onload = function() { +// setTimeout(function() { +// var noticeElement = document.getElementById('notice'); +// if (alertElement) { +// alertElement.style.display = 'none'; +// } +// if (noticeElement) { +// noticeElement.style.display = 'none'; +// } +// }, 5000); // 5000 milliseconds = 5 seconds +// }; \ No newline at end of file diff --git a/app/javascript/controllers/geolocation_controller.js b/app/javascript/controllers/geolocation_controller.js new file mode 100644 index 000000000..3f3a647e3 --- /dev/null +++ b/app/javascript/controllers/geolocation_controller.js @@ -0,0 +1,33 @@ +import { Controller } from "@hotwired/stimulus" + +const options = { + enableHighAccuracy: true, + timeout: 5000, + maximumAge: 0 +}; + +// Connects to data-controller="geolocation" +export default class extends Controller { + connect() { + } + + success(pos) { + const crd = pos.coords; + + console.log('Your current position is:'); + console.log(`Latitude : ${crd.latitude}`); + console.log(`Longitude: ${crd.longitude}`); + console.log(`More or less ${crd.accuracy} meters.`); + location.assign(`/locations?place=${crd.latitude},${crd.longitude}`) + } + + error(err) { + console.warn(`ERROR(${err.code}): ${err.message}`); + } + + search () { + navigator.geolocation.getCurrentPosition(this.success, this.error, options); + } + + +} \ No newline at end of file diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 000000000..ac2224535 --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,5 @@ +class Category < ApplicationRecord + has_many :memberships + + +end diff --git a/app/models/location.rb b/app/models/location.rb new file mode 100644 index 000000000..d86a3a5c9 --- /dev/null +++ b/app/models/location.rb @@ -0,0 +1,4 @@ +class Location < ApplicationRecord + geocoded_by :address + after_validation :geocode, if: :address_changed? +end diff --git a/app/models/membership.rb b/app/models/membership.rb new file mode 100644 index 000000000..8ae5cdf86 --- /dev/null +++ b/app/models/membership.rb @@ -0,0 +1,4 @@ +class Membership < ApplicationRecord + belongs_to :category #annual, weekly, day, monthly + +end diff --git a/app/models/payment.rb b/app/models/payment.rb new file mode 100644 index 000000000..7dacef605 --- /dev/null +++ b/app/models/payment.rb @@ -0,0 +1,4 @@ +class Payment < ApplicationRecord + validates :credit_card_info, length: { minimum: 16, maximum: 16 } + validates_presence_of :amount +end diff --git a/app/models/rental.rb b/app/models/rental.rb new file mode 100644 index 000000000..52f6c325f --- /dev/null +++ b/app/models/rental.rb @@ -0,0 +1,5 @@ +class Rental < ApplicationRecord + validates_presence_of :rental_period, + :return_by + belongs_to :user, class_name: :User, foreign_key: :id, optional:true +end diff --git a/app/models/station.rb b/app/models/station.rb index 64b9eaada..58b6f9df4 100644 --- a/app/models/station.rb +++ b/app/models/station.rb @@ -2,8 +2,12 @@ class Station < ApplicationRecord validates_presence_of :identifier, :name, :address + validates_uniqueness_of :identifier has_many :docked_bikes, class_name: :Bike, foreign_key: :current_station_id end + + + diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..15974200d --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,17 @@ +class User < ApplicationRecord + include ActiveModel::SecurePassword + # EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/ + has_secure_password + has_secure_password :recovery_password, validations: false + + validates_presence_of :first_name, + :last_name, + :email_address + + validates_uniqueness_of :email_address + + has_one :current_rental, class_name: :Rental, foreign_key: :id + has_many :rentals, class_name: :Rental, foreign_key: :id + + # validates :email_address, format: {with: EMAIL_REGEX, message: "Email invalid" } +end diff --git a/app/views/bikes/_row.html.erb b/app/views/bikes/_row.html.erb new file mode 100644 index 000000000..352b43842 --- /dev/null +++ b/app/views/bikes/_row.html.erb @@ -0,0 +1,4 @@ +
flexbox vertical stretch justify-space-between"> +
<%= bike.identifier %>
+
<%= bike.current_station.blank? ? "In Use" : "Docked (#{bike.current_station.address})" %>
+
\ No newline at end of file diff --git a/app/views/bikes/index.html.erb b/app/views/bikes/index.html.erb new file mode 100644 index 000000000..a01a3f564 --- /dev/null +++ b/app/views/bikes/index.html.erb @@ -0,0 +1,31 @@ +
+
+
+ Bikes +
+ +
+ <% if @bikes.present? %> + +
+ <% if params[:reverse].blank? || params[:reverse] == "0" %> + Sort ⬇ + + <% else %> + Sort ⬆ + + <% end %> +
+ + <%= render(partial: "bikes/row", collection: @bikes, as: :bike) %> + + <% else %> +
+ No stations found. +
+ <% end %> + +
+
+
+ diff --git a/app/views/categories/delete.html.erb b/app/views/categories/delete.html.erb new file mode 100644 index 000000000..c157520b5 --- /dev/null +++ b/app/views/categories/delete.html.erb @@ -0,0 +1,4 @@ +
+

Categories#delete

+

Find me in app/views/categories/delete.html.erb

+
diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb new file mode 100644 index 000000000..1e2205a5f --- /dev/null +++ b/app/views/categories/edit.html.erb @@ -0,0 +1,4 @@ +
+

Categories#edit

+

Find me in app/views/categories/edit.html.erb

+
diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb new file mode 100644 index 000000000..8a8143af2 --- /dev/null +++ b/app/views/categories/index.html.erb @@ -0,0 +1,4 @@ +
+

Categories#index

+

Find me in app/views/categories/index.html.erb

+
diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/categories/show.html.erb b/app/views/categories/show.html.erb new file mode 100644 index 000000000..e00d1a237 --- /dev/null +++ b/app/views/categories/show.html.erb @@ -0,0 +1,4 @@ +
+

Categories#show

+

Find me in app/views/categories/show.html.erb

+
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 000000000..67db0dc19 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,17 @@ +
+
+
+
+
+

Home

+
+
+

This is where we should put some About info...or searching for a bike on the map

+ <%= link_to "Refer to the Figma visualization (click here)", "https://www.figma.com/file/jLAscgKzd4HPAfotfuieGu/ValetBike?type=design&node-id=0%3A1&mode=design&t=op9OSiDs7IVGALMT-1" %>
+
+ + + + + + diff --git a/app/views/layouts/_error_messages.html.erb b/app/views/layouts/_error_messages.html.erb new file mode 100644 index 000000000..3cbbba477 --- /dev/null +++ b/app/views/layouts/_error_messages.html.erb @@ -0,0 +1,13 @@ +# when ryan was messing around with the flashes, they deleted this file. they restored it after playing around, but may conflict with things +<% if object && object.errors.size > 0 %> + logger.log("OKAY so obj exists and there are errors") +
+

<%= pluralize(object.errors.size, 'error') %> prohibited this record from being saved

+

There were problems with the following fields:

+ +
+<% end %> diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb new file mode 100644 index 000000000..73c61317a --- /dev/null +++ b/app/views/layouts/_navbar.html.erb @@ -0,0 +1,67 @@ + + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7ace1393e..b5c92e726 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,20 +3,43 @@ + + + + + + + + + + <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> + - ValetBike + -
-
+ + +
+ <%= render partial: 'layouts/navbar' %> +
+ <%= display_alerts %> + <%= display_notices %> + + <%= display_errors %> + <%= display_successes %> + <%= yield %>
+ + + diff --git a/app/views/locations/_form.html.erb b/app/views/locations/_form.html.erb new file mode 100644 index 000000000..1940cc041 --- /dev/null +++ b/app/views/locations/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: location, class: "contents") do |form| %> + <% if location.errors.any? %> +
+

<%= pluralize(location.errors.count, "error") %> prohibited this location from being saved:

+ +
    + <% location.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :name %> + <%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> +
+ +
+ <%= form.label :address %> + <%= form.text_field :address, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> +
+ +
+ <%= form.label :latitude %> + <%= form.text_field :latitude, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> +
+ +
+ <%= form.label :longitude %> + <%= form.text_field :longitude, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> +
+ +
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> +
+<% end %> diff --git a/app/views/locations/_location.html.erb b/app/views/locations/_location.html.erb new file mode 100644 index 000000000..b0d8be367 --- /dev/null +++ b/app/views/locations/_location.html.erb @@ -0,0 +1,29 @@ +
+ + <%= image_tag "https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/pin-s+555555(#{location.longitude},#{location.latitude})/#{location.longitude},#{location.latitude},13,0/200x200?access_token=pk.eyJ1IjoicGNhbGxlMjAwMyIsImEiOiJjbHA1bXNzeGMwN2t6MnFxazU3cGU1eWgyIn0.S4cnOrUfM5Uh4mbzSCWkJA" %> +

+ Name: + <%= location.name %> +

+ +

+ Address: + <%= location.address %> +

+ +

+ Latitude: + <%= location.latitude %> +

+ +

+ Longitude: + <%= location.longitude %> +

+ + <% if action_name != "show" %> + <%= link_to "Show this location", location, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to 'Edit this location', edit_location_path(location), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> +
+ <% end %> +
diff --git a/app/views/locations/_location.json.jbuilder b/app/views/locations/_location.json.jbuilder new file mode 100644 index 000000000..a15c32a0a --- /dev/null +++ b/app/views/locations/_location.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! location, :id, :name, :address, :latitude, :longitude, :created_at, :updated_at +json.url location_url(location, format: :json) diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb new file mode 100644 index 000000000..3b050c7c1 --- /dev/null +++ b/app/views/locations/edit.html.erb @@ -0,0 +1,8 @@ +
+

Editing location

+ + <%= render "form", location: @location %> + + <%= link_to "Show this location", @location, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Back to locations", locations_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +
diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb new file mode 100644 index 000000000..f8308a6ba --- /dev/null +++ b/app/views/locations/index.html.erb @@ -0,0 +1,28 @@ +
+ <% if notice.present? %> +

<%= notice %>

+ <% end %> + +
+

Locationsssss

+ +
+ + + <% js_map [{latitude: 42.3363, longitude: -72.6233}] %> + + <%= form_with url: locations_path, method: :get do |form| %> + <%= form.text_field :place, value: params[:place]%> + <%= form.select :distance, [1, 5, 10]%> + <%= form.submit %> + <% end %> + + <% if params[:count].present? %> + <%= params[:count] %> + <% end %> + + +
+ <%= render @locations %> +
+
diff --git a/app/views/locations/index.json.jbuilder b/app/views/locations/index.json.jbuilder new file mode 100644 index 000000000..4644857c3 --- /dev/null +++ b/app/views/locations/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @locations, partial: "locations/location", as: :location diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb new file mode 100644 index 000000000..f182294d6 --- /dev/null +++ b/app/views/locations/new.html.erb @@ -0,0 +1,7 @@ +
+

New location

+ + <%= render "form", location: @location %> + + <%= link_to 'Back to locations', locations_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +
diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb new file mode 100644 index 000000000..cb7f8d4c1 --- /dev/null +++ b/app/views/locations/show.html.erb @@ -0,0 +1,39 @@ +
+
+ <% if notice.present? %> +

<%= notice %>

+ <% end %> + + <%= render @location %> + + <%= link_to 'Edit this location', edit_location_path(@location), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to 'Back to locations', locations_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + +
+ + +
+ + + +
+
+ Staions nearby <%= @location.name %>: +
    + <% @location.nearbys(0.5).each do |location| %> +
  • + Station: <%= location.name %> + Distance: <%= location.distance_to(@location) %> +
  • +
    + <% end %> +
+
+ + + + + + + + diff --git a/app/views/locations/show.json.jbuilder b/app/views/locations/show.json.jbuilder new file mode 100644 index 000000000..463e4b23a --- /dev/null +++ b/app/views/locations/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "locations/location", location: @location diff --git a/app/views/memberships/delete.html.erb b/app/views/memberships/delete.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/memberships/edit.html.erb b/app/views/memberships/edit.html.erb new file mode 100644 index 000000000..1221fd4c7 --- /dev/null +++ b/app/views/memberships/edit.html.erb @@ -0,0 +1,4 @@ +
+

Memberships#edit

+

Find me in app/views/memberships/edit.html.erb

+
diff --git a/app/views/memberships/index.html.erb b/app/views/memberships/index.html.erb new file mode 100644 index 000000000..9208c3424 --- /dev/null +++ b/app/views/memberships/index.html.erb @@ -0,0 +1,4 @@ +
+

Memberships#index

+

Find me in app/views/memberships/index.html.erb

+
diff --git a/app/views/memberships/new.html.erb b/app/views/memberships/new.html.erb new file mode 100644 index 000000000..56760b28e --- /dev/null +++ b/app/views/memberships/new.html.erb @@ -0,0 +1,6 @@ +
+

Memberships#new

+

Find me in app/views/memberships/new.html.erb

+
+ + diff --git a/app/views/memberships/show.html.erb b/app/views/memberships/show.html.erb new file mode 100644 index 000000000..3dfd45236 --- /dev/null +++ b/app/views/memberships/show.html.erb @@ -0,0 +1,4 @@ +
+

Memberships#show

+

Find me in app/views/memberships/show.html.erb

+
diff --git a/app/views/payments/_row.html.erb b/app/views/payments/_row.html.erb new file mode 100644 index 000000000..9a0d7a351 --- /dev/null +++ b/app/views/payments/_row.html.erb @@ -0,0 +1,7 @@ +
flexbox vertical stretch"> + <%= payment.id %> + Credit card info: <%= payment.credit_card_info %> +
+

Amount: <%= number_to_currency(payment.amount) %> + +

\ No newline at end of file diff --git a/app/views/payments/create.html.erb b/app/views/payments/create.html.erb new file mode 100644 index 000000000..64043289d --- /dev/null +++ b/app/views/payments/create.html.erb @@ -0,0 +1,4 @@ +
+

Payments#create

+

Find me in app/views/payments/create.html.erb

+
diff --git a/app/views/payments/destroy.html.erb b/app/views/payments/destroy.html.erb new file mode 100644 index 000000000..5b8401406 --- /dev/null +++ b/app/views/payments/destroy.html.erb @@ -0,0 +1,4 @@ +
+

Payments#destroy

+

Find me in app/views/payments/destroy.html.erb

+
diff --git a/app/views/payments/edit.html.erb b/app/views/payments/edit.html.erb new file mode 100644 index 000000000..aeef7dd69 --- /dev/null +++ b/app/views/payments/edit.html.erb @@ -0,0 +1,4 @@ +
+

Payments#edit

+

Find me in app/views/payments/edit.html.erb

+
diff --git a/app/views/payments/index.html.erb b/app/views/payments/index.html.erb new file mode 100644 index 000000000..be10e3106 --- /dev/null +++ b/app/views/payments/index.html.erb @@ -0,0 +1,37 @@ + + Payments + + + +
+
+

Payments

+

+ <%= link_to "New Payment", new_payment_path, class: 'btn button btn-primary' %> +

+
+ + <% if @payments.present? %> + +
+ <% if params[:reverse].blank? || params[:reverse] == "0" %> + Sort ⬇ + + <% else %> + Sort ⬆ + + <% end %> +
+ + <%= render(partial: "payments/row", collection: @payments, as: :payment) %> + + <% else %> +

+ No payments found. +

+ <% end %> + +
+
+
+ diff --git a/app/views/payments/new.html.erb b/app/views/payments/new.html.erb new file mode 100644 index 000000000..b7dc65350 --- /dev/null +++ b/app/views/payments/new.html.erb @@ -0,0 +1,13 @@ +

New Payment

+ +<%= form_with model: @payment, url: payments_path, method: :post, local:true do |f| %> + + <%= f.label (:credit_card_info) %> + <%= f.text_field (:credit_card_info), placeholder: "0000000000000000" %> + + <%= f.label (:amount) %> + <%= f.text_field (:amount) %> + + <%= f.submit class: "btn button btn-primary"%> + +<% end %> \ No newline at end of file diff --git a/app/views/payments/show.html.erb b/app/views/payments/show.html.erb new file mode 100644 index 000000000..ad0b41045 --- /dev/null +++ b/app/views/payments/show.html.erb @@ -0,0 +1,4 @@ +
+

Payments#show

+

Find me in app/views/payments/show.html.erb

+
diff --git a/app/views/payments/update.html.erb b/app/views/payments/update.html.erb new file mode 100644 index 000000000..059fec6ed --- /dev/null +++ b/app/views/payments/update.html.erb @@ -0,0 +1,4 @@ +
+

Payments#update

+

Find me in app/views/payments/update.html.erb

+
diff --git a/app/views/rentals/_row.html.erb b/app/views/rentals/_row.html.erb new file mode 100644 index 000000000..e0231de7b --- /dev/null +++ b/app/views/rentals/_row.html.erb @@ -0,0 +1,17 @@ +
flexbox vertical stretch"> + <%= rental.id %> + Rental period: <%= rental.rental_period %> +
+

Return by: <%= rental.return_by %> +

User: <%=rental.user.id%> + <% puts rental.id %> + <% puts User.find(session[:user_id]).current_rental %> + <% if rental.id==User.find(session[:user_id]).current_rental %> + <% puts "current_user.current_rental.id is equal to the rental.id" %> +

+

+ <%= link_to "Return Rental", return_path, class: 'btn btn-primary' %> +

+
+ <%end%> +
\ No newline at end of file diff --git a/app/views/rentals/create.html.erb b/app/views/rentals/create.html.erb new file mode 100644 index 000000000..bcac74f77 --- /dev/null +++ b/app/views/rentals/create.html.erb @@ -0,0 +1,4 @@ +
+

Rentals#create

+

Find me in app/views/rentals/create.html.erb

+
diff --git a/app/views/rentals/destroy.html.erb b/app/views/rentals/destroy.html.erb new file mode 100644 index 000000000..044026fe7 --- /dev/null +++ b/app/views/rentals/destroy.html.erb @@ -0,0 +1,4 @@ +
+

Rentals#destroy

+

Find me in app/views/rentals/destroy.html.erb

+
diff --git a/app/views/rentals/edit.html.erb b/app/views/rentals/edit.html.erb new file mode 100644 index 000000000..e4b490a4a --- /dev/null +++ b/app/views/rentals/edit.html.erb @@ -0,0 +1,4 @@ +
+

Rentals#edit

+

Find me in app/views/rentals/edit.html.erb

+
diff --git a/app/views/rentals/index.html.erb b/app/views/rentals/index.html.erb new file mode 100644 index 000000000..17d422f38 --- /dev/null +++ b/app/views/rentals/index.html.erb @@ -0,0 +1,35 @@ +
+
+
+ Rentals +
+
+

+ <%= link_to "Create New Rental", new_rental_path, class: 'btn button btn-primary' %> +

+
+
+
+ <% if @rentals.present? %> + +
+ <% if params[:reverse].blank? || params[:reverse] == "0" %> + Sort ⬇ + + <% else %> + Sort ⬆ + + <% end %> +
+ + <%= render(partial: "rentals/row", collection: @rentals, as: :rental) %> + + <% else %> +
+ No rentals found. +
+ <% end %> + +
+
+
\ No newline at end of file diff --git a/app/views/rentals/new.html.erb b/app/views/rentals/new.html.erb new file mode 100644 index 000000000..cfa22282c --- /dev/null +++ b/app/views/rentals/new.html.erb @@ -0,0 +1,36 @@ +

Create New Rental

+ + +
+ <%= form_with model: @rental, url: rentals_path, method: :post, local:true do |f| %> +
+
+ + + + +<%= f.label (:rental_period) %> +
+ + + + +
+ + + + + + + <%= f.label (:return_by) %> + <%= f.date_field (:return_by) %> + +
+ +
+
+
+ <%= f.submit "Submit", class: "btn button btn-primary"%> + + <% end %> +
\ No newline at end of file diff --git a/app/views/rentals/show.html.erb b/app/views/rentals/show.html.erb new file mode 100644 index 000000000..857494e93 --- /dev/null +++ b/app/views/rentals/show.html.erb @@ -0,0 +1,4 @@ +
+

Rentals#show

+

Find me in app/views/rentals/show.html.erb

+
diff --git a/app/views/rentals/update.html.erb b/app/views/rentals/update.html.erb new file mode 100644 index 000000000..93836dc4d --- /dev/null +++ b/app/views/rentals/update.html.erb @@ -0,0 +1,12 @@ +
+
+
+ Return rental +
+
+

+ <%= link_to "Return Rental", return_path, class: 'btn btn-primary' %> +

+
+
+
\ No newline at end of file diff --git a/app/views/sessions/_flash.html.erb b/app/views/sessions/_flash.html.erb new file mode 100644 index 000000000..db68cc6a5 --- /dev/null +++ b/app/views/sessions/_flash.html.erb @@ -0,0 +1,5 @@ +<% if flash[:notice].present? %> +
+ <%= flash[:notice] %> +
+<% end %> \ No newline at end of file diff --git a/app/views/sessions/menu.html.erb b/app/views/sessions/menu.html.erb new file mode 100644 index 000000000..54e09678c --- /dev/null +++ b/app/views/sessions/menu.html.erb @@ -0,0 +1,2 @@ +<%= content_tag :h1, current_user.welcome %> +<%= link_to "Sign out", session_path, method:"delete" %> \ No newline at end of file diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 000000000..2dfc084fb --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,32 @@ +
+
+
+ Login +
+
+ <%= form_tag(sessions_path) do %> + +
+ + + + + + + + +
+
<%= label_tag(:email_address) %><%= text_field_tag(:email_address, params[:email_address]) %>
<%= label_tag(:password) %><%= password_field_tag(:password) %>
+
+
+ <%= submit_tag "Login", class: 'btn button btn-primary', style: 'color: black;' %> +
+ <% end %> +
+
+
+

Don't have an account?

+

<%= link_to "Create Account", sign_up_path, class: 'btn button btn-primary' %>

+
+
+
\ No newline at end of file diff --git a/app/views/stations/_row.html.erb b/app/views/stations/_row.html.erb index 68a74d983..128a37dde 100644 --- a/app/views/stations/_row.html.erb +++ b/app/views/stations/_row.html.erb @@ -1,3 +1,9 @@ -
flexbox vertical stretch"> - <%= station.identifier %>: <%= station.name %> (<%= station.address %>) -
\ No newline at end of file + +
+
+ <%= station.identifier %>: <%= station.name %> (<%= station.address %>) + <%= station.docked_bikes.count %> bikes + <%= link_to "Select Station", station_path(id: station.identifier), class: "fill-block"%> +
+
+ diff --git a/app/views/stations/index.html.erb b/app/views/stations/index.html.erb index d211dda42..c6422f2d5 100644 --- a/app/views/stations/index.html.erb +++ b/app/views/stations/index.html.erb @@ -1,16 +1,40 @@ -
+
-
- Welcome to ValetBike! -
+
+ Stations +
+
<% if @stations.present? %> + +
+ <% if params[:reverse].blank? || params[:reverse] == "0" %> + Sort ⬇ + + <% else %> + Sort ⬆ + + <% end %> + + <%= form_tag "/stations", method: "GET" do %> + + <%= text_field_tag :search_by_address, params[:search_by_address], class: "search-control", placeholder: "Search Address" %> + <% end %> + +
+ +
+ +
+ <%= render(partial: "stations/row", collection: @stations, as: :station) %> + <% else %> -
- No stations found. -
+
+ No stations found. +
<% end %> +
-
+
\ No newline at end of file diff --git a/app/views/stations/show.html.erb b/app/views/stations/show.html.erb new file mode 100644 index 000000000..992b5d811 --- /dev/null +++ b/app/views/stations/show.html.erb @@ -0,0 +1,3 @@ + + +

Station Selected: <%= @station.name %>

\ No newline at end of file diff --git a/app/views/users/delete.html.erb b/app/views/users/delete.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb new file mode 100644 index 000000000..6873e47ac --- /dev/null +++ b/app/views/users/edit.html.erb @@ -0,0 +1,4 @@ +
+

Users#edit

+

Find me in app/views/users/edit.html.erb

+
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 000000000..091dc8f99 --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,4 @@ +
+

Users#index

+

Find me in app/views/users/index.html.erb

+
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 000000000..818df8259 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,40 @@ +
+

Create an Account

+
+ + <%= form_with url: '/sign_up', method: :post do |form| %> + + + + + + + + + + + + + + + + + + + + + + +
<%= label_tag(:first_name) %><%= text_field_tag(:first_name, params[:first_name], required: true) %>
<%= label_tag(:last_name) %><%= text_field_tag(:last_name, params[:last_name], required: true) %>
<%= label_tag(:email_address) %><%= text_field_tag(:email_address, params[:email_address], type: 'email', required: true) %>
<%= label_tag(:password) %><%= password_field_tag(:password, nil, required: true, minlength: 8) %>
<%= label_tag(:password_confirmation) %><%= password_field_tag(:password_confirmation, nil, required: true, minlength: 8) %>
+ +
+ <%= submit_tag "Sign Up", class: 'btn btn-primary', style: 'color: black;' %> +
+ +
+

Already have an account?

+

<%= link_to "Login", login_path, class: 'btn btn-primary' %>

+ + <% end %> + +
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 000000000..c6510b6cf --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,5 @@ +
+

Welcome <%= @current_user.first_name %>

+

Find me in app/views/users/show.html.erb

+
+ diff --git a/config/importmap.rb b/config/importmap.rb index 8dce42d40..65ad021a2 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -4,4 +4,5 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true +pin "mapkick/bundle", to: "mapkick.bundle.js" pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/config/initializers/mapbox.rb b/config/initializers/mapbox.rb new file mode 100644 index 000000000..e059b74ac --- /dev/null +++ b/config/initializers/mapbox.rb @@ -0,0 +1,2 @@ +ENV["MAPBOX_ACCESS_TOKEN"] = "pk.eyJ1IjoicGNhbGxlMjAwMyIsImEiOiJjbHA1bXNzeGMwN2t6MnFxazU3cGU1eWgyIn0.S4cnOrUfM5Uh4mbzSCWkJA" +ENV["MAPS_API_KEY"] = "AIzaSyBjC2E5rdBM0e_deSdd2jnbrw7-DNTeDk4" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f1eb0a0d8..91c714e8b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,52 @@ Rails.application.routes.draw do - root to: "stations#index" -end \ No newline at end of file + resources :locations + + root 'home#index' #homepage + get 'home', to: 'home#index' + post 'home', to: 'home#index' + + get 'users/show', to: 'users#show' + + #Sessions routes + get '/login', to: 'sessions#new' + post '/login', to: 'sessions#create' + get '/logout', to: 'sessions#destroy' + delete 'logout', to: 'sessions#destroy' + + get '/sign_up', to: 'users#new' + post '/sign_up', to: 'users#create' + resources :users + # resources :users, only: [:new, :create, :index, :show] + resources :memberships, only: [:new, :create, :index, :show] + resources :sessions, only: [:new, :create, :destroy] + + # end + + resources :stations, only: [:index, :show] + resources :bikes, only: [:index] + + resources :payments, only: [:new] + get 'payments', to: 'payments#index', as: 'payments' + post 'payments', to: 'payments#create' + + # below not set up in the controller...but will need to just add the simple thing to the resources list above + # get 'payments/:id' , to: 'payments#show', as: 'payment' + # get 'payments/update' + # get 'payments/edit' + # get 'payments/destroy' + + + #Rentals routes + resources :rentals, only: [:index, :new, :create, :update] + post 'rentals', to: 'rentals#create' + get 'rentals/return', to: 'rentals#update', as: 'return' + + # below not set up in the controller...but will need to just add the simple thing to the resources list above + # get 'rentals/:id' , to: 'rentals#show', as: 'rental' + # get 'rentals/edit' + # get 'rentals/destroy' + +end + + + diff --git a/db/migrate/20220831090424_create_stations.rb b/db/migrate/20220831090424_create_stations.rb index 765811e88..a9f90d07b 100644 --- a/db/migrate/20220831090424_create_stations.rb +++ b/db/migrate/20220831090424_create_stations.rb @@ -5,7 +5,10 @@ def change t.string :name t.string :address + t.timestamps end end end + +#identifier, name, has_kiosk, needs_maintenance, dock_count, docked_bike_count, address \ No newline at end of file diff --git a/db/migrate/20220831090719_create_bikes.rb b/db/migrate/20220831090719_create_bikes.rb index 8e0f2dcd3..ed13793e6 100644 --- a/db/migrate/20220831090719_create_bikes.rb +++ b/db/migrate/20220831090719_create_bikes.rb @@ -3,7 +3,6 @@ def change create_table :bikes do |t| t.integer :identifier t.integer :current_station_id - t.timestamps end end diff --git a/db/migrate/20231103203007_create_users.rb b/db/migrate/20231103203007_create_users.rb new file mode 100644 index 000000000..478b95e5a --- /dev/null +++ b/db/migrate/20231103203007_create_users.rb @@ -0,0 +1,16 @@ +class CreateUsers < ActiveRecord::Migration[7.0] + def change + create_table :users do |t| + t.string :first_name + t.string :last_name + t.string :email_address, null: false + t.boolean :has_bike + t.string :password_digest + + t.timestamps + end + end +end + +# change combined up and down method +# allows you to drop users and add users \ No newline at end of file diff --git a/db/migrate/20231103203528_create_memberships.rb b/db/migrate/20231103203528_create_memberships.rb new file mode 100644 index 000000000..20e453221 --- /dev/null +++ b/db/migrate/20231103203528_create_memberships.rb @@ -0,0 +1,11 @@ +class CreateMemberships < ActiveRecord::Migration[7.0] + def change + create_table :memberships do |t| + t.string :type + t.float :cost + t.date :expiration_date + + t.timestamps + end + end +end diff --git a/db/migrate/20231105185936_create_rentals.rb b/db/migrate/20231105185936_create_rentals.rb new file mode 100644 index 000000000..5af0a7568 --- /dev/null +++ b/db/migrate/20231105185936_create_rentals.rb @@ -0,0 +1,13 @@ +class CreateRentals < ActiveRecord::Migration[7.0] + def change + create_table :rentals do |t| + t.integer :identifier + t.datetime :rented_at + t.datetime :returned_at + t.integer :rental_period + t.datetime :return_by + + t.timestamps + end + end +end diff --git a/db/migrate/20231105190001_create_payments.rb b/db/migrate/20231105190001_create_payments.rb new file mode 100644 index 000000000..16e57249f --- /dev/null +++ b/db/migrate/20231105190001_create_payments.rb @@ -0,0 +1,9 @@ +class CreatePayments < ActiveRecord::Migration[7.0] + def change + create_table :payments do |t| + t.string :credit_card_info + + t.timestamps + end + end +end diff --git a/db/migrate/20231105194701_create_categories.rb b/db/migrate/20231105194701_create_categories.rb new file mode 100644 index 000000000..aaa868dda --- /dev/null +++ b/db/migrate/20231105194701_create_categories.rb @@ -0,0 +1,9 @@ +class CreateCategories < ActiveRecord::Migration[7.0] + def change + create_table :categories do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20231105194806_add_category_id_to_memeberships.rb b/db/migrate/20231105194806_add_category_id_to_memeberships.rb new file mode 100644 index 000000000..ce4407556 --- /dev/null +++ b/db/migrate/20231105194806_add_category_id_to_memeberships.rb @@ -0,0 +1,5 @@ +class AddCategoryIdToMemeberships < ActiveRecord::Migration[7.0] + def change + add_column(:memberships, :category_id, :integer, index: true) #annual, weekly, monthy, day + end +end diff --git a/db/migrate/20231107032240_add_password_digest_to_users.rb b/db/migrate/20231107032240_add_password_digest_to_users.rb new file mode 100644 index 000000000..b6b2d5f0d --- /dev/null +++ b/db/migrate/20231107032240_add_password_digest_to_users.rb @@ -0,0 +1,5 @@ +class AddPasswordDigestToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :password_digest, :string + end +end diff --git a/db/migrate/20231107165624_add_amount_to_payments.rb b/db/migrate/20231107165624_add_amount_to_payments.rb new file mode 100644 index 000000000..e709bf247 --- /dev/null +++ b/db/migrate/20231107165624_add_amount_to_payments.rb @@ -0,0 +1,5 @@ +class AddAmountToPayments < ActiveRecord::Migration[7.0] + def change + add_column :payments, :amount, :float + end +end diff --git a/db/migrate/20231107184506_remove_password_digest_from_users.rb b/db/migrate/20231107184506_remove_password_digest_from_users.rb new file mode 100644 index 000000000..633fc2269 --- /dev/null +++ b/db/migrate/20231107184506_remove_password_digest_from_users.rb @@ -0,0 +1,5 @@ +class RemovePasswordDigestFromUsers < ActiveRecord::Migration[7.0] + def change + remove_column :users, :password_digest, :string + end +end diff --git a/db/migrate/20231110223754_remove_identifier_from_rentals.rb b/db/migrate/20231110223754_remove_identifier_from_rentals.rb new file mode 100644 index 000000000..3c3513985 --- /dev/null +++ b/db/migrate/20231110223754_remove_identifier_from_rentals.rb @@ -0,0 +1,5 @@ +class RemoveIdentifierFromRentals < ActiveRecord::Migration[7.0] + def change + remove_column :rentals, :identifier, :integer + end +end diff --git a/db/migrate/20231111041347_remove_attributes_from_stations.rb b/db/migrate/20231111041347_remove_attributes_from_stations.rb new file mode 100644 index 000000000..511050813 --- /dev/null +++ b/db/migrate/20231111041347_remove_attributes_from_stations.rb @@ -0,0 +1,5 @@ +class RemoveAttributesFromStations < ActiveRecord::Migration[7.0] + def change + + end +end diff --git a/db/migrate/20231115165520_add_user_to_rentals.rb b/db/migrate/20231115165520_add_user_to_rentals.rb new file mode 100644 index 000000000..3cc3b5c8e --- /dev/null +++ b/db/migrate/20231115165520_add_user_to_rentals.rb @@ -0,0 +1,5 @@ +class AddUserToRentals < ActiveRecord::Migration[7.0] + def change + add_column :rentals, :user, :integer + end +end diff --git a/db/migrate/20231118192327_create_locations.rb b/db/migrate/20231118192327_create_locations.rb new file mode 100644 index 000000000..06f40bd25 --- /dev/null +++ b/db/migrate/20231118192327_create_locations.rb @@ -0,0 +1,14 @@ +class CreateLocations < ActiveRecord::Migration[7.0] + def change + create_table :locations do |t| + t.string :name + t.string :address + t.float :latitude + t.float :longitude + + t.timestamps + end + add_index :locations, :latitude + add_index :locations, :longitude + end +end diff --git a/db/migrate/20231119175250_add_current_rental_to_users.rb b/db/migrate/20231119175250_add_current_rental_to_users.rb new file mode 100644 index 000000000..e30310629 --- /dev/null +++ b/db/migrate/20231119175250_add_current_rental_to_users.rb @@ -0,0 +1,5 @@ +class AddCurrentRentalToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :current_rental, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index b98268f0e..81ff0fc38 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_08_31_090719) do +ActiveRecord::Schema[7.0].define(version: 2023_11_19_175250) do create_table "bikes", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "identifier" t.integer "current_station_id" @@ -18,6 +18,49 @@ t.datetime "updated_at", null: false end + create_table "categories", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "locations", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "name" + t.string "address" + t.float "latitude" + t.float "longitude" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["latitude"], name: "index_locations_on_latitude" + t.index ["longitude"], name: "index_locations_on_longitude" + end + + create_table "memberships", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "type" + t.float "cost" + t.date "expiration_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "category_id" + end + + create_table "payments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "credit_card_info" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.float "amount" + end + + create_table "rentals", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "rented_at" + t.datetime "returned_at" + t.integer "rental_period" + t.datetime "return_by" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "user" + end + create_table "stations", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "identifier" t.string "name" @@ -26,4 +69,16 @@ t.datetime "updated_at", null: false end + create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "first_name" + t.string "last_name" + t.string "email_address" + t.boolean "has_bike" + t.string "password" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "password_digest" + t.integer "current_rental" + end + end diff --git a/lib/tasks/import_bikes.rake b/lib/tasks/import_bikes.rake new file mode 100644 index 000000000..a59109ae9 --- /dev/null +++ b/lib/tasks/import_bikes.rake @@ -0,0 +1,36 @@ +# This task imports bike data from a CSV file +# Use after importing station data +# Usage: rake db:import_bikes["notes/bike-data.csv"] + +namespace :db do + + desc "Import bike data from csv file" + + task :import_bikes, [:filename] => :environment do |task, args| + require 'csv' + + puts "Importing bike data..." + + CSV.parse(File.read(args[:filename]), headers: true).each do |row| + puts "Importing: Bike #{row.to_hash["identifier"]}\n" + import_bike(row.to_hash) + end + end + + def import_bike(item) + bike = Bike.new(identifier: item["identifier"]) + bike.current_station = Station.find_by(identifier: item ["current_station_identifier"]) + + if bike.save + puts "Success import of Bike #{item["identifier"]}\n" + else + puts "Failed to import: Bike #{item["identifier"]}\n" + end + + end + +end + + + + diff --git a/lib/tasks/import_stations.rake b/lib/tasks/import_stations.rake new file mode 100644 index 000000000..bc18c8e31 --- /dev/null +++ b/lib/tasks/import_stations.rake @@ -0,0 +1,49 @@ +# This task imports bike data from a CSV file +# Use before importing bike data +# Usage: + +namespace :db do + + desc "Import station data from csv file" + + task :import_stations, [:filename] => :environment do |task, args| + require 'csv' + + puts "Importing station data..." + + CSV.parse(File.read(args[:filename]), headers: true).each do |row| + puts "Importing: #{row.to_hash["name"]}\n" + import_station(row.to_hash) + end + end + + def import_station(item) + station = Station.new({ + identifier: item["identifier"], + name: item["name"], + address: item["address"]}) + + location = Location.new({ + name: station["name"], + address: station["address"] + }) + + location.geocode + + if station.save + puts "Successfully imported: #{item["name"]}\n" + + if location.save + puts "Sussessfuly saved geocordinates for #{item["name"]}" + else + puts "Failed to save geocordinates for #{item["name"]}" + end + + else + puts "Failed to import: #{item["name"]}\n" + end + + end + +end + diff --git a/notes/station-data.csv b/notes/station-data.csv index 6f147a8a8..a71dd7439 100644 --- a/notes/station-data.csv +++ b/notes/station-data.csv @@ -1,15 +1,15 @@ identifier,name,has_kiosk,needs_maintenance,dock_count,docked_bike_count,address -21,Florence Bank Station,0,0,7,4,19 Meadow Street Florence MA @ Lilly Library +21,Florence Bank Station,0,0,7,4,19 Meadow St Northampton MA 01062 24,Florence Center,0,0,10,2,31 Main Street Florence MA 30,Jackson Street,0,0,16,8,7A-7D Jackson Street Northampton MA 25,Cooley Dickinson Health Care,0,1,14,6,51 Locust Street Northampton MA -29,State St/Mass Central Rail Trail,0,0,10,4,State Street/Mass Central Rail Trail +29,State St/Mass Central Rail Trail,0,0,10,4,1740 Hardwick Rd New Braintree MA 01531 33,Northampton High School,0,0,15,8,380 Elm Street Northampton MA -20,Village Hill/State Hospital,0,0,14,6,Village Hill/State Hospital -26,John M Greene Hall/Smith College,0,0,16,5,1 Chapin Way Northampton MA @ John M. Greene Hall +20,Village Hill/State Hospital,0,0,14,6,1 Prince St Northampton MA 01060 +26,John M Greene Hall/Smith College,0,0,16,5,60 Elm St Northampton MA 01060 23,Forbes Library,0,0,13,6,20 West Street Northampton MA -27,Pulaski Park/Downtown,1,0,11,3,274 Main Street Northampton MA at Pulaski Park +27,Pulaski Park/Downtown,1,0,11,3,240 Main St Northampton MA 01060 31,Main Street/Court House,0,1,10,3,99 Main Street Northampton MA 28,Northampton Train Station,1,0,13,5,Northampton Train Station 32,Main Street/Bridge Street,0,0,15,8,1 Bridge Street Northampton MA -22,YMCA/Childs Park,0,0,17,8,YMCA/Childs Park \ No newline at end of file +22,YMCA/Childs Park,0,0,17,8,71 N Elm St Northampton MA 01060 \ No newline at end of file diff --git a/test/controllers/bikes_controller_test.rb b/test/controllers/bikes_controller_test.rb new file mode 100644 index 000000000..d156f629c --- /dev/null +++ b/test/controllers/bikes_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class BikesControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb new file mode 100644 index 000000000..bd3492bf8 --- /dev/null +++ b/test/controllers/categories_controller_test.rb @@ -0,0 +1,23 @@ +require "test_helper" + +class CategoriesControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get categories_index_url + assert_response :success + end + + test "should get show" do + get categories_show_url + assert_response :success + end + + test "should get edit" do + get categories_edit_url + assert_response :success + end + + test "should get delete" do + get categories_delete_url + assert_response :success + end +end diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb new file mode 100644 index 000000000..f6f3785e8 --- /dev/null +++ b/test/controllers/home_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class HomeControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get home_index_url + assert_response :success + end +end diff --git a/test/controllers/locations_controller_test.rb b/test/controllers/locations_controller_test.rb new file mode 100644 index 000000000..98a2973af --- /dev/null +++ b/test/controllers/locations_controller_test.rb @@ -0,0 +1,48 @@ +require "test_helper" + +class LocationsControllerTest < ActionDispatch::IntegrationTest + setup do + @location = locations(:one) + end + + test "should get index" do + get locations_url + assert_response :success + end + + test "should get new" do + get new_location_url + assert_response :success + end + + test "should create location" do + assert_difference("Location.count") do + post locations_url, params: { location: { address: @location.address, latitude: @location.latitude, longitude: @location.longitude, name: @location.name } } + end + + assert_redirected_to location_url(Location.last) + end + + test "should show location" do + get location_url(@location) + assert_response :success + end + + test "should get edit" do + get edit_location_url(@location) + assert_response :success + end + + test "should update location" do + patch location_url(@location), params: { location: { address: @location.address, latitude: @location.latitude, longitude: @location.longitude, name: @location.name } } + assert_redirected_to location_url(@location) + end + + test "should destroy location" do + assert_difference("Location.count", -1) do + delete location_url(@location) + end + + assert_redirected_to locations_url + end +end diff --git a/test/controllers/memberships_controller_test.rb b/test/controllers/memberships_controller_test.rb new file mode 100644 index 000000000..16008437b --- /dev/null +++ b/test/controllers/memberships_controller_test.rb @@ -0,0 +1,23 @@ +require "test_helper" + +class MembershipsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get memberships_index_url + assert_response :success + end + + test "should get show" do + get memberships_show_url + assert_response :success + end + + test "should get new" do + get memberships_new_url + assert_response :success + end + + test "should get edit" do + get memberships_edit_url + assert_response :success + end +end diff --git a/test/controllers/payments_controller_test.rb b/test/controllers/payments_controller_test.rb new file mode 100644 index 000000000..288d0ef1c --- /dev/null +++ b/test/controllers/payments_controller_test.rb @@ -0,0 +1,38 @@ +require "test_helper" + +class PaymentsControllerTest < ActionDispatch::IntegrationTest + test "should get new" do + get payments_new_url + assert_response :success + end + + test "should get create" do + get payments_create_url + assert_response :success + end + + test "should get update" do + get payments_update_url + assert_response :success + end + + test "should get edit" do + get payments_edit_url + assert_response :success + end + + test "should get destroy" do + get payments_destroy_url + assert_response :success + end + + test "should get index" do + get payments_index_url + assert_response :success + end + + test "should get show" do + get payments_show_url + assert_response :success + end +end diff --git a/test/controllers/rentals_controller_test.rb b/test/controllers/rentals_controller_test.rb new file mode 100644 index 000000000..80fe9bd67 --- /dev/null +++ b/test/controllers/rentals_controller_test.rb @@ -0,0 +1,38 @@ +require "test_helper" + +class RentalsControllerTest < ActionDispatch::IntegrationTest + test "should get new" do + get rentals_new_url + assert_response :success + end + + test "should get create" do + get rentals_create_url + assert_response :success + end + + test "should get update" do + get rentals_update_url + assert_response :success + end + + test "should get edit" do + get rentals_edit_url + assert_response :success + end + + test "should get destroy" do + get rentals_destroy_url + assert_response :success + end + + test "should get index" do + get rentals_index_url + assert_response :success + end + + test "should get show" do + get rentals_show_url + assert_response :success + end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 000000000..e5da4b3f3 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SessionsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 000000000..8e31f7ce6 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,23 @@ +require "test_helper" + +class UsersControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get users_index_url + assert_response :success + end + + test "should get show" do + get users_show_url + assert_response :success + end + + test "should get new" do + get users_new_url + assert_response :success + end + + test "should get edit" do + get users_edit_url + assert_response :success + end +end diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml new file mode 100644 index 000000000..7d4122404 --- /dev/null +++ b/test/fixtures/categories.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/fixtures/locations.yml b/test/fixtures/locations.yml new file mode 100644 index 000000000..b5fad577e --- /dev/null +++ b/test/fixtures/locations.yml @@ -0,0 +1,13 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + latitude: 1.5 + longitude: 1.5 + +two: + name: MyString + address: MyString + latitude: 1.5 + longitude: 1.5 diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml new file mode 100644 index 000000000..07a32b3e1 --- /dev/null +++ b/test/fixtures/memberships.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + type: + cost: 1.5 + expiration_date: 2023-11-03 + +two: + type: + cost: 1.5 + expiration_date: 2023-11-03 diff --git a/test/fixtures/payments.yml b/test/fixtures/payments.yml new file mode 100644 index 000000000..2047d212c --- /dev/null +++ b/test/fixtures/payments.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + credit_card_info: MyString + +two: + credit_card_info: MyString diff --git a/test/fixtures/rentals.yml b/test/fixtures/rentals.yml new file mode 100644 index 000000000..766b4bff2 --- /dev/null +++ b/test/fixtures/rentals.yml @@ -0,0 +1,15 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + identifier: 1 + rented_at: 2023-11-05 13:59:36 + returned_at: 2023-11-05 13:59:36 + rental_period: 1 + return_by: 2023-11-05 13:59:36 + +two: + identifier: 1 + rented_at: 2023-11-05 13:59:36 + returned_at: 2023-11-05 13:59:36 + rental_period: 1 + return_by: 2023-11-05 13:59:36 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 000000000..148530e18 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,15 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + first_name: MyString + last_name: MyString + email_address: MyString + has_bike: false + password: MyString + +two: + first_name: MyString + last_name: MyString + email_address: MyString + has_bike: false + password: MyString diff --git a/test/models/category_test.rb b/test/models/category_test.rb new file mode 100644 index 000000000..869357c88 --- /dev/null +++ b/test/models/category_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class CategoryTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/location_test.rb b/test/models/location_test.rb new file mode 100644 index 000000000..3c813e8ff --- /dev/null +++ b/test/models/location_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class LocationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/membership_test.rb b/test/models/membership_test.rb new file mode 100644 index 000000000..8506331ed --- /dev/null +++ b/test/models/membership_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class MembershipTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/payment_test.rb b/test/models/payment_test.rb new file mode 100644 index 000000000..f43bc797b --- /dev/null +++ b/test/models/payment_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class PaymentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/rental_test.rb b/test/models/rental_test.rb new file mode 100644 index 000000000..c3d74bd40 --- /dev/null +++ b/test/models/rental_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class RentalTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 000000000..5c07f4900 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/locations_test.rb b/test/system/locations_test.rb new file mode 100644 index 000000000..54078c6ce --- /dev/null +++ b/test/system/locations_test.rb @@ -0,0 +1,47 @@ +require "application_system_test_case" + +class LocationsTest < ApplicationSystemTestCase + setup do + @location = locations(:one) + end + + test "visiting the index" do + visit locations_url + assert_selector "h1", text: "Locations" + end + + test "should create location" do + visit locations_url + click_on "New location" + + fill_in "Address", with: @location.address + fill_in "Latitude", with: @location.latitude + fill_in "Longitude", with: @location.longitude + fill_in "Name", with: @location.name + click_on "Create Location" + + assert_text "Location was successfully created" + click_on "Back" + end + + test "should update Location" do + visit location_url(@location) + click_on "Edit this location", match: :first + + fill_in "Address", with: @location.address + fill_in "Latitude", with: @location.latitude + fill_in "Longitude", with: @location.longitude + fill_in "Name", with: @location.name + click_on "Update Location" + + assert_text "Location was successfully updated" + click_on "Back" + end + + test "should destroy Location" do + visit location_url(@location) + click_on "Destroy this location", match: :first + + assert_text "Location was successfully destroyed" + end +end