diff --git a/Gemfile b/Gemfile index 0b7a3b30..5e8f9aa1 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' @@ -41,4 +41,3 @@ group :development do gem 'spring' gem 'listen' end - diff --git a/Gemfile.lock b/Gemfile.lock index 2ecff3a1..6b4e2375 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,6 +43,7 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) + bcrypt (3.1.12) bindex (0.5.0) builder (3.2.3) byebug (10.0.2) @@ -160,6 +161,7 @@ PLATFORMS ruby DEPENDENCIES + bcrypt (~> 3.1.7) byebug jbuilder (~> 2.0) jquery-rails @@ -173,4 +175,4 @@ DEPENDENCIES web-console BUNDLED WITH - 1.16.1 + 1.16.2 diff --git a/app/assets/javascripts/reservations.js b/app/assets/javascripts/reservations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/reservations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/restaurants.js b/app/assets/javascripts/restaurants.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/restaurants.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/sessions.js b/app/assets/javascripts/sessions.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/sessions.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/users.js b/app/assets/javascripts/users.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/users.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/reservations.scss b/app/assets/stylesheets/reservations.scss new file mode 100644 index 00000000..7b399eed --- /dev/null +++ b/app/assets/stylesheets/reservations.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Reservations controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/restaurants.scss b/app/assets/stylesheets/restaurants.scss new file mode 100644 index 00000000..18555c87 --- /dev/null +++ b/app/assets/stylesheets/restaurants.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Restaurants controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 00000000..ccb1ed25 --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 00000000..31a2eacb --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e1..ac0710eb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,16 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + +private + +def current_user + @current_user ||= User.find(session[:user_id]) if session[:user_id] +end + + +helper_method :current_user + + + end diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb new file mode 100644 index 00000000..6308e2c6 --- /dev/null +++ b/app/controllers/reservations_controller.rb @@ -0,0 +1,74 @@ +class ReservationsController < ApplicationController +# +# def create_reservation(user_id,rest_id,start_time, end_time, no_of_guests ) +# max_time = 1 +# current_cap = max_cap +# reservation.restaurant_id = params[][] +# reservation.user_id = params[][] +# reservation.time = params[][] +# reservation.number_of_guests = params[] +# +# +# +# if (restaurant.capacity > no_of_guests) && (time) && current_day == true +# +# allow the party +# current_cap = +# else +# +# reservation request cancelled +# +# end +# + + +# +# def capacity +# @capacity = Restaurant.find(params[:restaurant_id]).capacity +# end + +# end #create reservation ends + + +def create + @reservation = Reservation.new + @reservation.time = params[:reservation][:time] + @reservation.number_of_guests = params[:reservation][:number_of_guests] + @reservation.user_id = params[:reservation][:user_id] + @reservation.restaurant_id = params[:reservation][:restaurant_id] + + + @restaurant_total_capacity = Restaurant.find(params[:restaurant_id]).capacity + + @restaurant_open = + + + if (@restaurant_total_capacity < @reservation.number_of_guests)&&() + puts "NOPE" + else + puts "OKAY" + redirect_to restaurants_url + end + +end + + +def edit + +end + + +def update + +end + + + + +def delete + +end + + + +end diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb new file mode 100644 index 00000000..b223ff63 --- /dev/null +++ b/app/controllers/restaurants_controller.rb @@ -0,0 +1,70 @@ +class RestaurantsController < ApplicationController + + def index + @restaurants = Restaurant.all + end + + def show + @restaurant = Restaurant.find(params[:id]) + @reservations = Reservation.where(restaurant_id: @restaurant_id) + @reservations = @restaurant.reservations + @reservation = Reservation.new + end + + def new + @restaurant = Restaurant.new + end + + def create + @restaurant = Restaurant.new + @restaurant.name = params[:restaurant][:name] + @restaurant.address = params[:restaurant][:address] + @restaurant.city = params[:restaurant][:city] + @restaurant.price_range = params[:restaurant][:price_range] + @restaurant.summary = params[:restaurant][:summary] + @restaurant.menu = params[:restaurant][:menu] + @restaurant.opening_hours = params[:restaurant][:opening_hours] + @restaurant.closing_hours = params[:restaurant][:closing_hours] + @restaurant.capacity = params[:restaurant][:capacity] + @restaurant.min_party_size = params[:restaurant][:min_party_size] + @restaurant.max_party_size = params[:restaurant][:max_party_size] + @restaurant.user = current_user + if @restaurant.save + redirect_to restaurants_url + else + render :new + end + end + + def edit + @restaurant = Restaurant.find(params[:id]) + end + + def update + @restaurant = Restaurant.find(params[:id]) + @restaurant.name = params[:restaurant][:name] + @restaurant.address = params[:restaurant][:address] + @restaurant.city = params[:restaurant][:city] + @restaurant.price_range = params[:restaurant][:price_range] + @restaurant.summary = params[:restaurant][:summary] + @restaurant.menu = params[:restaurant][:menu] + @restaurant.opening_hours = params[:restaurant][:opening_hours] + @restaurant.closing_hours = params[:restaurant][:closing_hours] + @restaurant.capacity = params[:restaurant][:capacity] + @restaurant.min_party_size = params[:restaurant][:min_party_size] + @restaurant.max_party_size = params[:restaurant][:max_party_size] + if @restaurant.save + redirect_to restaurant_url + else + render :edit + end + end + + def destroy + @restaurant = Restaurant.find(params[:id]) + @restaurant.destroy + redirect_to restaurants_url + end + + +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 00000000..d6c46e28 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,20 @@ +class SessionsController < ApplicationController + def new + end + + def create + user = User.find_by(email: params[:session][:email]) + if user && user.authenticate(params[:session][:password]) + session[:user_id] = user.id + + redirect_to restaurants_url + else + render :new + end + end + + def destroy + session[:user_id] = nil + redirect_to restaurants_url, notice: "Logged out!" + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 00000000..5ad0c7ae --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,25 @@ +class UsersController < ApplicationController + + def new + @user = User.new + end + + def create + @user = User.new + @user.name = params[:user][:name] + @user.email = params[:user][:email] + @user.password = params[:user][:password] + + + if @user.save + redirect_to restaurants_url + else + render :new + end + end + + def show + @restaurants = current_user.restaurants + end + +end diff --git a/app/helpers/reservations_helper.rb b/app/helpers/reservations_helper.rb new file mode 100644 index 00000000..f28b699d --- /dev/null +++ b/app/helpers/reservations_helper.rb @@ -0,0 +1,2 @@ +module ReservationsHelper +end diff --git a/app/helpers/restaurants_helper.rb b/app/helpers/restaurants_helper.rb new file mode 100644 index 00000000..3937c4c7 --- /dev/null +++ b/app/helpers/restaurants_helper.rb @@ -0,0 +1,2 @@ +module RestaurantsHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 00000000..309f8b2e --- /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 00000000..2310a240 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/models/reservation.rb b/app/models/reservation.rb new file mode 100644 index 00000000..cc40c87d --- /dev/null +++ b/app/models/reservation.rb @@ -0,0 +1,4 @@ +class Reservation < ApplicationRecord + belongs_to :restaurant + belongs_to :user +end diff --git a/app/models/restaurant.rb b/app/models/restaurant.rb new file mode 100644 index 00000000..51d94b4a --- /dev/null +++ b/app/models/restaurant.rb @@ -0,0 +1,8 @@ +class Restaurant < ApplicationRecord + has_many :reservations + belongs_to :user + + validates :name, :address, :city, :price_range, :capacity, :opening_hours, :closing_hours, :max_party_size, presence: true + validates :address, uniqueness: true + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 00000000..b9019e51 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,12 @@ +class User < ApplicationRecord + has_many :reservations + has_many :restaurants + + has_secure_password + + validates :name, presence: true + validates :email, presence: true + validates :email, uniqueness: true + + +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c32feae9..5c21aa08 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,6 +6,24 @@ <%= javascript_include_tag 'application' %> <%= csrf_meta_tags %> + +
+ +
<%= yield %> diff --git a/app/views/reservations/_form.html.erb b/app/views/reservations/_form.html.erb new file mode 100644 index 00000000..6ed7dd6b --- /dev/null +++ b/app/views/reservations/_form.html.erb @@ -0,0 +1,18 @@ +<%= form_for ([restaurant, reservation]) do |f| %> + + +
+ <%= f.label :time %> + <%= f.time_field :time %> +
+ +
+ <%= f.label :number_of_guests %> + <%= f.number_field :number_of_guests %> +
+ +
+ <%= f.submit "Submit" %> +
+ +<% end %> diff --git a/app/views/restaurants/_form_restaurant.html.erb b/app/views/restaurants/_form_restaurant.html.erb new file mode 100644 index 00000000..bfceb7e3 --- /dev/null +++ b/app/views/restaurants/_form_restaurant.html.erb @@ -0,0 +1,69 @@ +<% if restaurant.errors.any? %> + <% restaurant.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +<% end %> + + + +<%= form_for restaurant do |f| %> +
    + <%= f.label :name %> + <%= f.text_field :name %> +
    + +
    + <%= f.label :address %> + <%= f.text_field :address %> +
    + +
    + <%= f.label :city %> + <%= f.text_field :city %> +
    + +
    + <%= f.label :price_range %> + <%= f.text_field :price_range %> +
    + +
    + <%= f.label :summary %> + <%= f.text_field :summary %> +
    + +
    + <%= f.label :menu %> + <%= f.text_field :menu %> +
    + +
    + <%= f.label :opening_hours %> + <%= f.time_field :opening_hours %> +
    + +
    + <%= f.label :closing_hours %> + <%= f.time_field :closing_hours %> +
    + + +
    + <%= f.label :capacity %> + <%= f.number_field :capacity %> +
    + +
    + <%= f.label :min_party_size %> + <%= f.number_field :min_party_size %> +
    + +
    + <%= f.label :max_party_size %> + <%= f.number_field :max_party_size %> +
    + +
    + <%= f.submit "Submit" %> +
    +<% end %> diff --git a/app/views/restaurants/edit.html.erb b/app/views/restaurants/edit.html.erb new file mode 100644 index 00000000..2b119cd8 --- /dev/null +++ b/app/views/restaurants/edit.html.erb @@ -0,0 +1,3 @@ +

    Edit your restaurant

    + +<%= render 'form_restaurant', restaurant: @restaurant %> diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb new file mode 100644 index 00000000..2961f9e7 --- /dev/null +++ b/app/views/restaurants/index.html.erb @@ -0,0 +1,5 @@ +

    Welcome To Munch!

    + +<% @restaurants.sort_by{|city| city[:city]}.each do |restaurant| %> +
  • <%= link_to"#{restaurant.name}", restaurant_url(restaurant) %>
  • +<% end %> diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb new file mode 100644 index 00000000..7bc88dd7 --- /dev/null +++ b/app/views/restaurants/new.html.erb @@ -0,0 +1,3 @@ +

    Create your restaurant

    + +<%= render 'form_restaurant', restaurant: @restaurant %> diff --git a/app/views/restaurants/show.html.erb b/app/views/restaurants/show.html.erb new file mode 100644 index 00000000..9516b0c9 --- /dev/null +++ b/app/views/restaurants/show.html.erb @@ -0,0 +1,20 @@ +

    <%= @restaurant.name %>

    + +<% if current_user == @restaurant.user %> + <%= link_to "Edit", edit_restaurant_path %> | <%= link_to "Delete", "/restaurants/#{@restaurant.id}", method: :delete %> +<% end %> + + + + +

    Reservation

    +<%= render partial: "reservations/form", locals: {restaurant: @restaurant, reservation: @reservation} %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 00000000..13eb063c --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,19 @@ +

    Log in

    + +<%= form_for :session, url: sessions_path do |f| %> + +

    + <%= f.label :email %> + <%= f.text_field :email %> +

    + +

    + <%= f.label :password %> + <%= f.password_field :password %> +

    + +

    + <%= f.submit "Submit" %> +

    + +<% end %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 00000000..7e1c3a21 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,29 @@ +

    Sign up

    + +<%= form_for @user do |f| %> + +

    + <%= f.label :name %> + <%= f.text_field :name %> +

    + +

    + <%= f.label :email %> + <%= f.text_field :email %> +

    + +

    + <%= f.label :password %> + <%= f.password_field :password %> +

    + +

    + <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation %> +

    + +

    + <%= f.submit "Submit" %> +

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

    <%= current_user.name %>

    +
    +<%= current_user.email %> +
    + + +<% @restaurants.each do |restaurant| %> + <% @reservations = restaurant.reservations %> + + <% @reservations.each do |reservation| %> + + <% end %> +<% end %> + +

    Reservations made

    +<% current_user.reservations.each do |r| %> +
    +

    Time: <%= r.time %>

    +

    Restaurant: <%= r.restaurant_id %>

    +

    Guests:<%= r.number_of_guests %>

    +
    +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 787824f8..20dcbc52 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,13 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + resources :restaurants do + resources :reservations + end + + resources :users + + resources :sessions + + root 'restaurants#index' end diff --git a/db/migrate/20181010191109_create_restaurants.rb b/db/migrate/20181010191109_create_restaurants.rb new file mode 100644 index 00000000..2ab66af9 --- /dev/null +++ b/db/migrate/20181010191109_create_restaurants.rb @@ -0,0 +1,16 @@ +class CreateRestaurants < ActiveRecord::Migration[5.2] + def change + create_table :restaurants do |t| + t.string :address + t.string :city + t.string :price_range + t.text :summary + t.string :menu + t.string :opening_hours + t.integer :user_id + t.integer :capacity + + t.timestamps + end + end +end diff --git a/db/migrate/20181010191133_create_users.rb b/db/migrate/20181010191133_create_users.rb new file mode 100644 index 00000000..df6f8641 --- /dev/null +++ b/db/migrate/20181010191133_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration[5.2] + def change + create_table :users do |t| + t.string :name + t.string :email + t.boolean :owner + + t.timestamps + end + end +end diff --git a/db/migrate/20181010191213_create_reservations.rb b/db/migrate/20181010191213_create_reservations.rb new file mode 100644 index 00000000..a0613278 --- /dev/null +++ b/db/migrate/20181010191213_create_reservations.rb @@ -0,0 +1,12 @@ +class CreateReservations < ActiveRecord::Migration[5.2] + def change + create_table :reservations do |t| + t.integer :restaurant_id + t.integer :user_id + t.string :time + t.integer :number_of_guests + + t.timestamps + end + end +end diff --git a/db/migrate/20181010202515_add_password_column.rb b/db/migrate/20181010202515_add_password_column.rb new file mode 100644 index 00000000..85520c9c --- /dev/null +++ b/db/migrate/20181010202515_add_password_column.rb @@ -0,0 +1,5 @@ +class AddPasswordColumn < ActiveRecord::Migration[5.2] + def change + add_column :users, :password_digest, :string + end +end diff --git a/db/migrate/20181010204331_drop_column_owner.rb b/db/migrate/20181010204331_drop_column_owner.rb new file mode 100644 index 00000000..e781e19d --- /dev/null +++ b/db/migrate/20181010204331_drop_column_owner.rb @@ -0,0 +1,5 @@ +class DropColumnOwner < ActiveRecord::Migration[5.2] + def change + remove_column :users, :owner + end +end diff --git a/db/migrate/20181010211911_add_column_name_to_restaurant.rb b/db/migrate/20181010211911_add_column_name_to_restaurant.rb new file mode 100644 index 00000000..ef32123a --- /dev/null +++ b/db/migrate/20181010211911_add_column_name_to_restaurant.rb @@ -0,0 +1,5 @@ +class AddColumnNameToRestaurant < ActiveRecord::Migration[5.2] + def change + add_column :restaurants, :name, :string + end +end diff --git a/db/migrate/20181011151617_change_opening_hours.rb b/db/migrate/20181011151617_change_opening_hours.rb new file mode 100644 index 00000000..a9d37f34 --- /dev/null +++ b/db/migrate/20181011151617_change_opening_hours.rb @@ -0,0 +1,6 @@ +class ChangeOpeningHours < ActiveRecord::Migration[5.2] + def change + change_column :restaurants, :opening_hours, :time + add_column :restaurants, :closing_hours, :time + end +end diff --git a/db/migrate/20181011153809_edit_reservation_column.rb b/db/migrate/20181011153809_edit_reservation_column.rb new file mode 100644 index 00000000..8519e8b8 --- /dev/null +++ b/db/migrate/20181011153809_edit_reservation_column.rb @@ -0,0 +1,6 @@ +class EditReservationColumn < ActiveRecord::Migration[5.2] + def change + change_column :reservations, :time, :time + + end +end diff --git a/db/migrate/20181011184514_add_column_and_change_column.rb b/db/migrate/20181011184514_add_column_and_change_column.rb new file mode 100644 index 00000000..57d586a8 --- /dev/null +++ b/db/migrate/20181011184514_add_column_and_change_column.rb @@ -0,0 +1,10 @@ +class AddColumnAndChangeColumn < ActiveRecord::Migration[5.2] + def change + add_column :restaurants, :closing_hours, :time + end + + def change + change_column :restaurants, :opening_hours, :time + end + +end diff --git a/db/migrate/20181011205808_add_min_max_party_size_to_restaurant.rb b/db/migrate/20181011205808_add_min_max_party_size_to_restaurant.rb new file mode 100644 index 00000000..fa15e8b8 --- /dev/null +++ b/db/migrate/20181011205808_add_min_max_party_size_to_restaurant.rb @@ -0,0 +1,6 @@ +class AddMinMaxPartySizeToRestaurant < ActiveRecord::Migration[5.2] + def change + add_column :restaurants, :min_party_size, :integer + add_column :restaurants, :max_party_size, :interger + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..afc1b191 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,49 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2018_10_11_205808) do + + create_table "reservations", force: :cascade do |t| + t.integer "restaurant_id" + t.integer "user_id" + t.time "time" + t.integer "number_of_guests" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "restaurants", force: :cascade do |t| + t.string "address" + t.string "city" + t.string "price_range" + t.text "summary" + t.string "menu" + t.time "opening_hours" + t.integer "user_id" + t.integer "capacity" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.time "closing_hours" + t.integer "min_party_size" + t.integer "max_party_size" + end + + create_table "users", force: :cascade do |t| + t.string "name" + t.string "email" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "password_digest" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e85..4a154aac 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,49 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) + +user = User.create( + name: "kevin", + email: "kevindiep@fakemail.com" +) + +Restaurant.create( + address: "353 Bay Street", + city: "Toronto", + price_range: "$$$", + summary: "Authentic Japanese cuisine", + menu: "not available", + capacity: 150, + user_id: 1, + name: "Miku" + +) + +Restaurant.create( + address: "1 Yonge Street", + city: "Toronto", + price_range: "$$", + summary: "Mongolian hot pot", + menu: "not available", + capacity: 200, + user_id: 1, + name: "Mongolian Style" +) + +Restaurant.create( + address: "200 Bay Street", + city: "Toronto", + price_range: "$$$$", + summary: "Surf and Turf, fine dining", + menu: "coming soon!", + capacity: 100, + user_id: 1, + name: "surfs up!" +) + +Reservation.create( + restaurant_id: 10, + user_id: 4, + time: Time.now, + number_of_guests: 10 +) diff --git a/test/controllers/reservations_controller_test.rb b/test/controllers/reservations_controller_test.rb new file mode 100644 index 00000000..3b4d21b6 --- /dev/null +++ b/test/controllers/reservations_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ReservationsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/restaurants_controller_test.rb b/test/controllers/restaurants_controller_test.rb new file mode 100644 index 00000000..c0e4d28e --- /dev/null +++ b/test/controllers/restaurants_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RestaurantsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 00000000..6135ce6a --- /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 00000000..6c3da770 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UsersControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/reservations.yml b/test/fixtures/reservations.yml new file mode 100644 index 00000000..4cb3c9b7 --- /dev/null +++ b/test/fixtures/reservations.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + restaurant_id: 1 + user_id: 1 + time: MyString + number_of_guests: 1 + +two: + restaurant_id: 1 + user_id: 1 + time: MyString + number_of_guests: 1 diff --git a/test/fixtures/restaurants.yml b/test/fixtures/restaurants.yml new file mode 100644 index 00000000..63397761 --- /dev/null +++ b/test/fixtures/restaurants.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + address: MyString + city: MyString + price_range: MyString + summary: MyText + menu: MyString + opening_hours: MyString + user_id: 1 + +two: + address: MyString + city: MyString + price_range: MyString + summary: MyText + menu: MyString + opening_hours: MyString + user_id: 1 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 00000000..cfa8a56d --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + email: MyString + owner: false + +two: + name: MyString + email: MyString + owner: false diff --git a/test/models/reservation_test.rb b/test/models/reservation_test.rb new file mode 100644 index 00000000..391559fd --- /dev/null +++ b/test/models/reservation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ReservationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/restaurant_test.rb b/test/models/restaurant_test.rb new file mode 100644 index 00000000..b45b7417 --- /dev/null +++ b/test/models/restaurant_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RestaurantTest < 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 00000000..82f61e01 --- /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