From 62046c7b14552c32cdff24c87dd0cf8ad7a4cb41 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Wed, 18 Apr 2018 11:57:04 -0700
Subject: [PATCH 001/242] initial rails setup
---
.gitignore | 19 +
Gemfile | 72 ++
Gemfile.lock | 236 +++++
README.md | 207 +----
Rakefile | 6 +
app/assets/config/manifest.js | 3 +
app/assets/images/.keep | 0
app/assets/javascripts/application.js | 20 +
app/assets/javascripts/cable.js | 13 +
app/assets/javascripts/channels/.keep | 0
app/assets/stylesheets/_settings.scss | 869 ++++++++++++++++++
app/assets/stylesheets/application.css | 19 +
app/assets/stylesheets/browserslist | 4 +
.../stylesheets/foundation_and_overrides.scss | 61 ++
app/channels/application_cable/channel.rb | 4 +
app/channels/application_cable/connection.rb | 4 +
app/controllers/application_controller.rb | 3 +
app/controllers/concerns/.keep | 0
app/helpers/application_helper.rb | 2 +
app/jobs/application_job.rb | 2 +
app/mailers/application_mailer.rb | 4 +
app/models/application_record.rb | 3 +
app/models/concerns/.keep | 0
app/views/layouts/application.html.erb | 19 +
app/views/layouts/mailer.html.erb | 13 +
app/views/layouts/mailer.text.erb | 1 +
bin/bundle | 3 +
bin/rails | 9 +
bin/rake | 9 +
bin/setup | 38 +
bin/spring | 17 +
bin/update | 29 +
bin/yarn | 11 +
config.ru | 5 +
config/application.rb | 25 +
config/boot.rb | 3 +
config/cable.yml | 10 +
config/database.yml | 85 ++
config/environment.rb | 5 +
config/environments/development.rb | 54 ++
config/environments/production.rb | 91 ++
config/environments/test.rb | 42 +
.../application_controller_renderer.rb | 8 +
config/initializers/assets.rb | 14 +
config/initializers/backtrace_silencers.rb | 7 +
config/initializers/cookies_serializer.rb | 5 +
.../initializers/filter_parameter_logging.rb | 4 +
config/initializers/inflections.rb | 16 +
config/initializers/mime_types.rb | 4 +
config/initializers/wrap_parameters.rb | 14 +
config/locales/en.yml | 33 +
config/puma.rb | 56 ++
config/routes.rb | 3 +
config/secrets.yml | 32 +
config/spring.rb | 6 +
db/seeds.rb | 7 +
lib/assets/.keep | 0
lib/tasks/.keep | 0
log/.keep | 0
package.json | 5 +
public/404.html | 67 ++
public/422.html | 67 ++
public/500.html | 66 ++
public/apple-touch-icon-precomposed.png | 0
public/apple-touch-icon.png | 0
public/favicon.ico | 0
public/robots.txt | 1 +
test/application_system_test_case.rb | 5 +
test/controllers/.keep | 0
test/fixtures/.keep | 0
test/fixtures/files/.keep | 0
test/helpers/.keep | 0
test/integration/.keep | 0
test/mailers/.keep | 0
test/models/.keep | 0
test/system/.keep | 0
test/test_helper.rb | 26 +
tmp/.keep | 0
vendor/.keep | 0
79 files changed, 2272 insertions(+), 194 deletions(-)
create mode 100644 .gitignore
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 Rakefile
create mode 100644 app/assets/config/manifest.js
create mode 100644 app/assets/images/.keep
create mode 100644 app/assets/javascripts/application.js
create mode 100644 app/assets/javascripts/cable.js
create mode 100644 app/assets/javascripts/channels/.keep
create mode 100644 app/assets/stylesheets/_settings.scss
create mode 100644 app/assets/stylesheets/application.css
create mode 100644 app/assets/stylesheets/browserslist
create mode 100644 app/assets/stylesheets/foundation_and_overrides.scss
create mode 100644 app/channels/application_cable/channel.rb
create mode 100644 app/channels/application_cable/connection.rb
create mode 100644 app/controllers/application_controller.rb
create mode 100644 app/controllers/concerns/.keep
create mode 100644 app/helpers/application_helper.rb
create mode 100644 app/jobs/application_job.rb
create mode 100644 app/mailers/application_mailer.rb
create mode 100644 app/models/application_record.rb
create mode 100644 app/models/concerns/.keep
create mode 100644 app/views/layouts/application.html.erb
create mode 100644 app/views/layouts/mailer.html.erb
create mode 100644 app/views/layouts/mailer.text.erb
create mode 100755 bin/bundle
create mode 100755 bin/rails
create mode 100755 bin/rake
create mode 100755 bin/setup
create mode 100755 bin/spring
create mode 100755 bin/update
create mode 100755 bin/yarn
create mode 100644 config.ru
create mode 100644 config/application.rb
create mode 100644 config/boot.rb
create mode 100644 config/cable.yml
create mode 100644 config/database.yml
create mode 100644 config/environment.rb
create mode 100644 config/environments/development.rb
create mode 100644 config/environments/production.rb
create mode 100644 config/environments/test.rb
create mode 100644 config/initializers/application_controller_renderer.rb
create mode 100644 config/initializers/assets.rb
create mode 100644 config/initializers/backtrace_silencers.rb
create mode 100644 config/initializers/cookies_serializer.rb
create mode 100644 config/initializers/filter_parameter_logging.rb
create mode 100644 config/initializers/inflections.rb
create mode 100644 config/initializers/mime_types.rb
create mode 100644 config/initializers/wrap_parameters.rb
create mode 100644 config/locales/en.yml
create mode 100644 config/puma.rb
create mode 100644 config/routes.rb
create mode 100644 config/secrets.yml
create mode 100644 config/spring.rb
create mode 100644 db/seeds.rb
create mode 100644 lib/assets/.keep
create mode 100644 lib/tasks/.keep
create mode 100644 log/.keep
create mode 100644 package.json
create mode 100644 public/404.html
create mode 100644 public/422.html
create mode 100644 public/500.html
create mode 100644 public/apple-touch-icon-precomposed.png
create mode 100644 public/apple-touch-icon.png
create mode 100644 public/favicon.ico
create mode 100644 public/robots.txt
create mode 100644 test/application_system_test_case.rb
create mode 100644 test/controllers/.keep
create mode 100644 test/fixtures/.keep
create mode 100644 test/fixtures/files/.keep
create mode 100644 test/helpers/.keep
create mode 100644 test/integration/.keep
create mode 100644 test/mailers/.keep
create mode 100644 test/models/.keep
create mode 100644 test/system/.keep
create mode 100644 test/test_helper.rb
create mode 100644 tmp/.keep
create mode 100644 vendor/.keep
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..82701fedc8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile '~/.gitignore_global'
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+/node_modules
+/yarn-error.log
+
+.byebug_history
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000000..8490d0efb5
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,72 @@
+source 'https://rubygems.org'
+
+git_source(:github) do |repo_name|
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
+ "https://github.com/#{repo_name}.git"
+end
+
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '~> 5.1.6'
+# Use postgresql as the database for Active Record
+gem 'pg', '>= 0.18', '< 2.0'
+# Use Puma as the app server
+gem 'puma', '~> 3.7'
+# Use SCSS for stylesheets
+gem 'sass-rails', '~> 5.0'
+# Use Uglifier as compressor for JavaScript assets
+gem 'uglifier', '>= 1.3.0'
+# See https://github.com/rails/execjs#readme for more supported runtimes
+# gem 'therubyracer', platforms: :ruby
+
+# Use CoffeeScript for .coffee assets and views
+# gem 'coffee-rails', '~> 4.2'
+# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
+gem 'turbolinks', '~> 5'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.5'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 4.0'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+
+group :development, :test do
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
+ # Adds support for Capybara system testing and selenium driver
+ gem 'capybara', '~> 2.13'
+ gem 'selenium-webdriver'
+end
+
+group :development do
+ # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
+ gem 'web-console', '>= 3.3.0'
+ gem 'listen', '>= 3.0.5', '< 3.2'
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+ gem 'spring'
+ gem 'spring-watcher-listen', '~> 2.0.0'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
+
+gem 'jquery-turbolinks'
+gem 'jquery-rails'
+gem 'foundation-rails'
+gem 'normalize-rails'
+group :development, :test do
+ gem 'pry-rails'
+end
+
+group :development do
+ gem 'better_errors'
+ gem 'binding_of_caller'
+end
+
+group :test do
+ gem 'minitest-rails'
+ gem 'minitest-reporters'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000000..d528acb17a
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,236 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (5.1.6)
+ actionpack (= 5.1.6)
+ nio4r (~> 2.0)
+ websocket-driver (~> 0.6.1)
+ actionmailer (5.1.6)
+ actionpack (= 5.1.6)
+ actionview (= 5.1.6)
+ activejob (= 5.1.6)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.1.6)
+ actionview (= 5.1.6)
+ activesupport (= 5.1.6)
+ rack (~> 2.0)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ actionview (5.1.6)
+ activesupport (= 5.1.6)
+ builder (~> 3.1)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.1.6)
+ activesupport (= 5.1.6)
+ globalid (>= 0.3.6)
+ activemodel (5.1.6)
+ activesupport (= 5.1.6)
+ activerecord (5.1.6)
+ activemodel (= 5.1.6)
+ activesupport (= 5.1.6)
+ arel (~> 8.0)
+ activesupport (5.1.6)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ addressable (2.5.2)
+ public_suffix (>= 2.0.2, < 4.0)
+ ansi (1.5.0)
+ arel (8.0.0)
+ babel-source (5.8.35)
+ babel-transpiler (0.7.0)
+ babel-source (>= 4.0, < 6)
+ execjs (~> 2.0)
+ better_errors (2.4.0)
+ coderay (>= 1.0.0)
+ erubi (>= 1.0.0)
+ rack (>= 0.9.0)
+ bindex (0.5.0)
+ binding_of_caller (0.8.0)
+ debug_inspector (>= 0.0.1)
+ builder (3.2.3)
+ byebug (10.0.2)
+ capybara (2.18.0)
+ addressable
+ mini_mime (>= 0.1.3)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ xpath (>= 2.0, < 4.0)
+ childprocess (0.9.0)
+ ffi (~> 1.0, >= 1.0.11)
+ coderay (1.1.2)
+ concurrent-ruby (1.0.5)
+ crass (1.0.4)
+ debug_inspector (0.0.3)
+ erubi (1.7.1)
+ execjs (2.7.0)
+ ffi (1.9.23)
+ foundation-rails (6.4.3.0)
+ railties (>= 3.1.0)
+ sass (>= 3.3.0, < 3.5)
+ sprockets-es6 (>= 0.9.0)
+ globalid (0.4.1)
+ activesupport (>= 4.2.0)
+ i18n (1.0.1)
+ concurrent-ruby (~> 1.0)
+ jbuilder (2.7.0)
+ activesupport (>= 4.2.0)
+ multi_json (>= 1.2)
+ jquery-rails (4.3.3)
+ rails-dom-testing (>= 1, < 3)
+ railties (>= 4.2.0)
+ thor (>= 0.14, < 2.0)
+ jquery-turbolinks (2.1.0)
+ railties (>= 3.1.0)
+ turbolinks
+ listen (3.1.5)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ ruby_dep (~> 1.2)
+ loofah (2.2.2)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.7.0)
+ mini_mime (>= 0.1.1)
+ method_source (0.9.0)
+ mini_mime (1.0.0)
+ mini_portile2 (2.3.0)
+ minitest (5.11.3)
+ minitest-rails (3.0.0)
+ minitest (~> 5.8)
+ railties (~> 5.0)
+ minitest-reporters (1.2.0)
+ ansi
+ builder
+ minitest (>= 5.0)
+ ruby-progressbar
+ multi_json (1.13.1)
+ nio4r (2.3.0)
+ nokogiri (1.8.2)
+ mini_portile2 (~> 2.3.0)
+ normalize-rails (4.1.1)
+ pg (1.0.0)
+ pry (0.11.3)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ pry-rails (0.3.6)
+ pry (>= 0.10.4)
+ public_suffix (3.0.2)
+ puma (3.11.4)
+ rack (2.0.4)
+ rack-test (1.0.0)
+ rack (>= 1.0, < 3)
+ rails (5.1.6)
+ actioncable (= 5.1.6)
+ actionmailer (= 5.1.6)
+ actionpack (= 5.1.6)
+ actionview (= 5.1.6)
+ activejob (= 5.1.6)
+ activemodel (= 5.1.6)
+ activerecord (= 5.1.6)
+ activesupport (= 5.1.6)
+ bundler (>= 1.3.0)
+ railties (= 5.1.6)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.0.4)
+ loofah (~> 2.2, >= 2.2.2)
+ railties (5.1.6)
+ actionpack (= 5.1.6)
+ activesupport (= 5.1.6)
+ method_source
+ rake (>= 0.8.7)
+ thor (>= 0.18.1, < 2.0)
+ rake (12.3.1)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
+ ruby-progressbar (1.9.0)
+ ruby_dep (1.5.0)
+ rubyzip (1.2.1)
+ sass (3.4.25)
+ sass-rails (5.0.7)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
+ selenium-webdriver (3.11.0)
+ childprocess (~> 0.5)
+ rubyzip (~> 1.2)
+ spring (2.0.2)
+ activesupport (>= 4.2)
+ spring-watcher-listen (2.0.1)
+ listen (>= 2.7, < 4.0)
+ spring (>= 1.2, < 3.0)
+ sprockets (3.7.1)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-es6 (0.9.2)
+ babel-source (>= 5.8.11)
+ babel-transpiler
+ sprockets (>= 3.0.0)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ thor (0.20.0)
+ thread_safe (0.3.6)
+ tilt (2.0.8)
+ turbolinks (5.1.1)
+ turbolinks-source (~> 5.1)
+ turbolinks-source (5.1.0)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ uglifier (4.1.9)
+ execjs (>= 0.3.0, < 3)
+ web-console (3.6.0)
+ actionview (>= 5.0)
+ activemodel (>= 5.0)
+ bindex (>= 0.4.0)
+ railties (>= 5.0)
+ websocket-driver (0.6.5)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.3)
+ xpath (3.0.0)
+ nokogiri (~> 1.8)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ better_errors
+ binding_of_caller
+ byebug
+ capybara (~> 2.13)
+ foundation-rails
+ jbuilder (~> 2.5)
+ jquery-rails
+ jquery-turbolinks
+ listen (>= 3.0.5, < 3.2)
+ minitest-rails
+ minitest-reporters
+ normalize-rails
+ pg (>= 0.18, < 2.0)
+ pry-rails
+ puma (~> 3.7)
+ rails (~> 5.1.6)
+ sass-rails (~> 5.0)
+ selenium-webdriver
+ spring
+ spring-watcher-listen (~> 2.0.0)
+ turbolinks (~> 5)
+ tzinfo-data
+ uglifier (>= 1.3.0)
+ web-console (>= 3.3.0)
+
+BUNDLED WITH
+ 1.16.1
diff --git a/README.md b/README.md
index 2758975bf5..7db80e4ca1 100644
--- a/README.md
+++ b/README.md
@@ -1,205 +1,24 @@
-# bEtsy
-[Much like other e-commerce platforms](https://www.etsy.com/), your team will make an online store where a wide variety of products can be listed and sold by any user. This project focuses on reinforcing the major components of Rails, model validations, testing, and more complex logic such as user authentication.
+# README
-This is a [Stage 3](https://github.com/Ada-Developers-Academy/pedagogy/blob/master/rule-of-three.md) project requiring you to expand upon what you have learned in class.
+This README would normally document whatever steps are necessary to get the
+application up and running.
-## Project Learning Goals
-- Core comprehension of:
- - Routes
- - Controllers
- - Models
- - Views
-- User based application logic
-- User authentication
-- Testing on models and controllers
-- Agile practices
-- Feature branch management with Git
-- Group project ownership
+Things you may want to cover:
-## Guidelines
-- Groups of three or four will collaborate in pairs or individually and will report to their assigned Project Manager (one of the instructors)
-- Use a task manager like [Trello](http://trello.com) to track your team's efforts
-- Build a logical user-flow that moves across multiple controllers and models
-- Use HTML/CSS and Foundation to style your website
+* Ruby version
-## Getting Started
-1. As a group decide on an app name (this may help lead the aesthetic)
-1. As a group decide on a team name (this will amuse your instructors)
-1. Have one person on your team fork/clone the project master as per usual
- 1. Create a new rails app using `rails new .`
- 1. Add all other team members as collaborators
- 1. Each team member should clone the repo to their computer
-1. Figure out your workflow for the project, re: Git and Task management
- 1. Do you want to use git branches? Pull requests?
- 1. Determine who will be the Stand Up Leader and Task Leader for the first week
-1. Create a Trello board to use as a Kanban board and ensure that all team members and instructors have access
-1. Review the User Stories below and create Trello tasks to represent them
-1. Slack your team name, app name, and link to your Trello board to your Project Manager
+* System dependencies
-## Expectations
-Build an online system for listing, selling, reviewing, and buying a wide variety of products listed by multiple merchants.
+* Configuration
-### General Requirements
-- Unit tests and/or specs for
- - Models
- - Controllers
-- Test code coverage (using SimpleCov - remember me!)
- - 90% for all controller and model classes
+* Database creation
-### User Stories
-#### Guest User (Unauthenticated)
-As a guest to the website (not signed in) I **can**:
+* Database initialization
-- Browse all products
-- Browse products by category
-- Browse products by merchant (users)
-- View any individual product with additional details
-- Leave a review for a product providing:
- - A text review
- - A rating out of 5
-- Add in-stock products to my cart
-- Remove products from my cart
-- Change the quantity of an existing product in my cart
-- Purchase the items in my cart, providing:
- - Email Address
- - Mailing Address
- - Name on credit card
- - Credit card number
- - Credit cart expiration
- - Credit Card CVV (security code)
- - Billing zip code
-- Purchasing an order makes the following changes:
- - Reduces the number of inventory for each product
- - Changes the order state from "pending" to "paid"
- - Clears the current cart
-- After purchasing an order, I can view a confirmation screen including:
- - Each item in the order with a quantity and line-item subtotal
- - A link to the item description page
- - Order total price
- - Date/time the order was placed
- - The current status of the order
-- Sign up to be a merchant using OAuth
- - Every merchant must have a username
-- Sign in to my merchant account using OAuth
+* How to run the test suite
-As a guest I **cannot**:
+* Services (job queues, cache servers, search engines, etc.)
-- Add products to the cart that are out of stock
-- View any link or page to manage any products
-- View any of the account pages
+* Deployment instructions
-#### Authenticated Users
-As a signed-in user, I **can**:
-
-- Do everything a guest user can do except for sign up and sign in
-- Sign out
-- Create new categories (categories are shared between all merchants)
-- Create a new product providing:
- - name
- - description
- - price
- - photo URL
- - stock
-- Assign my products to any number of categories
-- Retire a product from being sold, which hides it from browsing
-- View an account page to edit/update my existing products
-- View an account page showing my order fulfillment
-- On the order fulfillment page:
- - Total Revenue
- - Total Revenue by status
- - Total number of orders by status
- - Filter orders displayed by status
- - Link to each individual order
- - A list of orders including at least one of my products:
- - Each order item sold by me with a quantity and line-item subtotal
- - A link to the item description page
- - DateTime the order was placed
- - Link to transition the order item to marked as shipped
- - The current status of the order ("pending", "paid", "complete", "cancelled")
-- View an individual order to see the user's:
- - Name
- - Email address
- - Mailing address
- - Last four digits of their credit card
- - Credit card expiration date
-
-As a signed-in user, I **cannot**:
-
-- Review my own products
-- View order items from a shared order that belong to another merchant
-- View another user's private data (i.e. order fulfillment or product management)
-
-### Validations
-Many of our models will have attributes that are required for our application to use and display data consistently. Each model will have attributes with requirements for a valid record. The requirements are summarized below:
-
-#### Merchant
-- Username must be present
-- Username must be unique
-- Email Address must be present
-- Email Address must be unique
-
-#### Product
-- Name must be present
-- Name must be unique
-- Price must be present
-- Price must be a number
-- Price must be greater than 0
-- Product must belong to a User
-
-#### Order
-- An Order must have one or more Order Items
-
-#### OrderItem
-- Must belong to a Product
-- Must belong to an Order
-- Quantity must be present
-- Quantity must be an integer
-- Quantity must be greater than 0
-
-#### Review
-- Rating must be present
-- Rating must be an integer
-- Rating must be between 1 and 5
-
-## Submission Guidelines
-Your final project must be deployed to [Heroku](http://heroku.com). Your team will open a single pull request for the entire project. There are comprehension questions to answer with your submission that you should complete together as a group. Remember, you can submit a PR and still make some final changes to your code, so don't wait until the last minute.
-
-## Team Leaders
-Each team will have team leaders who are responsible for keeping track of each team member's contributions. Rotate leader roles at the beginning of the second week; every team member should be in at least one leader role during the project.
-
-- **Stand Up Leader**
- - Notifies team members about meeting schedule and ensures that everyone is present and ready
- - Takes notes about each person's daily report in Stand Up
- - Keeps the meeting moving
-- **Task Leader**
- - Leads discussion on task assignment and prioritization
- - Decide if a task should be completed alone or in a pair
- - Assign tasks based on...
- - Individual comfort
- - Desire
- - Ability
- - Ensures the Kanban board stays up to date
-
-## Stand Up Meetings
-The Stand Up Leader should determine the daily time for your stand up meeting with the team. Once you come up with a time, confirm with your PM that this time will work for them.
-
-At the end of each day, your team's assigned Project Manager will review the Trello board to ensure it captures the updates that your team has made throughout the day.
-
-## Interim Demo
-In a real world work environment, a team's success is measured by their product as opposed to each individual's contribution.
-
-Each team will present their progress and respond to questions from their Project Manager on the first Friday. Every team member will participate in these demos; the PM will ask specific questions regarding
-1. The team's progress and plan for completing the project
-1. The technical decisions and implementation
-1. Every team member's understanding of the underlying technical structures
-
-## Final Presentation
-Each team will present their product in a final presentation to the group on the final Friday. Your presentation should be no more than 7 minutes. The presentation should include every team member and:
-- what you learned as individuals and as a group
-- a short story-driven demo of interesting features
-
-## Due Date
-This project is due EOD Apr 27 via PR against Ada-C9/betsy.
-
-## What Instructors Are Looking For
-Check out the [feedback template](feedback.md) which lists the items instructors will be looking for as they evaluate your project.
+* ...
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000000..e85f913914
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative 'config/application'
+
+Rails.application.load_tasks
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js
new file mode 100644
index 0000000000..b16e53d6d5
--- /dev/null
+++ b/app/assets/config/manifest.js
@@ -0,0 +1,3 @@
+//= link_tree ../images
+//= link_directory ../javascripts .js
+//= link_directory ../stylesheets .css
diff --git a/app/assets/images/.keep b/app/assets/images/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
new file mode 100644
index 0000000000..f04673be81
--- /dev/null
+++ b/app/assets/javascripts/application.js
@@ -0,0 +1,20 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
+// vendor/assets/javascripts directory can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// compiled file. JavaScript code in this file should be added after the last require_* statement.
+//
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
+// about supported directives.
+//= require jquery
+
+//
+//= require rails-ujs
+//= require foundation
+//= require turbolinks
+//= require_tree .
+
+$(function(){ $(document).foundation(); });
diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js
new file mode 100644
index 0000000000..739aa5f022
--- /dev/null
+++ b/app/assets/javascripts/cable.js
@@ -0,0 +1,13 @@
+// Action Cable provides the framework to deal with WebSockets in Rails.
+// You can generate new channels where WebSocket features live using the `rails generate channel` command.
+//
+//= require action_cable
+//= require_self
+//= require_tree ./channels
+
+(function() {
+ this.App || (this.App = {});
+
+ App.cable = ActionCable.createConsumer();
+
+}).call(this);
diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss
new file mode 100644
index 0000000000..26f74f9494
--- /dev/null
+++ b/app/assets/stylesheets/_settings.scss
@@ -0,0 +1,869 @@
+// Foundation for Sites Settings
+// -----------------------------
+//
+// Table of Contents:
+//
+// 1. Global
+// 2. Breakpoints
+// 3. The Grid
+// 4. Base Typography
+// 5. Typography Helpers
+// 6. Abide
+// 7. Accordion
+// 8. Accordion Menu
+// 9. Badge
+// 10. Breadcrumbs
+// 11. Button
+// 12. Button Group
+// 13. Callout
+// 14. Card
+// 15. Close Button
+// 16. Drilldown
+// 17. Dropdown
+// 18. Dropdown Menu
+// 19. Flexbox Utilities
+// 20. Forms
+// 21. Label
+// 22. Media Object
+// 23. Menu
+// 24. Meter
+// 25. Off-canvas
+// 26. Orbit
+// 27. Pagination
+// 28. Progress Bar
+// 29. Prototype Arrow
+// 30. Prototype Border-Box
+// 31. Prototype Border-None
+// 32. Prototype Bordered
+// 33. Prototype Display
+// 34. Prototype Font-Styling
+// 35. Prototype List-Style-Type
+// 36. Prototype Overflow
+// 37. Prototype Position
+// 38. Prototype Rounded
+// 39. Prototype Separator
+// 40. Prototype Shadow
+// 41. Prototype Sizing
+// 42. Prototype Spacing
+// 43. Prototype Text-Decoration
+// 44. Prototype Text-Transformation
+// 45. Prototype Text-Utilities
+// 46. Responsive Embed
+// 47. Reveal
+// 48. Slider
+// 49. Switch
+// 50. Table
+// 51. Tabs
+// 52. Thumbnail
+// 53. Title Bar
+// 54. Tooltip
+// 55. Top Bar
+// 56. Xy Grid
+
+@import 'util/util';
+
+// 1. Global
+// ---------
+
+$global-font-size: 100%;
+$global-width: rem-calc(1200);
+$global-lineheight: 1.5;
+$foundation-palette: (
+ primary: #1779ba,
+ secondary: #767676,
+ success: #3adb76,
+ warning: #ffae00,
+ alert: #cc4b37,
+);
+$light-gray: #e6e6e6;
+$medium-gray: #cacaca;
+$dark-gray: #8a8a8a;
+$black: #0a0a0a;
+$white: #fefefe;
+$body-background: $white;
+$body-font-color: $black;
+$body-font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;
+$body-antialiased: true;
+$global-margin: 1rem;
+$global-padding: 1rem;
+$global-position: 1rem;
+$global-weight-normal: normal;
+$global-weight-bold: bold;
+$global-radius: 0;
+$global-menu-padding: 0.7rem 1rem;
+$global-menu-nested-margin: 1rem;
+$global-text-direction: ltr;
+$global-flexbox: true;
+$global-prototype-breakpoints: false;
+$global-button-cursor: auto;
+$global-color-pick-contrast-tolerance: 0;
+$print-transparent-backgrounds: true;
+
+@include add-foundation-colors;
+
+// 2. Breakpoints
+// --------------
+
+$breakpoints: (
+ small: 0,
+ medium: 640px,
+ large: 1024px,
+ xlarge: 1200px,
+ xxlarge: 1440px,
+);
+$print-breakpoint: large;
+$breakpoint-classes: (small medium large);
+
+// 3. The Grid
+// -----------
+
+$grid-row-width: $global-width;
+$grid-column-count: 12;
+$grid-column-gutter: (
+ small: 20px,
+ medium: 30px,
+);
+$grid-column-align-edge: true;
+$grid-column-alias: 'columns';
+$block-grid-max: 8;
+
+// 4. Base Typography
+// ------------------
+
+$header-font-family: $body-font-family;
+$header-font-weight: $global-weight-normal;
+$header-font-style: normal;
+$font-family-monospace: Consolas, 'Liberation Mono', Courier, monospace;
+$header-color: inherit;
+$header-lineheight: 1.4;
+$header-margin-bottom: 0.5rem;
+$header-styles: (
+ small: (
+ 'h1': ('font-size': 24),
+ 'h2': ('font-size': 20),
+ 'h3': ('font-size': 19),
+ 'h4': ('font-size': 18),
+ 'h5': ('font-size': 17),
+ 'h6': ('font-size': 16),
+ ),
+ medium: (
+ 'h1': ('font-size': 48),
+ 'h2': ('font-size': 40),
+ 'h3': ('font-size': 31),
+ 'h4': ('font-size': 25),
+ 'h5': ('font-size': 20),
+ 'h6': ('font-size': 16),
+ ),
+);
+$header-text-rendering: optimizeLegibility;
+$small-font-size: 80%;
+$header-small-font-color: $medium-gray;
+$paragraph-lineheight: 1.6;
+$paragraph-margin-bottom: 1rem;
+$paragraph-text-rendering: optimizeLegibility;
+$code-color: $black;
+$code-font-family: $font-family-monospace;
+$code-font-weight: $global-weight-normal;
+$code-background: $light-gray;
+$code-border: 1px solid $medium-gray;
+$code-padding: rem-calc(2 5 1);
+$anchor-color: $primary-color;
+$anchor-color-hover: scale-color($anchor-color, $lightness: -14%);
+$anchor-text-decoration: none;
+$anchor-text-decoration-hover: none;
+$hr-width: $global-width;
+$hr-border: 1px solid $medium-gray;
+$hr-margin: rem-calc(20) auto;
+$list-lineheight: $paragraph-lineheight;
+$list-margin-bottom: $paragraph-margin-bottom;
+$list-style-type: disc;
+$list-style-position: outside;
+$list-side-margin: 1.25rem;
+$list-nested-side-margin: 1.25rem;
+$defnlist-margin-bottom: 1rem;
+$defnlist-term-weight: $global-weight-bold;
+$defnlist-term-margin-bottom: 0.3rem;
+$blockquote-color: $dark-gray;
+$blockquote-padding: rem-calc(9 20 0 19);
+$blockquote-border: 1px solid $medium-gray;
+$cite-font-size: rem-calc(13);
+$cite-color: $dark-gray;
+$cite-pseudo-content: '\2014 \0020';
+$keystroke-font: $font-family-monospace;
+$keystroke-color: $black;
+$keystroke-background: $light-gray;
+$keystroke-padding: rem-calc(2 4 0);
+$keystroke-radius: $global-radius;
+$abbr-underline: 1px dotted $black;
+
+// 5. Typography Helpers
+// ---------------------
+
+$lead-font-size: $global-font-size * 1.25;
+$lead-lineheight: 1.6;
+$subheader-lineheight: 1.4;
+$subheader-color: $dark-gray;
+$subheader-font-weight: $global-weight-normal;
+$subheader-margin-top: 0.2rem;
+$subheader-margin-bottom: 0.5rem;
+$stat-font-size: 2.5rem;
+
+// 6. Abide
+// --------
+
+$abide-inputs: true;
+$abide-labels: true;
+$input-background-invalid: get-color(alert);
+$form-label-color-invalid: get-color(alert);
+$input-error-color: get-color(alert);
+$input-error-font-size: rem-calc(12);
+$input-error-font-weight: $global-weight-bold;
+
+// 7. Accordion
+// ------------
+
+$accordion-background: $white;
+$accordion-plusminus: true;
+$accordion-title-font-size: rem-calc(12);
+$accordion-item-color: $primary-color;
+$accordion-item-background-hover: $light-gray;
+$accordion-item-padding: 1.25rem 1rem;
+$accordion-content-background: $white;
+$accordion-content-border: 1px solid $light-gray;
+$accordion-content-color: $body-font-color;
+$accordion-content-padding: 1rem;
+
+// 8. Accordion Menu
+// -----------------
+
+$accordionmenu-padding: $global-menu-padding;
+$accordionmenu-nested-margin: $global-menu-nested-margin;
+$accordionmenu-submenu-padding: $accordionmenu-padding;
+$accordionmenu-arrows: true;
+$accordionmenu-arrow-color: $primary-color;
+$accordionmenu-item-background: null;
+$accordionmenu-border: null;
+$accordionmenu-submenu-toggle-background: null;
+$accordion-submenu-toggle-border: $accordionmenu-border;
+$accordionmenu-submenu-toggle-width: 40px;
+$accordionmenu-submenu-toggle-height: $accordionmenu-submenu-toggle-width;
+$accordionmenu-arrow-size: 6px;
+
+// 9. Badge
+// --------
+
+$badge-background: $primary-color;
+$badge-color: $white;
+$badge-color-alt: $black;
+$badge-palette: $foundation-palette;
+$badge-padding: 0.3em;
+$badge-minwidth: 2.1em;
+$badge-font-size: 0.6rem;
+
+// 10. Breadcrumbs
+// ---------------
+
+$breadcrumbs-margin: 0 0 $global-margin 0;
+$breadcrumbs-item-font-size: rem-calc(11);
+$breadcrumbs-item-color: $primary-color;
+$breadcrumbs-item-color-current: $black;
+$breadcrumbs-item-color-disabled: $medium-gray;
+$breadcrumbs-item-margin: 0.75rem;
+$breadcrumbs-item-uppercase: true;
+$breadcrumbs-item-separator: true;
+$breadcrumbs-item-separator-item: '/';
+$breadcrumbs-item-separator-item-rtl: '\\';
+$breadcrumbs-item-separator-color: $medium-gray;
+
+// 11. Button
+// ----------
+
+$button-font-family: inherit;
+$button-padding: 0.85em 1em;
+$button-margin: 0 0 $global-margin 0;
+$button-fill: solid;
+$button-background: $primary-color;
+$button-background-hover: scale-color($button-background, $lightness: -15%);
+$button-color: $white;
+$button-color-alt: $black;
+$button-radius: $global-radius;
+$button-hollow-border-width: 1px;
+$button-sizes: (
+ tiny: 0.6rem,
+ small: 0.75rem,
+ default: 0.9rem,
+ large: 1.25rem,
+);
+$button-palette: $foundation-palette;
+$button-opacity-disabled: 0.25;
+$button-background-hover-lightness: -20%;
+$button-hollow-hover-lightness: -50%;
+$button-transition: background-color 0.25s ease-out, color 0.25s ease-out;
+
+// 12. Button Group
+// ----------------
+
+$buttongroup-margin: 1rem;
+$buttongroup-spacing: 1px;
+$buttongroup-child-selector: '.button';
+$buttongroup-expand-max: 6;
+$buttongroup-radius-on-each: true;
+
+// 13. Callout
+// -----------
+
+$callout-background: $white;
+$callout-background-fade: 85%;
+$callout-border: 1px solid rgba($black, 0.25);
+$callout-margin: 0 0 1rem 0;
+$callout-padding: 1rem;
+$callout-font-color: $body-font-color;
+$callout-font-color-alt: $body-background;
+$callout-radius: $global-radius;
+$callout-link-tint: 30%;
+
+// 14. Card
+// --------
+
+$card-background: $white;
+$card-font-color: $body-font-color;
+$card-divider-background: $light-gray;
+$card-border: 1px solid $light-gray;
+$card-shadow: none;
+$card-border-radius: $global-radius;
+$card-padding: $global-padding;
+$card-margin-bottom: $global-margin;
+
+// 15. Close Button
+// ----------------
+
+$closebutton-position: right top;
+$closebutton-offset-horizontal: (
+ small: 0.66rem,
+ medium: 1rem,
+);
+$closebutton-offset-vertical: (
+ small: 0.33em,
+ medium: 0.5rem,
+);
+$closebutton-size: (
+ small: 1.5em,
+ medium: 2em,
+);
+$closebutton-lineheight: 1;
+$closebutton-color: $dark-gray;
+$closebutton-color-hover: $black;
+
+// 16. Drilldown
+// -------------
+
+$drilldown-transition: transform 0.15s linear;
+$drilldown-arrows: true;
+$drilldown-padding: $global-menu-padding;
+$drilldown-nested-margin: 0;
+$drilldown-background: $white;
+$drilldown-submenu-padding: $drilldown-padding;
+$drilldown-submenu-background: $white;
+$drilldown-arrow-color: $primary-color;
+$drilldown-arrow-size: 6px;
+
+// 17. Dropdown
+// ------------
+
+$dropdown-padding: 1rem;
+$dropdown-background: $body-background;
+$dropdown-border: 1px solid $medium-gray;
+$dropdown-font-size: 1rem;
+$dropdown-width: 300px;
+$dropdown-radius: $global-radius;
+$dropdown-sizes: (
+ tiny: 100px,
+ small: 200px,
+ large: 400px,
+);
+
+// 18. Dropdown Menu
+// -----------------
+
+$dropdownmenu-arrows: true;
+$dropdownmenu-arrow-color: $anchor-color;
+$dropdownmenu-arrow-size: 6px;
+$dropdownmenu-arrow-padding: 1.5rem;
+$dropdownmenu-min-width: 200px;
+$dropdownmenu-background: $white;
+$dropdownmenu-submenu-background: $dropdownmenu-background;
+$dropdownmenu-padding: $global-menu-padding;
+$dropdownmenu-nested-margin: 0;
+$dropdownmenu-submenu-padding: $dropdownmenu-padding;
+$dropdownmenu-border: 1px solid $medium-gray;
+$dropdown-menu-item-color-active: get-color(primary);
+$dropdown-menu-item-background-active: transparent;
+
+// 19. Flexbox Utilities
+// ---------------------
+
+$flex-source-ordering-count: 6;
+$flexbox-responsive-breakpoints: true;
+
+// 20. Forms
+// ---------
+
+$fieldset-border: 1px solid $medium-gray;
+$fieldset-padding: rem-calc(20);
+$fieldset-margin: rem-calc(18 0);
+$legend-padding: rem-calc(0 3);
+$form-spacing: rem-calc(16);
+$helptext-color: $black;
+$helptext-font-size: rem-calc(13);
+$helptext-font-style: italic;
+$input-prefix-color: $black;
+$input-prefix-background: $light-gray;
+$input-prefix-border: 1px solid $medium-gray;
+$input-prefix-padding: 1rem;
+$form-label-color: $black;
+$form-label-font-size: rem-calc(14);
+$form-label-font-weight: $global-weight-normal;
+$form-label-line-height: 1.8;
+$select-background: $white;
+$select-triangle-color: $dark-gray;
+$select-radius: $global-radius;
+$input-color: $black;
+$input-placeholder-color: $medium-gray;
+$input-font-family: inherit;
+$input-font-size: rem-calc(16);
+$input-font-weight: $global-weight-normal;
+$input-line-height: $global-lineheight;
+$input-background: $white;
+$input-background-focus: $white;
+$input-background-disabled: $light-gray;
+$input-border: 1px solid $medium-gray;
+$input-border-focus: 1px solid $dark-gray;
+$input-padding: $form-spacing / 2;
+$input-shadow: inset 0 1px 2px rgba($black, 0.1);
+$input-shadow-focus: 0 0 5px $medium-gray;
+$input-cursor-disabled: not-allowed;
+$input-transition: box-shadow 0.5s, border-color 0.25s ease-in-out;
+$input-number-spinners: true;
+$input-radius: $global-radius;
+$form-button-radius: $global-radius;
+
+// 21. Label
+// ---------
+
+$label-background: $primary-color;
+$label-color: $white;
+$label-color-alt: $black;
+$label-palette: $foundation-palette;
+$label-font-size: 0.8rem;
+$label-padding: 0.33333rem 0.5rem;
+$label-radius: $global-radius;
+
+// 22. Media Object
+// ----------------
+
+$mediaobject-margin-bottom: $global-margin;
+$mediaobject-section-padding: $global-padding;
+$mediaobject-image-width-stacked: 100%;
+
+// 23. Menu
+// --------
+
+$menu-margin: 0;
+$menu-nested-margin: $global-menu-nested-margin;
+$menu-items-padding: $global-menu-padding;
+$menu-simple-margin: 1rem;
+$menu-item-color-active: $white;
+$menu-item-background-active: get-color(primary);
+$menu-icon-spacing: 0.25rem;
+$menu-item-background-hover: $light-gray;
+$menu-state-back-compat: true;
+$menu-centered-back-compat: true;
+$menu-icons-back-compat: true;
+
+// 24. Meter
+// ---------
+
+$meter-height: 1rem;
+$meter-radius: $global-radius;
+$meter-background: $medium-gray;
+$meter-fill-good: $success-color;
+$meter-fill-medium: $warning-color;
+$meter-fill-bad: $alert-color;
+
+// 25. Off-canvas
+// --------------
+
+$offcanvas-sizes: (
+ small: 250px,
+);
+$offcanvas-vertical-sizes: (
+ small: 250px,
+);
+$offcanvas-background: $light-gray;
+$offcanvas-shadow: 0 0 10px rgba($black, 0.7);
+$offcanvas-inner-shadow-size: 20px;
+$offcanvas-inner-shadow-color: rgba($black, 0.25);
+$offcanvas-overlay-zindex: 11;
+$offcanvas-push-zindex: 12;
+$offcanvas-overlap-zindex: 13;
+$offcanvas-reveal-zindex: 12;
+$offcanvas-transition-length: 0.5s;
+$offcanvas-transition-timing: ease;
+$offcanvas-fixed-reveal: true;
+$offcanvas-exit-background: rgba($white, 0.25);
+$maincontent-class: 'off-canvas-content';
+
+// 26. Orbit
+// ---------
+
+$orbit-bullet-background: $medium-gray;
+$orbit-bullet-background-active: $dark-gray;
+$orbit-bullet-diameter: 1.2rem;
+$orbit-bullet-margin: 0.1rem;
+$orbit-bullet-margin-top: 0.8rem;
+$orbit-bullet-margin-bottom: 0.8rem;
+$orbit-caption-background: rgba($black, 0.5);
+$orbit-caption-padding: 1rem;
+$orbit-control-background-hover: rgba($black, 0.5);
+$orbit-control-padding: 1rem;
+$orbit-control-zindex: 10;
+
+// 27. Pagination
+// --------------
+
+$pagination-font-size: rem-calc(14);
+$pagination-margin-bottom: $global-margin;
+$pagination-item-color: $black;
+$pagination-item-padding: rem-calc(3 10);
+$pagination-item-spacing: rem-calc(1);
+$pagination-radius: $global-radius;
+$pagination-item-background-hover: $light-gray;
+$pagination-item-background-current: $primary-color;
+$pagination-item-color-current: $white;
+$pagination-item-color-disabled: $medium-gray;
+$pagination-ellipsis-color: $black;
+$pagination-mobile-items: false;
+$pagination-mobile-current-item: false;
+$pagination-arrows: true;
+
+// 28. Progress Bar
+// ----------------
+
+$progress-height: 1rem;
+$progress-background: $medium-gray;
+$progress-margin-bottom: $global-margin;
+$progress-meter-background: $primary-color;
+$progress-radius: $global-radius;
+
+// 29. Prototype Arrow
+// -------------------
+
+$prototype-arrow-directions: (
+ down,
+ up,
+ right,
+ left
+);
+$prototype-arrow-size: 0.4375rem;
+$prototype-arrow-color: $black;
+
+// 30. Prototype Border-Box
+// ------------------------
+
+$prototype-border-box-breakpoints: $global-prototype-breakpoints;
+
+// 31. Prototype Border-None
+// -------------------------
+
+$prototype-border-none-breakpoints: $global-prototype-breakpoints;
+
+// 32. Prototype Bordered
+// ----------------------
+
+$prototype-bordered-breakpoints: $global-prototype-breakpoints;
+$prototype-border-width: rem-calc(1);
+$prototype-border-type: solid;
+$prototype-border-color: $medium-gray;
+
+// 33. Prototype Display
+// ---------------------
+
+$prototype-display-breakpoints: $global-prototype-breakpoints;
+$prototype-display: (
+ inline,
+ inline-block,
+ block,
+ table,
+ table-cell
+);
+
+// 34. Prototype Font-Styling
+// --------------------------
+
+$prototype-font-breakpoints: $global-prototype-breakpoints;
+$prototype-wide-letter-spacing: rem-calc(4);
+$prototype-font-normal: $global-weight-normal;
+$prototype-font-bold: $global-weight-bold;
+
+// 35. Prototype List-Style-Type
+// -----------------------------
+
+$prototype-list-breakpoints: $global-prototype-breakpoints;
+$prototype-style-type-unordered: (
+ disc,
+ circle,
+ square
+);
+$prototype-style-type-ordered: (
+ decimal,
+ lower-alpha,
+ lower-latin,
+ lower-roman,
+ upper-alpha,
+ upper-latin,
+ upper-roman
+);
+
+// 36. Prototype Overflow
+// ----------------------
+
+$prototype-overflow-breakpoints: $global-prototype-breakpoints;
+$prototype-overflow: (
+ visible,
+ hidden,
+ scroll
+);
+
+// 37. Prototype Position
+// ----------------------
+
+$prototype-position-breakpoints: $global-prototype-breakpoints;
+$prototype-position: (
+ static,
+ relative,
+ absolute,
+ fixed
+);
+$prototype-position-z-index: 975;
+
+// 38. Prototype Rounded
+// ---------------------
+
+$prototype-rounded-breakpoints: $global-prototype-breakpoints;
+$prototype-border-radius: rem-calc(3);
+
+// 39. Prototype Separator
+// -----------------------
+
+$prototype-separator-breakpoints: $global-prototype-breakpoints;
+$prototype-separator-align: center;
+$prototype-separator-height: rem-calc(2);
+$prototype-separator-width: 3rem;
+$prototype-separator-background: $primary-color;
+$prototype-separator-margin-top: $global-margin;
+
+// 40. Prototype Shadow
+// --------------------
+
+$prototype-shadow-breakpoints: $global-prototype-breakpoints;
+$prototype-box-shadow: 0 2px 5px 0 rgba(0,0,0,.16),
+ 0 2px 10px 0 rgba(0,0,0,.12);
+
+// 41. Prototype Sizing
+// --------------------
+
+$prototype-sizing-breakpoints: $global-prototype-breakpoints;
+$prototype-sizing: (
+ width,
+ height
+);
+$prototype-sizes: (
+ 25: 25%,
+ 50: 50%,
+ 75: 75%,
+ 100: 100%
+);
+
+// 42. Prototype Spacing
+// ---------------------
+
+$prototype-spacing-breakpoints: $global-prototype-breakpoints;
+$prototype-spacers-count: 3;
+
+// 43. Prototype Text-Decoration
+// -----------------------------
+
+$prototype-decoration-breakpoints: $global-prototype-breakpoints;
+$prototype-text-decoration: (
+ overline,
+ underline,
+ line-through,
+);
+
+// 44. Prototype Text-Transformation
+// ---------------------------------
+
+$prototype-transformation-breakpoints: $global-prototype-breakpoints;
+$prototype-text-transformation: (
+ lowercase,
+ uppercase,
+ capitalize
+);
+
+// 45. Prototype Text-Utilities
+// ----------------------------
+
+$prototype-utilities-breakpoints: $global-prototype-breakpoints;
+$prototype-text-overflow: ellipsis;
+
+// 46. Responsive Embed
+// --------------------
+
+$responsive-embed-margin-bottom: rem-calc(16);
+$responsive-embed-ratios: (
+ default: 4 by 3,
+ widescreen: 16 by 9,
+);
+
+// 47. Reveal
+// ----------
+
+$reveal-background: $white;
+$reveal-width: 600px;
+$reveal-max-width: $global-width;
+$reveal-padding: $global-padding;
+$reveal-border: 1px solid $medium-gray;
+$reveal-radius: $global-radius;
+$reveal-zindex: 1005;
+$reveal-overlay-background: rgba($black, 0.45);
+
+// 48. Slider
+// ----------
+
+$slider-width-vertical: 0.5rem;
+$slider-transition: all 0.2s ease-in-out;
+$slider-height: 0.5rem;
+$slider-background: $light-gray;
+$slider-fill-background: $medium-gray;
+$slider-handle-height: 1.4rem;
+$slider-handle-width: 1.4rem;
+$slider-handle-background: $primary-color;
+$slider-opacity-disabled: 0.25;
+$slider-radius: $global-radius;
+
+// 49. Switch
+// ----------
+
+$switch-background: $medium-gray;
+$switch-background-active: $primary-color;
+$switch-height: 2rem;
+$switch-height-tiny: 1.5rem;
+$switch-height-small: 1.75rem;
+$switch-height-large: 2.5rem;
+$switch-radius: $global-radius;
+$switch-margin: $global-margin;
+$switch-paddle-background: $white;
+$switch-paddle-offset: 0.25rem;
+$switch-paddle-radius: $global-radius;
+$switch-paddle-transition: all 0.25s ease-out;
+
+// 50. Table
+// ---------
+
+$table-background: $white;
+$table-color-scale: 5%;
+$table-border: 1px solid smart-scale($table-background, $table-color-scale);
+$table-padding: rem-calc(8 10 10);
+$table-hover-scale: 2%;
+$table-row-hover: darken($table-background, $table-hover-scale);
+$table-row-stripe-hover: darken($table-background, $table-color-scale + $table-hover-scale);
+$table-is-striped: true;
+$table-striped-background: smart-scale($table-background, $table-color-scale);
+$table-stripe: even;
+$table-head-background: smart-scale($table-background, $table-color-scale / 2);
+$table-head-row-hover: darken($table-head-background, $table-hover-scale);
+$table-foot-background: smart-scale($table-background, $table-color-scale);
+$table-foot-row-hover: darken($table-foot-background, $table-hover-scale);
+$table-head-font-color: $body-font-color;
+$table-foot-font-color: $body-font-color;
+$show-header-for-stacked: false;
+$table-stack-breakpoint: medium;
+
+// 51. Tabs
+// --------
+
+$tab-margin: 0;
+$tab-background: $white;
+$tab-color: $primary-color;
+$tab-background-active: $light-gray;
+$tab-active-color: $primary-color;
+$tab-item-font-size: rem-calc(12);
+$tab-item-background-hover: $white;
+$tab-item-padding: 1.25rem 1.5rem;
+$tab-expand-max: 6;
+$tab-content-background: $white;
+$tab-content-border: $light-gray;
+$tab-content-color: $body-font-color;
+$tab-content-padding: 1rem;
+
+// 52. Thumbnail
+// -------------
+
+$thumbnail-border: solid 4px $white;
+$thumbnail-margin-bottom: $global-margin;
+$thumbnail-shadow: 0 0 0 1px rgba($black, 0.2);
+$thumbnail-shadow-hover: 0 0 6px 1px rgba($primary-color, 0.5);
+$thumbnail-transition: box-shadow 200ms ease-out;
+$thumbnail-radius: $global-radius;
+
+// 53. Title Bar
+// -------------
+
+$titlebar-background: $black;
+$titlebar-color: $white;
+$titlebar-padding: 0.5rem;
+$titlebar-text-font-weight: bold;
+$titlebar-icon-color: $white;
+$titlebar-icon-color-hover: $medium-gray;
+$titlebar-icon-spacing: 0.25rem;
+
+// 54. Tooltip
+// -----------
+
+$has-tip-cursor: help;
+$has-tip-font-weight: $global-weight-bold;
+$has-tip-border-bottom: dotted 1px $dark-gray;
+$tooltip-background-color: $black;
+$tooltip-color: $white;
+$tooltip-padding: 0.75rem;
+$tooltip-max-width: 10rem;
+$tooltip-font-size: $small-font-size;
+$tooltip-pip-width: 0.75rem;
+$tooltip-pip-height: $tooltip-pip-width * 0.866;
+$tooltip-radius: $global-radius;
+
+// 55. Top Bar
+// -----------
+
+$topbar-padding: 0.5rem;
+$topbar-background: $light-gray;
+$topbar-submenu-background: $topbar-background;
+$topbar-title-spacing: 0.5rem 1rem 0.5rem 0;
+$topbar-input-width: 200px;
+$topbar-unstack-breakpoint: medium;
+
+// 56. Xy Grid
+// -----------
+
+$xy-grid: true;
+$grid-container: $global-width;
+$grid-columns: 12;
+$grid-margin-gutters: (
+ small: 20px,
+ medium: 30px
+);
+$grid-padding-gutters: $grid-margin-gutters;
+$grid-container-padding: $grid-padding-gutters;
+$grid-container-max: $global-width;
+$xy-block-grid-max: 8;
+
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
new file mode 100644
index 0000000000..3a38418320
--- /dev/null
+++ b/app/assets/stylesheets/application.css
@@ -0,0 +1,19 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *= require normalize-rails
+
+ *
+ *= require_tree .
+ *= require_self
+ *= require foundation_and_overrides
+
+ */
diff --git a/app/assets/stylesheets/browserslist b/app/assets/stylesheets/browserslist
new file mode 100644
index 0000000000..6019618a9a
--- /dev/null
+++ b/app/assets/stylesheets/browserslist
@@ -0,0 +1,4 @@
+last 2 versions
+ie >= 9
+Android >= 2.3
+ios >= 7
diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss
new file mode 100644
index 0000000000..ed4c5a0ecf
--- /dev/null
+++ b/app/assets/stylesheets/foundation_and_overrides.scss
@@ -0,0 +1,61 @@
+@charset 'utf-8';
+
+@import 'settings';
+@import 'foundation';
+
+// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package.
+//
+// @import 'motion-ui/motion-ui';
+
+// We include everything by default. To slim your CSS, remove components you don't use.
+
+@include foundation-global-styles;
+@include foundation-xy-grid-classes;
+//@include foundation-grid;
+//@include foundation-flex-grid;
+@include foundation-flex-classes;
+@include foundation-typography;
+@include foundation-forms;
+@include foundation-button;
+@include foundation-accordion;
+@include foundation-accordion-menu;
+@include foundation-badge;
+@include foundation-breadcrumbs;
+@include foundation-button-group;
+@include foundation-callout;
+@include foundation-card;
+@include foundation-close-button;
+@include foundation-menu;
+@include foundation-menu-icon;
+@include foundation-drilldown-menu;
+@include foundation-dropdown;
+@include foundation-dropdown-menu;
+@include foundation-responsive-embed;
+@include foundation-label;
+@include foundation-media-object;
+@include foundation-off-canvas;
+@include foundation-orbit;
+@include foundation-pagination;
+@include foundation-progress-bar;
+@include foundation-slider;
+@include foundation-sticky;
+@include foundation-reveal;
+@include foundation-switch;
+@include foundation-table;
+@include foundation-tabs;
+@include foundation-thumbnail;
+@include foundation-title-bar;
+@include foundation-tooltip;
+@include foundation-top-bar;
+@include foundation-visibility-classes;
+@include foundation-float-classes;
+
+// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package.
+//
+// @include motion-ui-transitions;
+// @include motion-ui-animations;
+@import 'motion-ui/motion-ui';
+@include motion-ui-transitions;
+@include motion-ui-animations;
+
+
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000000..d672697283
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000000..0ff5442f47
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000000..1c07694e9d
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery with: :exception
+end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
new file mode 100644
index 0000000000..de6be7945c
--- /dev/null
+++ b/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000000..a009ace51c
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,2 @@
+class ApplicationJob < ActiveJob::Base
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000000..286b2239d1
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000000..10a4cba84d
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+end
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
new file mode 100644
index 0000000000..cd60004891
--- /dev/null
+++ b/app/views/layouts/application.html.erb
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ <%= content_for?(:title) ? yield(:title) : "Untitled" %>
+
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
+ <%= csrf_meta_tags %>
+
+
+
+
+ <%= yield %>
+
+
+
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000000..cbd34d2e9d
--- /dev/null
+++ b/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000000..37f0bddbd7
--- /dev/null
+++ b/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 0000000000..66e9889e8b
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 0000000000..5badb2fde0
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000000..d87d5f5781
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000000..78c4e861dc
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/spring b/bin/spring
new file mode 100755
index 0000000000..fb2ec2ebb4
--- /dev/null
+++ b/bin/spring
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+# This file loads spring without using Bundler, in order to be fast.
+# It gets overwritten when you run the `spring binstub` command.
+
+unless defined?(Spring)
+ require 'rubygems'
+ require 'bundler'
+
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
+ if spring
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
+ gem 'spring', spring.version
+ require 'spring/binstub'
+ end
+end
diff --git a/bin/update b/bin/update
new file mode 100755
index 0000000000..a8e4462f20
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/yarn b/bin/yarn
new file mode 100755
index 0000000000..c2bacef836
--- /dev/null
+++ b/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+VENDOR_PATH = File.expand_path('..', __dir__)
+Dir.chdir(VENDOR_PATH) do
+ begin
+ exec "yarnpkg #{ARGV.join(" ")}"
+ rescue Errno::ENOENT
+ $stderr.puts "Yarn executable was not detected in the system."
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
+ exit 1
+ end
+end
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000000..f7ba0b527b
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 0000000000..5f6ca0f9b2
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,25 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Betsy
+ class Application < Rails::Application
+ config.generators do |g|
+ # Force new test files to be generated in the minitest-spec style
+ g.test_framework :minitest, spec: true
+
+ # Always use .js files, never .coffee
+ g.javascript_engine :js
+ end
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.1
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 0000000000..30f5120df6
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000000..3cba994bb2
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: redis://localhost:6379/1
+ channel_prefix: betsy_production
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000000..6903bb6083
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,85 @@
+# PostgreSQL. Versions 9.1 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On OS X with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On OS X with MacPorts:
+# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem 'pg'
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see Rails configuration guide
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: betsy_development
+
+ # The specified database role being used to connect to postgres.
+ # To create additional roles in postgres see `$ createuser --help`.
+ # When left blank, postgres will use the default role. This is
+ # the same name as the operating system user that initialized the database.
+ #username: betsy
+
+ # The password associated with the postgres role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: betsy_test
+
+# As with config/secrets.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password as a unix environment variable when you boot
+# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full rundown on how to provide these environment variables in a
+# production deployment.
+#
+# On Heroku and other platform providers, you may have a full connection URL
+# available as an environment variable. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# You can use this database configuration with:
+#
+# production:
+# url: <%= ENV['DATABASE_URL'] %>
+#
+production:
+ <<: *default
+ database: betsy_production
+ username: betsy
+ password: <%= ENV['BETSY_DATABASE_PASSWORD'] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 0000000000..426333bb46
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 0000000000..5187e22186
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,54 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 0000000000..9284f84839
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,91 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
+ # `config/secrets.yml.key`.
+ config.read_encrypted_secrets = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "betsy_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 0000000000..8e5cbde533
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 0000000000..89d2efab2b
--- /dev/null
+++ b/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644
index 0000000000..4b828e80cb
--- /dev/null
+++ b/config/initializers/assets.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000000..59385cdf37
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000000..5a6a32d371
--- /dev/null
+++ b/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000000..4a994e1e7b
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 0000000000..ac033bf9dc
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
new file mode 100644
index 0000000000..dc1899682b
--- /dev/null
+++ b/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000000..bbfc3961bf
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000000..decc5a8573
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000000..1e19380dcb
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,56 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# If you are preloading your application and using Active Record, it's
+# recommended that you close any connections to the database before workers
+# are forked to prevent connection leakage.
+#
+# before_fork do
+# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
+# end
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted, this block will be run. If you are using the `preload_app!`
+# option, you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, as Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+#
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000000..787824f888
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,3 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 0000000000..eb6904ad4b
--- /dev/null
+++ b/config/secrets.yml
@@ -0,0 +1,32 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rails secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+# Shared secrets are available across all environments.
+
+# shared:
+# api_key: a1B2c3D4e5F6
+
+# Environmental secrets are only available for that specific environment.
+
+development:
+ secret_key_base: 34fb4a95a4674d0975fcd131a3f269c2b709575c4bb992502aaa40db62f58292965df4b9433ae4126e12c20dca1fdaa481ba2c7fdebb919d62cd0d983f2741b5
+
+test:
+ secret_key_base: 1d4ffcfb3ee3e78cae04116f4cc76df3eb789be342ea4bb3e321d58145dbc5eb1b508a0f89254b9009063d62b86e856f67214970c6899af60792928ccd69223f
+
+# Do not keep production secrets in the unencrypted secrets file.
+# Instead, either read values from the environment.
+# Or, use `bin/rails secrets:setup` to configure encrypted secrets
+# and move the `production:` environment over there.
+
+production:
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 0000000000..c9119b40c0
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..1beea2accd
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
diff --git a/lib/assets/.keep b/lib/assets/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000..f874acf437
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "betsy",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/public/404.html b/public/404.html
new file mode 100644
index 0000000000..2be3af26fc
--- /dev/null
+++ b/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/422.html b/public/422.html
new file mode 100644
index 0000000000..c08eac0d1d
--- /dev/null
+++ b/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/500.html b/public/500.html
new file mode 100644
index 0000000000..78a030af22
--- /dev/null
+++ b/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000000..37b576a4a0
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
new file mode 100644
index 0000000000..d19212abd5
--- /dev/null
+++ b/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
+end
diff --git a/test/controllers/.keep b/test/controllers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/.keep b/test/fixtures/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/system/.keep b/test/system/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000000..10594a3248
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,26 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters" # for Colorized output
+
+# For colorful output!
+Minitest::Reporters.use!(
+ Minitest::Reporters::SpecReporter.new,
+ ENV,
+ Minitest.backtrace_filter
+)
+
+
+# To add Capybara feature tests add `gem "minitest-rails-capybara"`
+# to the test group in the Gemfile and uncomment the following:
+# require "minitest/rails/capybara"
+
+# Uncomment for awesome colorful output
+# require "minitest/pride"
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/tmp/.keep b/tmp/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/vendor/.keep b/vendor/.keep
new file mode 100644
index 0000000000..e69de29bb2
From 4eaf5c6586df6da069b9799219589c96749fa3eb Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Wed, 18 Apr 2018 20:39:53 -0700
Subject: [PATCH 002/242] Set up merchant model
---
app/models/merchant.rb | 2 ++
db/migrate/20180419033356_create_merchants.rb | 10 ++++++++++
test/fixtures/merchants.yml | 9 +++++++++
test/models/merchant_test.rb | 9 +++++++++
4 files changed, 30 insertions(+)
create mode 100644 app/models/merchant.rb
create mode 100644 db/migrate/20180419033356_create_merchants.rb
create mode 100644 test/fixtures/merchants.yml
create mode 100644 test/models/merchant_test.rb
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
new file mode 100644
index 0000000000..0440407160
--- /dev/null
+++ b/app/models/merchant.rb
@@ -0,0 +1,2 @@
+class Merchant < ApplicationRecord
+end
diff --git a/db/migrate/20180419033356_create_merchants.rb b/db/migrate/20180419033356_create_merchants.rb
new file mode 100644
index 0000000000..64a57c904c
--- /dev/null
+++ b/db/migrate/20180419033356_create_merchants.rb
@@ -0,0 +1,10 @@
+class CreateMerchants < ActiveRecord::Migration[5.1]
+ def change
+ create_table :merchants do |t|
+ t.string :username
+ t.string :email
+
+ t.timestamps
+ end
+ end
+end
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
new file mode 100644
index 0000000000..7af41d4fbe
--- /dev/null
+++ b/test/fixtures/merchants.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ username: MyString
+ email: MyString
+
+two:
+ username: MyString
+ email: MyString
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
new file mode 100644
index 0000000000..1cc99d985f
--- /dev/null
+++ b/test/models/merchant_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Merchant do
+ let(:merchant) { Merchant.new }
+
+ it "must be valid" do
+ value(merchant).must_be :valid?
+ end
+end
From c48e41a5b9122e44da19a4c6c20434c26857410e Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Wed, 18 Apr 2018 20:41:34 -0700
Subject: [PATCH 003/242] Set up review model
---
app/models/review.rb | 2 ++
db/migrate/20180419034041_create_reviews.rb | 9 +++++++++
test/fixtures/reviews.yml | 7 +++++++
test/models/review_test.rb | 9 +++++++++
4 files changed, 27 insertions(+)
create mode 100644 app/models/review.rb
create mode 100644 db/migrate/20180419034041_create_reviews.rb
create mode 100644 test/fixtures/reviews.yml
create mode 100644 test/models/review_test.rb
diff --git a/app/models/review.rb b/app/models/review.rb
new file mode 100644
index 0000000000..b2ca4935ed
--- /dev/null
+++ b/app/models/review.rb
@@ -0,0 +1,2 @@
+class Review < ApplicationRecord
+end
diff --git a/db/migrate/20180419034041_create_reviews.rb b/db/migrate/20180419034041_create_reviews.rb
new file mode 100644
index 0000000000..f369d1c988
--- /dev/null
+++ b/db/migrate/20180419034041_create_reviews.rb
@@ -0,0 +1,9 @@
+class CreateReviews < ActiveRecord::Migration[5.1]
+ def change
+ create_table :reviews do |t|
+ t.integer :rating
+
+ t.timestamps
+ end
+ end
+end
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..95b7ec8127
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ rating: 1
+
+two:
+ rating: 1
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..ce8378a033
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Review do
+ let(:review) { Review.new }
+
+ it "must be valid" do
+ value(review).must_be :valid?
+ end
+end
From a9074b36b3b4bd13327f3e0ef6b258c37c6c0568 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Wed, 18 Apr 2018 22:08:47 -0700
Subject: [PATCH 004/242] added product and category models and related them
---
app/models/category.rb | 3 ++
app/models/product.rb | 3 ++
db/migrate/20180419044712_create_products.rb | 12 +++++
.../20180419045117_create_categories.rb | 9 ++++
...180419045927_create_products_categories.rb | 8 +++
db/schema.rb | 53 +++++++++++++++++++
test/fixtures/categories.yml | 11 ++++
test/fixtures/products.yml | 11 ++++
test/models/category_test.rb | 9 ++++
test/models/product_test.rb | 9 ++++
10 files changed, 128 insertions(+)
create mode 100644 app/models/category.rb
create mode 100644 app/models/product.rb
create mode 100644 db/migrate/20180419044712_create_products.rb
create mode 100644 db/migrate/20180419045117_create_categories.rb
create mode 100644 db/migrate/20180419045927_create_products_categories.rb
create mode 100644 db/schema.rb
create mode 100644 test/fixtures/categories.yml
create mode 100644 test/fixtures/products.yml
create mode 100644 test/models/category_test.rb
create mode 100644 test/models/product_test.rb
diff --git a/app/models/category.rb b/app/models/category.rb
new file mode 100644
index 0000000000..f3218758f1
--- /dev/null
+++ b/app/models/category.rb
@@ -0,0 +1,3 @@
+class Category < ApplicationRecord
+ has_and_belongs_to_many :products
+end
diff --git a/app/models/product.rb b/app/models/product.rb
new file mode 100644
index 0000000000..fb4f0fbddd
--- /dev/null
+++ b/app/models/product.rb
@@ -0,0 +1,3 @@
+class Product < ApplicationRecord
+ has_and_belongs_to_many :categories
+end
diff --git a/db/migrate/20180419044712_create_products.rb b/db/migrate/20180419044712_create_products.rb
new file mode 100644
index 0000000000..94e1798ebf
--- /dev/null
+++ b/db/migrate/20180419044712_create_products.rb
@@ -0,0 +1,12 @@
+class CreateProducts < ActiveRecord::Migration[5.1]
+ def change
+ create_table :products do |t|
+ t.string :name
+ t.string :stock
+ t.float :price
+ t.text :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419045117_create_categories.rb b/db/migrate/20180419045117_create_categories.rb
new file mode 100644
index 0000000000..5bef4913b8
--- /dev/null
+++ b/db/migrate/20180419045117_create_categories.rb
@@ -0,0 +1,9 @@
+class CreateCategories < ActiveRecord::Migration[5.1]
+ def change
+ create_table :categories do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419045927_create_products_categories.rb b/db/migrate/20180419045927_create_products_categories.rb
new file mode 100644
index 0000000000..cb0a2423f0
--- /dev/null
+++ b/db/migrate/20180419045927_create_products_categories.rb
@@ -0,0 +1,8 @@
+class CreateProductsCategories < ActiveRecord::Migration[5.1]
+ def change
+ create_table :products_categories do |t|
+ t.belongs_to :product, index: true
+ t.belongs_to :category, index: true
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..e72a8a5be4
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,53 @@
+# 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: 20180419045927) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "categories", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "merchants", force: :cascade do |t|
+ t.string "username"
+ t.string "email"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "name"
+ t.string "stock"
+ t.float "price"
+ t.text "description"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "products_categories", force: :cascade do |t|
+ t.bigint "product_id"
+ t.bigint "category_id"
+ t.index ["category_id"], name: "index_products_categories_on_category_id"
+ t.index ["product_id"], name: "index_products_categories_on_product_id"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.integer "rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml
new file mode 100644
index 0000000000..dc3ee79b5d
--- /dev/null
+++ b/test/fixtures/categories.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the "{}" from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
new file mode 100644
index 0000000000..dc3ee79b5d
--- /dev/null
+++ b/test/fixtures/products.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the "{}" from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/category_test.rb b/test/models/category_test.rb
new file mode 100644
index 0000000000..781320ad8e
--- /dev/null
+++ b/test/models/category_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Category do
+ let(:category) { Category.new }
+
+ it "must be valid" do
+ value(category).must_be :valid?
+ end
+end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
new file mode 100644
index 0000000000..a618b0a156
--- /dev/null
+++ b/test/models/product_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Product do
+ let(:product) { Product.new }
+
+ it "must be valid" do
+ value(product).must_be :valid?
+ end
+end
From f4528eb6d81c8cf6dff9ac40b1a939e15845cb19 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Wed, 18 Apr 2018 22:15:27 -0700
Subject: [PATCH 005/242] created db, added order model
---
app/models/order.rb | 2 ++
db/migrate/20180419050820_create_orders.rb | 16 +++++++++++
db/schema.rb | 31 ++++++++++++++++++++++
test/fixtures/orders.yml | 21 +++++++++++++++
test/models/order_test.rb | 9 +++++++
5 files changed, 79 insertions(+)
create mode 100644 app/models/order.rb
create mode 100644 db/migrate/20180419050820_create_orders.rb
create mode 100644 db/schema.rb
create mode 100644 test/fixtures/orders.yml
create mode 100644 test/models/order_test.rb
diff --git a/app/models/order.rb b/app/models/order.rb
new file mode 100644
index 0000000000..10281b3450
--- /dev/null
+++ b/app/models/order.rb
@@ -0,0 +1,2 @@
+class Order < ApplicationRecord
+end
diff --git a/db/migrate/20180419050820_create_orders.rb b/db/migrate/20180419050820_create_orders.rb
new file mode 100644
index 0000000000..dbe01c2067
--- /dev/null
+++ b/db/migrate/20180419050820_create_orders.rb
@@ -0,0 +1,16 @@
+class CreateOrders < ActiveRecord::Migration[5.1]
+ def change
+ create_table :orders do |t|
+ t.string :customer_name
+ t.string :customer_email
+ t.string :credit_card
+ t.string :CVV
+ t.string :CC_expiration
+ t.string :status
+ t.string :shipping_address
+ t.string :billing_address
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..60a45cb2db
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,31 @@
+# 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: 20180419050820) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "orders", force: :cascade do |t|
+ t.string "customer_name"
+ t.string "customer_email"
+ t.string "credit_card"
+ t.string "CVV"
+ t.string "CC_expiration"
+ t.string "status"
+ t.string "shipping_address"
+ t.string "billing_address"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..8fb0410f73
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,21 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ customer_name: MyString
+ customer_email: MyString
+ credit_card: MyString
+ CVV: MyString
+ CC_expiration: MyString
+ status: MyString
+ shipping_address: MyString
+ billing_address: MyString
+
+two:
+ customer_name: MyString
+ customer_email: MyString
+ credit_card: MyString
+ CVV: MyString
+ CC_expiration: MyString
+ status: MyString
+ shipping_address: MyString
+ billing_address: MyString
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..df80f10fb6
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Order do
+ let(:order) { Order.new }
+
+ it "must be valid" do
+ value(order).must_be :valid?
+ end
+end
From 602840305e301c8f60485c4995b1e4de9aad2894 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Wed, 18 Apr 2018 22:39:41 -0700
Subject: [PATCH 006/242] added orderitem model
---
app/models/order_item.rb | 2 ++
db/migrate/20180419053635_create_order_items.rb | 11 +++++++++++
db/schema.rb | 10 +++++++++-
test/fixtures/order_items.yml | 11 +++++++++++
test/models/order_item_test.rb | 9 +++++++++
5 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 app/models/order_item.rb
create mode 100644 db/migrate/20180419053635_create_order_items.rb
create mode 100644 test/fixtures/order_items.yml
create mode 100644 test/models/order_item_test.rb
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
new file mode 100644
index 0000000000..acc6099fd0
--- /dev/null
+++ b/app/models/order_item.rb
@@ -0,0 +1,2 @@
+class OrderItem < ApplicationRecord
+end
diff --git a/db/migrate/20180419053635_create_order_items.rb b/db/migrate/20180419053635_create_order_items.rb
new file mode 100644
index 0000000000..1b14bf865b
--- /dev/null
+++ b/db/migrate/20180419053635_create_order_items.rb
@@ -0,0 +1,11 @@
+class CreateOrderItems < ActiveRecord::Migration[5.1]
+ def change
+ create_table :order_items do |t|
+ t.integer :quantity
+ t.integer :product_id
+ t.integer :order_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 60a45cb2db..d7b447755f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,11 +10,19 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180419050820) do
+ActiveRecord::Schema.define(version: 20180419053635) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "order_items", force: :cascade do |t|
+ t.integer "quantity"
+ t.integer "product_id"
+ t.integer "order_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "orders", force: :cascade do |t|
t.string "customer_name"
t.string "customer_email"
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
new file mode 100644
index 0000000000..1cb6079d5a
--- /dev/null
+++ b/test/fixtures/order_items.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ quantity: 1
+ product_id: 1
+ order_id: 1
+
+two:
+ quantity: 1
+ product_id: 1
+ order_id: 1
diff --git a/test/models/order_item_test.rb b/test/models/order_item_test.rb
new file mode 100644
index 0000000000..19a9bf8f58
--- /dev/null
+++ b/test/models/order_item_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe OrderItem do
+ let(:order_item) { OrderItem.new }
+
+ it "must be valid" do
+ value(order_item).must_be :valid?
+ end
+end
From 749592efa2c7b1c6b2645203861f5a9a13792bd1 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Thu, 19 Apr 2018 09:55:03 -0700
Subject: [PATCH 007/242] reset db - schema up to date
---
db/schema.rb | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/db/schema.rb b/db/schema.rb
index e72a8a5be4..f4dde6e2e5 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.define(version: 20180419045927) do
+ActiveRecord::Schema.define(version: 20180419053635) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -28,6 +28,27 @@
t.datetime "updated_at", null: false
end
+ create_table "order_items", force: :cascade do |t|
+ t.integer "quantity"
+ t.integer "product_id"
+ t.integer "order_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "orders", force: :cascade do |t|
+ t.string "customer_name"
+ t.string "customer_email"
+ t.string "credit_card"
+ t.string "CVV"
+ t.string "CC_expiration"
+ t.string "status"
+ t.string "shipping_address"
+ t.string "billing_address"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "products", force: :cascade do |t|
t.string "name"
t.string "stock"
From c53610894421622b455f60904f755b7aacdffc98 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 10:00:29 -0700
Subject: [PATCH 008/242] Update schema
---
db/schema.rb | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 db/schema.rb
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..35f829cd04
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,31 @@
+# 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: 20180419034041) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "merchants", force: :cascade do |t|
+ t.string "username"
+ t.string "email"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.integer "rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
From db420685803dcab36af49e58a6188ec7d8d3c3aa Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 13:56:25 -0700
Subject: [PATCH 009/242] added merchant and product relations
---
db/migrate/20180419171654_add_merchant_id_to_products.rb | 5 +++++
db/migrate/20180419171936_product_id_to_reviews.rb | 5 +++++
db/migrate/20180419172655_add_product_to_order_item.rb | 4 ++++
db/schema.rb | 5 ++++-
4 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 db/migrate/20180419171654_add_merchant_id_to_products.rb
create mode 100644 db/migrate/20180419171936_product_id_to_reviews.rb
create mode 100644 db/migrate/20180419172655_add_product_to_order_item.rb
diff --git a/db/migrate/20180419171654_add_merchant_id_to_products.rb b/db/migrate/20180419171654_add_merchant_id_to_products.rb
new file mode 100644
index 0000000000..45930fd0d9
--- /dev/null
+++ b/db/migrate/20180419171654_add_merchant_id_to_products.rb
@@ -0,0 +1,5 @@
+class AddMerchantIdToProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :products, :merchant, foreign_key: true
+ end
+end
diff --git a/db/migrate/20180419171936_product_id_to_reviews.rb b/db/migrate/20180419171936_product_id_to_reviews.rb
new file mode 100644
index 0000000000..58e4c7b6dd
--- /dev/null
+++ b/db/migrate/20180419171936_product_id_to_reviews.rb
@@ -0,0 +1,5 @@
+class ProductIdToReviews < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :reviews, :product, foreign_key: true
+ end
+end
diff --git a/db/migrate/20180419172655_add_product_to_order_item.rb b/db/migrate/20180419172655_add_product_to_order_item.rb
new file mode 100644
index 0000000000..19f5207f78
--- /dev/null
+++ b/db/migrate/20180419172655_add_product_to_order_item.rb
@@ -0,0 +1,4 @@
+class AddProductToOrderItem < ActiveRecord::Migration[5.1]
+ def change
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f4dde6e2e5..d0633d95bd 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.define(version: 20180419053635) do
+ActiveRecord::Schema.define(version: 20180419171654) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -56,6 +56,8 @@
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "merchant_id"
+ t.index ["merchant_id"], name: "index_products_on_merchant_id"
end
create_table "products_categories", force: :cascade do |t|
@@ -71,4 +73,5 @@
t.datetime "updated_at", null: false
end
+ add_foreign_key "products", "merchants"
end
From 5027364c99cf70a61a86ecf00557b9180d00b7a0 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 14:06:57 -0700
Subject: [PATCH 010/242] added relations from product to order-item and order
to order-item
---
.../20180419171936_product_id_to_reviews.rb | 5 +++++
.../20180419172655_add_product_to_order_item.rb | 6 ++++++
.../20180419210206_add_orderto_order_items.rb | 7 +++++++
db/schema.rb | 16 +++++++++++++---
4 files changed, 31 insertions(+), 3 deletions(-)
create mode 100644 db/migrate/20180419171936_product_id_to_reviews.rb
create mode 100644 db/migrate/20180419172655_add_product_to_order_item.rb
create mode 100644 db/migrate/20180419210206_add_orderto_order_items.rb
diff --git a/db/migrate/20180419171936_product_id_to_reviews.rb b/db/migrate/20180419171936_product_id_to_reviews.rb
new file mode 100644
index 0000000000..58e4c7b6dd
--- /dev/null
+++ b/db/migrate/20180419171936_product_id_to_reviews.rb
@@ -0,0 +1,5 @@
+class ProductIdToReviews < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :reviews, :product, foreign_key: true
+ end
+end
diff --git a/db/migrate/20180419172655_add_product_to_order_item.rb b/db/migrate/20180419172655_add_product_to_order_item.rb
new file mode 100644
index 0000000000..3672da38ca
--- /dev/null
+++ b/db/migrate/20180419172655_add_product_to_order_item.rb
@@ -0,0 +1,6 @@
+class AddProductToOrderItem < ActiveRecord::Migration[5.1]
+ def change
+ remove_column :order_items, :product_id, :integer
+ add_reference :order_items, :product, foreign_key: true
+ end
+end
diff --git a/db/migrate/20180419210206_add_orderto_order_items.rb b/db/migrate/20180419210206_add_orderto_order_items.rb
new file mode 100644
index 0000000000..e85143d2bf
--- /dev/null
+++ b/db/migrate/20180419210206_add_orderto_order_items.rb
@@ -0,0 +1,7 @@
+class AddOrdertoOrderItems < ActiveRecord::Migration[5.1]
+ def change
+ remove_column :order_items, :order_id, :integer
+
+ add_reference :order_items, :order, foreign_key: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f4dde6e2e5..fea17c2db7 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.define(version: 20180419053635) do
+ActiveRecord::Schema.define(version: 20180419210206) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -30,10 +30,12 @@
create_table "order_items", force: :cascade do |t|
t.integer "quantity"
- t.integer "product_id"
- t.integer "order_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "product_id"
+ t.bigint "order_id"
+ t.index ["order_id"], name: "index_order_items_on_order_id"
+ t.index ["product_id"], name: "index_order_items_on_product_id"
end
create_table "orders", force: :cascade do |t|
@@ -56,6 +58,8 @@
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "merchant_id"
+ t.index ["merchant_id"], name: "index_products_on_merchant_id"
end
create_table "products_categories", force: :cascade do |t|
@@ -69,6 +73,12 @@
t.integer "rating"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "product_id"
+ t.index ["product_id"], name: "index_reviews_on_product_id"
end
+ add_foreign_key "order_items", "orders"
+ add_foreign_key "order_items", "products"
+ add_foreign_key "products", "merchants"
+ add_foreign_key "reviews", "products"
end
From 2aed1559207f8ccd8e816f2b7c52600a41642535 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:09:07 -0700
Subject: [PATCH 011/242] Merge schema changes
---
db/schema.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/db/schema.rb b/db/schema.rb
index d0633d95bd..c83174ee15 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.define(version: 20180419171654) do
+ActiveRecord::Schema.define(version: 20180419172655) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -71,7 +71,10 @@
t.integer "rating"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "product_id"
+ t.index ["product_id"], name: "index_reviews_on_product_id"
end
add_foreign_key "products", "merchants"
+ add_foreign_key "reviews", "products"
end
From b1da66c6e5a7b1ede093437778926db507d9d48e Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:13:43 -0700
Subject: [PATCH 012/242] Test Merchant model validations
---
app/models/merchant.rb | 3 +++
test/fixtures/merchants.yml | 10 +++------
test/models/merchant_test.rb | 43 ++++++++++++++++++++++++++++++++----
3 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
index 0440407160..ce74e80512 100644
--- a/app/models/merchant.rb
+++ b/app/models/merchant.rb
@@ -1,2 +1,5 @@
class Merchant < ApplicationRecord
+ validates :username, presence: true, uniqueness: true
+
+ validates :email, presence: true, uniqueness: true
end
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
index 7af41d4fbe..f6dd8456c4 100644
--- a/test/fixtures/merchants.yml
+++ b/test/fixtures/merchants.yml
@@ -1,9 +1,5 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-one:
- username: MyString
- email: MyString
-
-two:
- username: MyString
- email: MyString
+merchant_one:
+ username: merchant_one
+ email: merchant_one@example.com
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
index 1cc99d985f..c5494c5f1d 100644
--- a/test/models/merchant_test.rb
+++ b/test/models/merchant_test.rb
@@ -1,9 +1,44 @@
require "test_helper"
describe Merchant do
- let(:merchant) { Merchant.new }
+ describe "validations" do
- it "must be valid" do
- value(merchant).must_be :valid?
- end
+ it "must have a unique username" do
+ # arrange
+ merchant = Merchant.first
+ old_merchant_count = Merchant.count
+
+ new_merchant = Merchant.new(username: merchant.username, email: "address@example.com")
+
+ # assumptions
+ new_merchant.wont_be :valid?
+
+ # act
+ new_merchant.save
+
+ # assert
+ Merchant.count.must_equal old_merchant_count
+ end
+
+ it "must have a unique email" do
+ # arrange
+ merchant = Merchant.first
+ old_merchant_count = Merchant.count
+
+ new_merchant = Merchant.new(username: "example_username", email: merchant.email)
+
+ # assumptions
+ new_merchant.wont_be :valid?
+
+ # act
+ new_merchant.save
+
+ # assert
+ Merchant.count.must_equal old_merchant_count
+ end
+
+ end # validations
+
+ describe "relations" do
+ end # relations
end
From 8ef397628e23bd8b16f1bfe4fbbad28307eb2d65 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 14:15:16 -0700
Subject: [PATCH 013/242] added ruby relations to models
---
app/models/merchant.rb | 1 +
app/models/order.rb | 2 ++
app/models/order_item.rb | 2 ++
app/models/product.rb | 4 ++++
app/models/review.rb | 1 +
5 files changed, 10 insertions(+)
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
index 0440407160..07aacc445d 100644
--- a/app/models/merchant.rb
+++ b/app/models/merchant.rb
@@ -1,2 +1,3 @@
class Merchant < ApplicationRecord
+ has_many :products
end
diff --git a/app/models/order.rb b/app/models/order.rb
index 10281b3450..b36051f45f 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -1,2 +1,4 @@
class Order < ApplicationRecord
+ has_many :order_items
+ has_many :products, through: :order_items
end
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index acc6099fd0..eecf9e7ebf 100644
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -1,2 +1,4 @@
class OrderItem < ApplicationRecord
+ belongs_to :product
+ belongs_to :order
end
diff --git a/app/models/product.rb b/app/models/product.rb
index fb4f0fbddd..45ff6731f4 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,3 +1,7 @@
class Product < ApplicationRecord
has_and_belongs_to_many :categories
+ has_many :reviews
+ belongs_to :merchant
+ has_many :order_items
+ has_many :orders, through: :order_items
end
diff --git a/app/models/review.rb b/app/models/review.rb
index b2ca4935ed..949d4ccddb 100644
--- a/app/models/review.rb
+++ b/app/models/review.rb
@@ -1,2 +1,3 @@
class Review < ApplicationRecord
+ belongs_to :product
end
From dc3ab0460bcbfbfcb77103eec9bb3535e320f659 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:19:49 -0700
Subject: [PATCH 014/242] Test Merchant model relations
---
app/models/merchant.rb | 2 ++
test/models/merchant_test.rb | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
index ce74e80512..2ecc991a66 100644
--- a/app/models/merchant.rb
+++ b/app/models/merchant.rb
@@ -1,4 +1,6 @@
class Merchant < ApplicationRecord
+ has_many :products
+
validates :username, presence: true, uniqueness: true
validates :email, presence: true, uniqueness: true
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
index c5494c5f1d..075528ae62 100644
--- a/test/models/merchant_test.rb
+++ b/test/models/merchant_test.rb
@@ -40,5 +40,16 @@
end # validations
describe "relations" do
+
+ it "connects product and product_id" do
+ merchant = Merchant.first
+
+ product = Product.first
+
+ product.merchant = merchant
+
+ product.merchant_id.must_equal merchant.id
+ end
+
end # relations
end
From c53bdb306fcdb80a7827bb2f6d7dae7606981251 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:25:20 -0700
Subject: [PATCH 015/242] Merge changes to schema involving relations set up
---
db/schema.rb | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/db/schema.rb b/db/schema.rb
index fea17c2db7..cd6233987a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -30,12 +30,11 @@
create_table "order_items", force: :cascade do |t|
t.integer "quantity"
+ t.integer "product_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.bigint "product_id"
t.bigint "order_id"
t.index ["order_id"], name: "index_order_items_on_order_id"
- t.index ["product_id"], name: "index_order_items_on_product_id"
end
create_table "orders", force: :cascade do |t|
@@ -78,7 +77,6 @@
end
add_foreign_key "order_items", "orders"
- add_foreign_key "order_items", "products"
add_foreign_key "products", "merchants"
add_foreign_key "reviews", "products"
end
From cd975424a83c10c4e7e36eb6c66bc0fde2a0c467 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:35:36 -0700
Subject: [PATCH 016/242] Update Review model to include description
---
db/migrate/20180419213238_add_description_to_review.rb | 5 +++++
db/schema.rb | 7 +++++--
2 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 db/migrate/20180419213238_add_description_to_review.rb
diff --git a/db/migrate/20180419213238_add_description_to_review.rb b/db/migrate/20180419213238_add_description_to_review.rb
new file mode 100644
index 0000000000..4c7de16c49
--- /dev/null
+++ b/db/migrate/20180419213238_add_description_to_review.rb
@@ -0,0 +1,5 @@
+class AddDescriptionToReview < ActiveRecord::Migration[5.1]
+ def change
+ add_column :reviews, :description, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c83174ee15..22bd53ef3a 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.define(version: 20180419172655) do
+ActiveRecord::Schema.define(version: 20180419213238) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -31,9 +31,10 @@
create_table "order_items", force: :cascade do |t|
t.integer "quantity"
t.integer "product_id"
- t.integer "order_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "order_id"
+ t.index ["order_id"], name: "index_order_items_on_order_id"
end
create_table "orders", force: :cascade do |t|
@@ -72,9 +73,11 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "product_id"
+ t.text "description"
t.index ["product_id"], name: "index_reviews_on_product_id"
end
+ add_foreign_key "order_items", "orders"
add_foreign_key "products", "merchants"
add_foreign_key "reviews", "products"
end
From ed0e75f9174abb95cf58f1b27df2a205c0661860 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 14:36:04 -0700
Subject: [PATCH 017/242] added fixture data for products and categories
---
test/fixtures/categories.yml | 11 ++++++-----
test/fixtures/merchants.yml | 10 +++-------
test/fixtures/products.yml | 19 ++++++++++++++-----
test/models/product_test.rb | 8 ++++----
4 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml
index dc3ee79b5d..492f2445ef 100644
--- a/test/fixtures/categories.yml
+++ b/test/fixtures/categories.yml
@@ -4,8 +4,9 @@
# model remove the "{}" from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
-one: {}
-# column: value
-#
-two: {}
-# column: value
+
+memorabilia:
+ name: memorabilia
+
+awesome:
+ name: awesome
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
index 7af41d4fbe..f6dd8456c4 100644
--- a/test/fixtures/merchants.yml
+++ b/test/fixtures/merchants.yml
@@ -1,9 +1,5 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-one:
- username: MyString
- email: MyString
-
-two:
- username: MyString
- email: MyString
+merchant_one:
+ username: merchant_one
+ email: merchant_one@example.com
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
index dc3ee79b5d..06f50a559f 100644
--- a/test/fixtures/products.yml
+++ b/test/fixtures/products.yml
@@ -4,8 +4,17 @@
# model remove the "{}" from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
-one: {}
-# column: value
-#
-two: {}
-# column: value
+
+batarang:
+ name: Batarang
+ stock: 3
+ price: 40.00
+ description: The only weapon you'll ever need.
+ merchant: merchant_one
+
+lasso:
+ name: Lasso of Truth
+ stock: 10
+ price: 234.99
+ description: Lasso
+ merchant: merchant_one
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
index a618b0a156..82005cd85d 100644
--- a/test/models/product_test.rb
+++ b/test/models/product_test.rb
@@ -1,9 +1,9 @@
require "test_helper"
describe Product do
- let(:product) { Product.new }
-
- it "must be valid" do
- value(product).must_be :valid?
+ describe 'relations' do
+ it 'has a list of categories' do
+ product = products(:batarang)
+ end
end
end
From 4037e4d7b62027b3ac958913321f6abf4970781d Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 14:36:40 -0700
Subject: [PATCH 018/242] Update Review model to include description
---
db/migrate/20180419213238_add_description_to_review.rb | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 db/migrate/20180419213238_add_description_to_review.rb
diff --git a/db/migrate/20180419213238_add_description_to_review.rb b/db/migrate/20180419213238_add_description_to_review.rb
new file mode 100644
index 0000000000..4c7de16c49
--- /dev/null
+++ b/db/migrate/20180419213238_add_description_to_review.rb
@@ -0,0 +1,5 @@
+class AddDescriptionToReview < ActiveRecord::Migration[5.1]
+ def change
+ add_column :reviews, :description, :text
+ end
+end
From 3a5034092bf04ff1a8ff54557209936ea0616ef3 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 14:39:37 -0700
Subject: [PATCH 019/242] updated category fixture
---
test/fixtures/products.yml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
index 06f50a559f..807fc25ff2 100644
--- a/test/fixtures/products.yml
+++ b/test/fixtures/products.yml
@@ -11,6 +11,9 @@ batarang:
price: 40.00
description: The only weapon you'll ever need.
merchant: merchant_one
+ categories:
+ - memorabilia
+ - awesome
lasso:
name: Lasso of Truth
@@ -18,3 +21,6 @@ lasso:
price: 234.99
description: Lasso
merchant: merchant_one
+ categories:
+ - memorabilia
+ - awesome
From 2c18d6fc89bd843c883baa0735bf29a585bbbfec Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Thu, 19 Apr 2018 14:41:32 -0700
Subject: [PATCH 020/242] added in stubs for order model testing; built order
fixtures
---
test/fixtures/merchants.yml | 10 +++-------
test/fixtures/orders.yml | 32 ++++++++++++++++----------------
test/models/order_test.rb | 14 +++++++++++---
3 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
index 7af41d4fbe..f6dd8456c4 100644
--- a/test/fixtures/merchants.yml
+++ b/test/fixtures/merchants.yml
@@ -1,9 +1,5 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-one:
- username: MyString
- email: MyString
-
-two:
- username: MyString
- email: MyString
+merchant_one:
+ username: merchant_one
+ email: merchant_one@example.com
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
index 8fb0410f73..3218155976 100644
--- a/test/fixtures/orders.yml
+++ b/test/fixtures/orders.yml
@@ -1,21 +1,21 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- customer_name: MyString
- customer_email: MyString
- credit_card: MyString
- CVV: MyString
- CC_expiration: MyString
- status: MyString
- shipping_address: MyString
- billing_address: MyString
+ customer_name: Peter Parker
+ customer_email: iluvheros@fan.net
+ credit_card: 1234567891011121
+ CVV: 987
+ CC_expiration: 09/35
+ status: pending
+ shipping_address: 1234 Lovelace Ave Seattle WA 98103
+ billing_address: 98103
two:
- customer_name: MyString
- customer_email: MyString
- credit_card: MyString
- CVV: MyString
- CC_expiration: MyString
- status: MyString
- shipping_address: MyString
- billing_address: MyString
+ customer_name: Jane Foster
+ customer_email: desertphenom@smartypants.com
+ credit_card: 9876543210111213
+ CVV: 786
+ CC_expiration: 03/23
+ status: pending
+ shipping_address: 109 Desert Road Nowhere AZ 29843
+ billing_address: 29843
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
index df80f10fb6..9766b78ef3 100644
--- a/test/models/order_test.rb
+++ b/test/models/order_test.rb
@@ -1,9 +1,17 @@
require "test_helper"
describe Order do
- let(:order) { Order.new }
+ it 'is valid with one order item' do
+
+ end
+
+ it 'is valid with multiple order items' do
+
+ end
+
+ it 'is not valid with 0 order items' do
+
+ end
- it "must be valid" do
- value(order).must_be :valid?
end
end
From ae37e21faf5510cd9a6b2d06ecd0298516f88d3c Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Thu, 19 Apr 2018 14:47:16 -0700
Subject: [PATCH 021/242] added in OrderItem fixtures
---
test/fixtures/order_items.yml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
index 1cb6079d5a..dd855d1e95 100644
--- a/test/fixtures/order_items.yml
+++ b/test/fixtures/order_items.yml
@@ -2,10 +2,10 @@
one:
quantity: 1
- product_id: 1
- order_id: 1
+ product: batarang
+ order: one
two:
- quantity: 1
- product_id: 1
- order_id: 1
+ quantity: 2
+ product: lasso
+ order: two
From 6c01d1489488e2fddaff7936443d361af86271ec Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 15:12:05 -0700
Subject: [PATCH 022/242] Test Merchant model relations
---
app/models/category.rb | 2 +-
app/models/merchant.rb | 3 ---
app/models/product.rb | 2 +-
db/schema.rb | 2 +-
test/models/merchant_test.rb | 8 ++++++--
test/models/review_test.rb | 17 +++++++++++++----
6 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/app/models/category.rb b/app/models/category.rb
index f3218758f1..4f685d9be9 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -1,3 +1,3 @@
class Category < ApplicationRecord
- has_and_belongs_to_many :products
+ has_and_belongs_to_many :products, join_table: :products_categories
end
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
index 3c77ef37ab..2ecc991a66 100644
--- a/app/models/merchant.rb
+++ b/app/models/merchant.rb
@@ -1,10 +1,7 @@
class Merchant < ApplicationRecord
has_many :products
-<<<<<<< HEAD
validates :username, presence: true, uniqueness: true
validates :email, presence: true, uniqueness: true
-=======
->>>>>>> master
end
diff --git a/app/models/product.rb b/app/models/product.rb
index 45ff6731f4..a8f3b612ac 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,5 +1,5 @@
class Product < ApplicationRecord
- has_and_belongs_to_many :categories
+ has_and_belongs_to_many :categories, join_table: :products_categories
has_many :reviews
belongs_to :merchant
has_many :order_items
diff --git a/db/schema.rb b/db/schema.rb
index abda418c4b..22bd53ef3a 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.define(version: 20180419210206) do
+ActiveRecord::Schema.define(version: 20180419213238) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
index 075528ae62..702f8cb1d0 100644
--- a/test/models/merchant_test.rb
+++ b/test/models/merchant_test.rb
@@ -44,11 +44,15 @@
it "connects product and product_id" do
merchant = Merchant.first
- product = Product.first
+ product = Product.new(name: "Green Lantern Ring", stock: 1, price: 57.00)
+ # act
product.merchant = merchant
+ product.must_be :valid?
+
+ product.save
- product.merchant_id.must_equal merchant.id
+ merchant.product_ids.must_include product.id
end
end # relations
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
index ce8378a033..ee549db550 100644
--- a/test/models/review_test.rb
+++ b/test/models/review_test.rb
@@ -1,9 +1,18 @@
require "test_helper"
describe Review do
- let(:review) { Review.new }
+ describe "validations" do
- it "must be valid" do
- value(review).must_be :valid?
- end
+ it "must have a rating" do
+
+ end
+
+ # rating must be an integer
+
+ # rating must be between 1 and 5 inclusive
+
+ end # validations
+
+ describe "relations" do
+ end # relations
end
From 8b380930d5f4c91aae8dd0f7b38550ce29fa82d7 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Thu, 19 Apr 2018 15:22:00 -0700
Subject: [PATCH 023/242] added in order model testing
---
app/models/category.rb | 2 +-
app/models/order.rb | 2 ++
app/models/product.rb | 2 +-
test/models/order_test.rb | 28 ++++++++++++++++++++++------
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/app/models/category.rb b/app/models/category.rb
index f3218758f1..4f685d9be9 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -1,3 +1,3 @@
class Category < ApplicationRecord
- has_and_belongs_to_many :products
+ has_and_belongs_to_many :products, join_table: :products_categories
end
diff --git a/app/models/order.rb b/app/models/order.rb
index b36051f45f..e62d87a728 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -1,4 +1,6 @@
class Order < ApplicationRecord
has_many :order_items
has_many :products, through: :order_items
+
+ validates :order_items, :length => { :minimum => 1 }
end
diff --git a/app/models/product.rb b/app/models/product.rb
index 45ff6731f4..a8f3b612ac 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,5 +1,5 @@
class Product < ApplicationRecord
- has_and_belongs_to_many :categories
+ has_and_belongs_to_many :categories, join_table: :products_categories
has_many :reviews
belongs_to :merchant
has_many :order_items
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
index 9766b78ef3..7af52ef5ca 100644
--- a/test/models/order_test.rb
+++ b/test/models/order_test.rb
@@ -1,17 +1,33 @@
require "test_helper"
describe Order do
- it 'is valid with one order item' do
+ describe 'validations' do
+ it 'is valid with one order item' do
+ order_item = OrderItem.first
+ order = Order.new
+ order.valid?.must_equal false
+ order.order_items.push(order_item)
- end
+ order.valid?.must_equal true
- it 'is valid with multiple order items' do
+ end
- end
+ it 'is valid with multiple order items' do
+ order_item_1 = OrderItem.first
+ order_item_2 = OrderItem.last
+ order = Order.new
+ order.valid?.must_equal false
+ order.order_items.push(order_item_1, order_item_2)
- it 'is not valid with 0 order items' do
+ order.valid?.must_equal true
+ end
- end
+ it 'is not valid with 0 order items' do
+ order = Order.new
+ order.valid?.must_equal false
+
+ order.errors.messages.must_include :order_items
+ end
end
end
From 5ba0974f7124dcc53caa769bbefad37929343ca2 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 15:29:02 -0700
Subject: [PATCH 024/242] Test Review model validations and relations
---
app/models/review.rb | 2 ++
test/models/review_test.rb | 41 +++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/app/models/review.rb b/app/models/review.rb
index 949d4ccddb..0c8753826d 100644
--- a/app/models/review.rb
+++ b/app/models/review.rb
@@ -1,3 +1,5 @@
class Review < ApplicationRecord
belongs_to :product
+
+ validates :rating, presence: true, numericality: { only_integer: true, greater_than: 0, less_than: 6 }
end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
index ee549db550..e1a5999a4f 100644
--- a/test/models/review_test.rb
+++ b/test/models/review_test.rb
@@ -2,17 +2,52 @@
describe Review do
describe "validations" do
+ before do
+ @old_review_count = Review.count
+ @review = Review.new()
+ @review.product = Product.first
+ end
it "must have a rating" do
-
+ @review.wont_be :valid?
+ @review.save
+ Review.count.must_equal @old_review_count
end
- # rating must be an integer
+ it "must have a rating that's an integer" do
+ @review.rating = "a"
+ @review.wont_be :valid?
+ @review.save
+ Review.count.must_equal @old_review_count
+ end
- # rating must be between 1 and 5 inclusive
+ it "must have a rating that is greater than 0" do
+ @review.rating = 0
+ @review.wont_be :valid?
+ @review.save
+ Review.count.must_equal @old_review_count
+ end
+
+ it "must have a rating that is less than 6" do
+ @review.rating = 6
+ @review.wont_be :valid?
+ @review.save
+ Review.count.must_equal @old_review_count
+ end
end # validations
describe "relations" do
+
+ it "connects product and product id" do
+ review = Review.new(rating: 3)
+ review.product = Product.first
+
+ review.must_be :valid?
+ review.save
+
+ review.product_id.must_equal Product.first.id
+ end
+
end # relations
end
From 3077c92a912d70e7f1ce9c74184c1e9828afe64a Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 19:37:36 -0700
Subject: [PATCH 025/242] Set up Orders controller
---
app/assets/javascripts/orders.js | 2 ++
app/assets/stylesheets/orders.scss | 3 +++
app/controllers/orders_controller.rb | 2 ++
app/helpers/orders_helper.rb | 2 ++
test/controllers/orders_controller_test.rb | 7 +++++++
5 files changed, 16 insertions(+)
create mode 100644 app/assets/javascripts/orders.js
create mode 100644 app/assets/stylesheets/orders.scss
create mode 100644 app/controllers/orders_controller.rb
create mode 100644 app/helpers/orders_helper.rb
create mode 100644 test/controllers/orders_controller_test.rb
diff --git a/app/assets/javascripts/orders.js b/app/assets/javascripts/orders.js
new file mode 100644
index 0000000000..dee720facd
--- /dev/null
+++ b/app/assets/javascripts/orders.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/orders.scss b/app/assets/stylesheets/orders.scss
new file mode 100644
index 0000000000..741506954d
--- /dev/null
+++ b/app/assets/stylesheets/orders.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Orders 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/orders_controller.rb b/app/controllers/orders_controller.rb
new file mode 100644
index 0000000000..8a0e3659ae
--- /dev/null
+++ b/app/controllers/orders_controller.rb
@@ -0,0 +1,2 @@
+class OrdersController < ApplicationController
+end
diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb
new file mode 100644
index 0000000000..443227fd48
--- /dev/null
+++ b/app/helpers/orders_helper.rb
@@ -0,0 +1,2 @@
+module OrdersHelper
+end
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
new file mode 100644
index 0000000000..68784595f3
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe OrdersController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
From ab95f9d215dc408327b792f85e564663865ea017 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 22:22:06 -0700
Subject: [PATCH 026/242] Write and test orders#create
---
app/controllers/orders_controller.rb | 31 ++++++++++++++++++++++
app/models/order.rb | 2 +-
config/routes.rb | 5 ++++
test/controllers/orders_controller_test.rb | 18 ++++++++++---
4 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index 8a0e3659ae..dec432d7f0 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -1,2 +1,33 @@
class OrdersController < ApplicationController
+
+ def index
+ end
+ #
+ # def show
+ # end
+ #
+ # def new
+ # end
+ #
+ def create
+ order = Order.new
+
+ if order.save
+ flash[:success] = "You have opened up a cart!"
+ redirect_back(fallback_location: root_path)
+ else
+ flash[:failure] = "Could not open up a cart."
+ redirect_back(fallback_location: root_path)
+ end
+ end
+ #
+ # def edit
+ # end
+ #
+ # def update
+ # end
+ #
+ # def destroy
+ # end
+
end
diff --git a/app/models/order.rb b/app/models/order.rb
index e62d87a728..bdbad7bcf2 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -2,5 +2,5 @@ class Order < ApplicationRecord
has_many :order_items
has_many :products, through: :order_items
- validates :order_items, :length => { :minimum => 1 }
+ # validates :order_items, :length => { :minimum => 1 }
end
diff --git a/config/routes.rb b/config/routes.rb
index 787824f888..ebae38af77 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,8 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+ root 'orders#index'
+
+ resources :orders
+
end
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
index 68784595f3..d295e4087f 100644
--- a/test/controllers/orders_controller_test.rb
+++ b/test/controllers/orders_controller_test.rb
@@ -1,7 +1,19 @@
require "test_helper"
describe OrdersController do
- # it "must be a real test" do
- # flunk "Need real tests"
- # end
+
+ describe "create" do
+
+ it 'adds a valid order' do
+ old_order_count = Order.count
+
+ post orders_path
+
+ must_respond_with :redirect
+ # must redirect to same path as before
+
+ Order.count.must_equal old_order_count + 1
+ end
+
+ end # create
end
From f5b4fa4a2c376e98c56d62ae3e0e7215bcfbdc63 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 22:27:43 -0700
Subject: [PATCH 027/242] product validation tests
---
app/models/category.rb | 2 +-
app/models/product.rb | 5 +++-
test/models/category_test.rb | 12 +++++++---
test/models/product_test.rb | 46 ++++++++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/app/models/category.rb b/app/models/category.rb
index f3218758f1..4f685d9be9 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -1,3 +1,3 @@
class Category < ApplicationRecord
- has_and_belongs_to_many :products
+ has_and_belongs_to_many :products, join_table: :products_categories
end
diff --git a/app/models/product.rb b/app/models/product.rb
index 45ff6731f4..597520cb24 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,7 +1,10 @@
class Product < ApplicationRecord
- has_and_belongs_to_many :categories
+ has_and_belongs_to_many :categories, join_table: :products_categories
has_many :reviews
belongs_to :merchant
has_many :order_items
has_many :orders, through: :order_items
+
+ validates :name, presence: true, uniqueness: true
+ # validates :price, presence: true, numericality: {greater_than: 0, only_number: true}
end
diff --git a/test/models/category_test.rb b/test/models/category_test.rb
index 781320ad8e..0717b8c3e8 100644
--- a/test/models/category_test.rb
+++ b/test/models/category_test.rb
@@ -1,9 +1,15 @@
require "test_helper"
describe Category do
- let(:category) { Category.new }
+ describe 'relations' do
+ it 'connects category and products' do
+ product = Product.first
- it "must be valid" do
- value(category).must_be :valid?
+ category = Category.new(name: 'Accessories')
+ category.products.push(product)
+
+ category.valid?.must_equal true
+ category.products.must_include product
+ end
end
end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
index 82005cd85d..8331479ad9 100644
--- a/test/models/product_test.rb
+++ b/test/models/product_test.rb
@@ -2,8 +2,54 @@
describe Product do
describe 'relations' do
+ let (:product) { Product.new(name: 'Action Figure', stock: 3, price: 2.99, merchant: merchants(:merchant_one)) }
+
it 'has a list of categories' do
product = products(:batarang)
+
+ product.must_respond_to :categories
+
+ product.categories.each do |category|
+ category.must_be_kind_of Category
+ end
+ end
+
+ it 'connects categories and products' do
+ category = Category.first
+
+ product.categories.push(category)
+
+ product.valid?.must_equal true
+
+ product.categories.must_include category
+ end
+
+
+ it 'connects products and merchants' do
+ merchant = Merchant.first
+
+ product = Product.new(name: 'Green Hair Dye', stock: 24, price: 8.99, merchant_id: merchant.id)
+
+ product.merchant_id.must_equal merchant.id
+ end
+ end
+
+ describe 'validations' do
+ it 'cannot be created without a name' do
+ merchant = Merchant.first
+ categories = [Category.first]
+
+ product_data = {
+ stock: 1,
+ price: 1.99,
+ merchant_id: merchant.id,
+ categories: categories
+ }
+
+ product = Product.new(product_data)
+
+ product.valid?.must_equal false
+ product.error.messages.must_include :name
end
end
end
From e57182b566c861219cb9e7d74b6b444fde4e353b Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Thu, 19 Apr 2018 22:49:56 -0700
Subject: [PATCH 028/242] added orderitems controller; added restful routes for
orderitems
---
app/assets/javascripts/orderitems.js | 2 ++
app/assets/stylesheets/orderitems.scss | 3 +++
app/controllers/orderitems_controller.rb | 4 ++++
app/helpers/orderitems_helper.rb | 2 ++
config/routes.rb | 3 +++
test/controllers/orderitems_controller_test.rb | 7 +++++++
6 files changed, 21 insertions(+)
create mode 100644 app/assets/javascripts/orderitems.js
create mode 100644 app/assets/stylesheets/orderitems.scss
create mode 100644 app/controllers/orderitems_controller.rb
create mode 100644 app/helpers/orderitems_helper.rb
create mode 100644 test/controllers/orderitems_controller_test.rb
diff --git a/app/assets/javascripts/orderitems.js b/app/assets/javascripts/orderitems.js
new file mode 100644
index 0000000000..dee720facd
--- /dev/null
+++ b/app/assets/javascripts/orderitems.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/orderitems.scss b/app/assets/stylesheets/orderitems.scss
new file mode 100644
index 0000000000..3ae284dd37
--- /dev/null
+++ b/app/assets/stylesheets/orderitems.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the orderitems 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/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
new file mode 100644
index 0000000000..757e8bf833
--- /dev/null
+++ b/app/controllers/orderitems_controller.rb
@@ -0,0 +1,4 @@
+class OrderitemsController < ApplicationController
+
+
+end
diff --git a/app/helpers/orderitems_helper.rb b/app/helpers/orderitems_helper.rb
new file mode 100644
index 0000000000..c74e407d1c
--- /dev/null
+++ b/app/helpers/orderitems_helper.rb
@@ -0,0 +1,2 @@
+module OrderitemsHelper
+end
diff --git a/config/routes.rb b/config/routes.rb
index 787824f888..8cb3369091 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,6 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+ resources :orderitmes do
+end
end
diff --git a/test/controllers/orderitems_controller_test.rb b/test/controllers/orderitems_controller_test.rb
new file mode 100644
index 0000000000..16f4fb42b6
--- /dev/null
+++ b/test/controllers/orderitems_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe OrderitemsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
From c0e888128a14fb69eb1717e638a796933af15ef7 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Thu, 19 Apr 2018 23:41:29 -0700
Subject: [PATCH 029/242] added tests for product and required validations,
added a product controller, restful method skeletons and view files
---
app/assets/javascripts/products.js | 2 +
app/assets/stylesheets/products.scss | 3 ++
app/controllers/application_controller.rb | 4 ++
app/controllers/products_controller.rb | 44 +++++++++++++++++++
app/helpers/products_helper.rb | 2 +
app/models/product.rb | 3 +-
app/views/products/edit.html.erb | 0
app/views/products/index.html.erb | 3 ++
app/views/products/new.html.erb | 0
app/views/products/show.html.erb | 1 +
.../20180420062814_add_status_to_products.rb | 5 +++
test/controllers/products_controller_test.rb | 7 +++
12 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 app/assets/javascripts/products.js
create mode 100644 app/assets/stylesheets/products.scss
create mode 100644 app/controllers/products_controller.rb
create mode 100644 app/helpers/products_helper.rb
create mode 100644 app/views/products/edit.html.erb
create mode 100644 app/views/products/index.html.erb
create mode 100644 app/views/products/new.html.erb
create mode 100644 app/views/products/show.html.erb
create mode 100644 db/migrate/20180420062814_add_status_to_products.rb
create mode 100644 test/controllers/products_controller_test.rb
diff --git a/app/assets/javascripts/products.js b/app/assets/javascripts/products.js
new file mode 100644
index 0000000000..dee720facd
--- /dev/null
+++ b/app/assets/javascripts/products.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/products.scss b/app/assets/stylesheets/products.scss
new file mode 100644
index 0000000000..89e2e8db07
--- /dev/null
+++ b/app/assets/stylesheets/products.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the products 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 1c07694e9d..eb5bf7a5f2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
+
+ def render_404
+ raise ActionController::RoutingError.new('Not Found')
+ end
end
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
new file mode 100644
index 0000000000..6a3c1fa875
--- /dev/null
+++ b/app/controllers/products_controller.rb
@@ -0,0 +1,44 @@
+class ProductsController < ApplicationController
+
+ before_action :find_product, only: [:show, :edit, :update]
+
+ def index
+ @products = Product.all
+ end
+
+ def new
+ @product = Product.new
+ end
+
+ def create
+ @product = Product.new(product_params)
+
+ if @product.save
+ # do something
+ else
+ render :new
+ end
+ end
+
+ def show; end
+
+ def edit
+ end
+
+ def update
+ end
+
+ def destroy # this will likely be replaced or used 'non-restfully' - can retire an item but not destroy it
+ end
+
+ private
+
+ def product_params
+ return params.require(:product).permit(:name, :merchant_id, :stock, :price, :description)
+ end
+
+ def find_product
+ @product = Product.find_by(id: params[:id])
+ render_404 unless @product
+ end
+end
diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb
new file mode 100644
index 0000000000..ab5c42b325
--- /dev/null
+++ b/app/helpers/products_helper.rb
@@ -0,0 +1,2 @@
+module ProductsHelper
+end
diff --git a/app/models/product.rb b/app/models/product.rb
index 597520cb24..68850ce6ea 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,4 +1,5 @@
class Product < ApplicationRecord
+ # can be created without a category?
has_and_belongs_to_many :categories, join_table: :products_categories
has_many :reviews
belongs_to :merchant
@@ -6,5 +7,5 @@ class Product < ApplicationRecord
has_many :orders, through: :order_items
validates :name, presence: true, uniqueness: true
- # validates :price, presence: true, numericality: {greater_than: 0, only_number: true}
+ validates :price, presence: true, numericality: {greater_than: 0}
end
diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
new file mode 100644
index 0000000000..6368bd49a1
--- /dev/null
+++ b/app/views/products/index.html.erb
@@ -0,0 +1,3 @@
+<% @products.each do |product| %>
+ <%= product.name %>: <%= product.price %>
+<% end %>
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
new file mode 100644
index 0000000000..75a5d0d021
--- /dev/null
+++ b/app/views/products/show.html.erb
@@ -0,0 +1 @@
+<%= @product.name %>: <%= @product.price %>
diff --git a/db/migrate/20180420062814_add_status_to_products.rb b/db/migrate/20180420062814_add_status_to_products.rb
new file mode 100644
index 0000000000..a12aa899ef
--- /dev/null
+++ b/db/migrate/20180420062814_add_status_to_products.rb
@@ -0,0 +1,5 @@
+class AddStatusToProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :retired, :boolean, default: false
+ end
+end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
new file mode 100644
index 0000000000..392a20e292
--- /dev/null
+++ b/test/controllers/products_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe ProductsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
From cb3746f5d6198db217ec2523680a429f870d0a50 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Thu, 19 Apr 2018 23:56:30 -0700
Subject: [PATCH 030/242] Set up tests for orders#update
---
app/controllers/orders_controller.rb | 36 ++++++++++++++++++----
test/controllers/orders_controller_test.rb | 26 ++++++++++++++++
2 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index dec432d7f0..e9c236b8d1 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -1,16 +1,18 @@
class OrdersController < ApplicationController
+require 'pry'
+
def index
end
- #
- # def show
- # end
+
+ def show
+ end
#
# def new
# end
#
def create
- order = Order.new
+ order = Order.new(status: "pending")
if order.save
flash[:success] = "You have opened up a cart!"
@@ -24,10 +26,32 @@ def create
# def edit
# end
#
- # def update
- # end
+ def update
+ order = Order.find(params[:id])
+ order.assign_attributes(customer_params)
+
+ if order.order_items.count > 0
+ order.assign_attributes(status: "paid")
+
+ if order.save
+ flash[:success] = "Thank you! Order has been placed."
+ redirect_to order_path(order)
+ else
+
+ end
+
+ else
+ flash[:failure] = "There are no items to check out"
+ end
+
+ end
#
# def destroy
# end
+ private
+ def customer_params
+ return params.permit(:customer_name, :customer_email, :credit_card, :CVV, :CC_expiration, :shipping_address, :billing_address)
+ end
+
end
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
index d295e4087f..52f0c9f576 100644
--- a/test/controllers/orders_controller_test.rb
+++ b/test/controllers/orders_controller_test.rb
@@ -1,4 +1,5 @@
require "test_helper"
+require 'pry'
describe OrdersController do
@@ -13,7 +14,32 @@
# must redirect to same path as before
Order.count.must_equal old_order_count + 1
+ Order.last.status.must_equal "pending"
end
end # create
+
+ describe "update" do
+
+ it "incorporates customer information and changes status to paid" do
+ order = Order.create(status: "pending")
+
+ order_item = OrderItem.create(quantity: 1, product: Product.first, order: order)
+
+ patch order_path(order), params: {
+ customer_name: "Barry Allen",
+ customer_email: "run@nike.com",
+ credit_card: "1123581321345589",
+ CVV: 890,
+ CC_expiration: "09/20",
+ shipping_address: "200 Washington St., Central City, NJ, 23456",
+ billing_address: "23456"
+ }
+
+ must_redirect_to order_path(order)
+
+ Order.last.status.must_equal "paid"
+ end
+
+ end # update
end
From 0d8564dc88ba088909a93360ad878ca4f301d2c0 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Fri, 20 Apr 2018 00:00:43 -0700
Subject: [PATCH 031/242] added in some controller tests and placeholder html;
fixed typo in routes
---
app/controllers/orderitems_controller.rb | 46 ++++++++-
app/views/orderitems/new.html.erb | 1 +
config/routes.rb | 2 +-
.../controllers/orderitems_controller_test.rb | 99 ++++++++++++++++++-
4 files changed, 144 insertions(+), 4 deletions(-)
create mode 100644 app/views/orderitems/new.html.erb
diff --git a/app/controllers/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
index 757e8bf833..cd4b16da3b 100644
--- a/app/controllers/orderitems_controller.rb
+++ b/app/controllers/orderitems_controller.rb
@@ -1,4 +1,48 @@
class OrderitemsController < ApplicationController
+ before_action :find_order_item, only: [:edit, :update, :destroy]
+
+ def index
+
+ end
+
+ def new
+ @orderitem = OrderItem.new
+ end
+
+ def create
+ @orderitem = OrderItem.new(order_item_params)
+
+ if @orderitem.save
+ flash[:success] = "Item added successfully!"
+ redirect_to products_path
+ else
+ flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
+ render "products/show", status: :bad_request
+ end
+
+ def edit; end
+
+ def update
+ @order_item.assign_attributes(order_item_params)
+
+ if @orderitem.save
+ flash[:success] = "Item added successfully!"
+ redirect_to products_path
+ else
+ flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
+ render "products/show", status: :bad_request
+
+ end
+
+ def show; end
+
+ def destroy
+ end
+
+ private
+
+ def order_item_params
+ params.require(:orderitem).permit(:order_id, :product_id, :quantity)
+ end
-
end
diff --git a/app/views/orderitems/new.html.erb b/app/views/orderitems/new.html.erb
new file mode 100644
index 0000000000..17a5763d19
--- /dev/null
+++ b/app/views/orderitems/new.html.erb
@@ -0,0 +1 @@
+
Placeholder - likely won't have this view!
diff --git a/config/routes.rb b/config/routes.rb
index 8cb3369091..c8f43278e0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,6 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- resources :orderitmes do
+ resources :orderitems do
end
end
diff --git a/test/controllers/orderitems_controller_test.rb b/test/controllers/orderitems_controller_test.rb
index 16f4fb42b6..dca4c1e587 100644
--- a/test/controllers/orderitems_controller_test.rb
+++ b/test/controllers/orderitems_controller_test.rb
@@ -1,7 +1,102 @@
require "test_helper"
describe OrderitemsController do
- # it "must be a real test" do
- # flunk "Need real tests"
+ describe 'new' do
+ it 'responds with success' do
+ get new_orderitem_path
+ must_respond_with :success
+ end
+ end
+
+ # describe 'create' do
+ # it 'can add a valid orderitem' do
+ # oi_data = {
+ # product_id: Product.first.id,
+ # order_id: Order.first.id,
+ # quantity: 1
+ # }
+ #
+ # old_oi_count = OrderItem.count
+ #
+ # OrderItem.new(oi_data).must_be :valid?
+ #
+ # post orderitems_path, params: {orderitem: oi_data}
+ #
+ # must_respond_with :redirect
+ # must_redirect_to products_path
+ #
+ # OrderItem.count.must_equal old_oi_count + 1
+ #
+ # end
+ #
+ # it "won't add an invalid orderitem" do
+ # oi_data = {
+ # product_id: Product.first.id,
+ # quantity: 1
+ # }
+ #
+ # old_oi_count = OrderItem.count
+ #
+ # OrderItem.new(oi_data).wont_be :valid?
+ #
+ # post orderitems_path, params: {orderitem: oi_data}
+ #
+ # must_respond_with :bad_request
+ #
+ # OrderItem.count.must_equal old_oi_count
+ # end
# end
+
+ describe 'edit' do
+ it 'responds with success' do
+ get edit_orderitem_path(OrderItem.last)
+ must_respond_with :success
+ end
+
+ it 'sends not_found if order_item does not exist' do
+ orderitem_id = OrderItem.last.id + 1
+ get orderitem_path(orderitem_id)
+ must_respond_with :not_found
+ end
+ end
+
+ describe 'update' do
+ it 'updates an existing orderitem with valid data' do
+ test_io = OrderItem.first
+ oi_data = test_io.attributes
+ oi_data[:quantity] = 2
+
+ test_io.assign_attributes(oi_Data)
+ test_io.must_be :valid
+
+ patch orderitem_path(test_io), params: { orderitem: io_data }
+
+ must_redirect_to products_path
+
+ test_io.reload
+ test_io.quantity.must_equal io_data[:quantity]
+
+ end
+
+ it 'sends bad_request for invalid data' do
+ test_io = OrderItem.first
+ oi_data = test_io.attributes
+ oi_data[:quantity] = 20000
+
+ test_io.assign_attributes(oi_Data)
+ test_io.wont_be :valid
+
+ patch orderitem_path(test_io), params: { orderitem: io_data }
+
+ must_respond_with :bad_request
+ end
+
+ it 'sends not_found for orderitem that dne' do
+ io_id = OrderItem.last.id + 1
+ patch orderitem_path(io_id)
+
+ must_respond_with :not_found
+ end
+
+ end
end
From 46985e461d1cfedc8aa1a007828b56f07cfcd1ba Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Fri, 20 Apr 2018 00:11:12 -0700
Subject: [PATCH 032/242] added in remainder of controller tests & methods
---
app/controllers/orderitems_controller.rb | 13 ++-
.../controllers/orderitems_controller_test.rb | 101 +++++++++++-------
2 files changed, 74 insertions(+), 40 deletions(-)
diff --git a/app/controllers/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
index cd4b16da3b..5139a7fc9b 100644
--- a/app/controllers/orderitems_controller.rb
+++ b/app/controllers/orderitems_controller.rb
@@ -2,8 +2,8 @@ class OrderitemsController < ApplicationController
before_action :find_order_item, only: [:edit, :update, :destroy]
def index
-
end
+ # not sure we need this one
def new
@orderitem = OrderItem.new
@@ -23,7 +23,7 @@ def create
def edit; end
def update
- @order_item.assign_attributes(order_item_params)
+ @orderitem.assign_attributes(order_item_params)
if @orderitem.save
flash[:success] = "Item added successfully!"
@@ -35,8 +35,12 @@ def update
end
def show; end
+ # do we even need this?
def destroy
+ @orderitem.destroy
+
+ redirect_to "order/show"
end
private
@@ -45,4 +49,9 @@ def order_item_params
params.require(:orderitem).permit(:order_id, :product_id, :quantity)
end
+ def find_order_item
+ @orderitem = OrderItem.find_by(id: params[:id])
+ head :not_found unless @orderitem
+ end
+
end
diff --git a/test/controllers/orderitems_controller_test.rb b/test/controllers/orderitems_controller_test.rb
index dca4c1e587..c10d2109ed 100644
--- a/test/controllers/orderitems_controller_test.rb
+++ b/test/controllers/orderitems_controller_test.rb
@@ -8,44 +8,44 @@
end
end
- # describe 'create' do
- # it 'can add a valid orderitem' do
- # oi_data = {
- # product_id: Product.first.id,
- # order_id: Order.first.id,
- # quantity: 1
- # }
- #
- # old_oi_count = OrderItem.count
- #
- # OrderItem.new(oi_data).must_be :valid?
- #
- # post orderitems_path, params: {orderitem: oi_data}
- #
- # must_respond_with :redirect
- # must_redirect_to products_path
- #
- # OrderItem.count.must_equal old_oi_count + 1
- #
- # end
- #
- # it "won't add an invalid orderitem" do
- # oi_data = {
- # product_id: Product.first.id,
- # quantity: 1
- # }
- #
- # old_oi_count = OrderItem.count
- #
- # OrderItem.new(oi_data).wont_be :valid?
- #
- # post orderitems_path, params: {orderitem: oi_data}
- #
- # must_respond_with :bad_request
- #
- # OrderItem.count.must_equal old_oi_count
- # end
- # end
+ describe 'create' do
+ it 'can add a valid orderitem' do
+ oi_data = {
+ product_id: Product.first.id,
+ order_id: Order.first.id,
+ quantity: 1
+ }
+
+ old_oi_count = OrderItem.count
+
+ OrderItem.new(oi_data).must_be :valid?
+
+ post orderitems_path, params: {orderitem: oi_data}
+
+ must_respond_with :redirect
+ must_redirect_to products_path
+
+ OrderItem.count.must_equal old_oi_count + 1
+
+ end
+
+ it "won't add an invalid orderitem" do
+ oi_data = {
+ product_id: Product.first.id,
+ quantity: 1
+ }
+
+ old_oi_count = OrderItem.count
+
+ OrderItem.new(oi_data).wont_be :valid?
+
+ post orderitems_path, params: {orderitem: oi_data}
+
+ must_respond_with :bad_request
+
+ OrderItem.count.must_equal old_oi_count
+ end
+ end
describe 'edit' do
it 'responds with success' do
@@ -97,6 +97,31 @@
must_respond_with :not_found
end
+ end
+
+ describe 'destroy' do
+ it 'responds with success if an orderitem is deleted' do
+ io_id = OrderItem.first.id
+ old_oi_count = OrderItem.count
+
+ delete orderitem_path(io_id)
+
+ must_respond_with :redirect
+ must_redirect_to "order/show"
+
+ OrderItem.count.must_equal old_oi_count - 1
+ OrderItem.find_by(id: io_id).must_be_nil
+ end
+
+ it 'sends not_found if orderitem dne' do
+ io_id = OrderItem.last.id + 1
+ old_oi_count = OrderItem.count
+
+ delete orderitem_path(io_id)
+ must_respond_with :not_found
+ OrderItem.count.must_equal old_oi_count
+ end
end
+
end
From c1c9e7df0392a6a53e3b594c2d6df69473f546a4 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Fri, 20 Apr 2018 08:34:12 -0700
Subject: [PATCH 033/242] Write and test update, show, and index for Orders
controller
---
app/controllers/orders_controller.rb | 28 ++++----
app/models/order.rb | 10 ++-
app/views/orders/index.html.erb | 0
app/views/orders/show.html.erb | 0
test/controllers/orders_controller_test.rb | 76 +++++++++++++++++++++-
5 files changed, 99 insertions(+), 15 deletions(-)
create mode 100644 app/views/orders/index.html.erb
create mode 100644 app/views/orders/show.html.erb
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index e9c236b8d1..5156bd95e2 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -1,12 +1,12 @@
class OrdersController < ApplicationController
-require 'pry'
+ before_action :order_params, only: [:show, :update]
def index
+ @order = Order.all
end
- def show
- end
+ def show; end
#
# def new
# end
@@ -27,21 +27,22 @@ def create
# end
#
def update
- order = Order.find(params[:id])
- order.assign_attributes(customer_params)
+ @order.assign_attributes(customer_params)
- if order.order_items.count > 0
- order.assign_attributes(status: "paid")
+ if @order.order_items.count > 0
+ @order.assign_attributes(status: "paid")
- if order.save
- flash[:success] = "Thank you! Order has been placed."
- redirect_to order_path(order)
+ if @order.save
+ flash[:success] = "Thank you! Your order has been placed."
+ redirect_to order_path(@order)
else
-
+ flash[:failure] = "The customer information was incomplete."
+ redirect_to order_path(@order)
end
else
flash[:failure] = "There are no items to check out"
+ redirect_back(fallback_location: root_path)
end
end
@@ -50,6 +51,11 @@ def update
# end
private
+ def order_params
+ @order = Order.find_by(id: params[:id])
+ head :not_found unless @order
+ end
+
def customer_params
return params.permit(:customer_name, :customer_email, :credit_card, :CVV, :CC_expiration, :shipping_address, :billing_address)
end
diff --git a/app/models/order.rb b/app/models/order.rb
index bdbad7bcf2..de3593055f 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -1,6 +1,14 @@
class Order < ApplicationRecord
- has_many :order_items
+ has_many :order_items, dependent: :destroy
has_many :products, through: :order_items
# validates :order_items, :length => { :minimum => 1 }
+ validates :order_items, length: { minimum: 1 }, if: :customer_info?
+
+ def customer_info?
+ if self.customer_name.nil? || self.customer_email.nil? || self.credit_card.nil? || self.CVV.nil? || self.CC_expiration.nil? || self.shipping_address.nil? || self.billing_address.nil?
+ return false
+ end
+ return true
+ end
end
diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
index 52f0c9f576..c3cda76749 100644
--- a/test/controllers/orders_controller_test.rb
+++ b/test/controllers/orders_controller_test.rb
@@ -1,8 +1,40 @@
require "test_helper"
-require 'pry'
describe OrdersController do
+ describe "index" do
+
+ it "sends a success response when there are many orders" do
+ Order.count.must_be :>, 0
+ get orders_path
+ must_respond_with :success
+ end
+
+ it "sends a success response when there are no orders" do
+ Order.destroy_all
+ Order.count.must_equal 0
+ get orders_path
+ must_respond_with :success
+ end
+
+ end
+
+ describe "show" do
+
+ it "sends success if the order exists" do
+ order = Order.first
+ get order_path(order)
+ must_respond_with :success
+ end
+
+ it "sends not_found if the order does not exist" do
+ order_id = Order.last.id + 1
+ get order_path(order_id)
+ must_respond_with :not_found
+ end
+
+ end # show
+
describe "create" do
it 'adds a valid order' do
@@ -21,7 +53,7 @@
describe "update" do
- it "incorporates customer information and changes status to paid" do
+ it "incorporates complete customer information and changes status to paid" do
order = Order.create(status: "pending")
order_item = OrderItem.create(quantity: 1, product: Product.first, order: order)
@@ -30,12 +62,50 @@
customer_name: "Barry Allen",
customer_email: "run@nike.com",
credit_card: "1123581321345589",
- CVV: 890,
+ CVV: "890",
+ CC_expiration: "09/20",
+ shipping_address: "200 Washington St., Central City, NJ, 23456",
+ billing_address: "23456"
+ }
+
+ must_redirect_to order_path(order)
+
+ Order.last.status.must_equal "paid"
+ end
+
+ it "does not allow the transaction to go through if there are no items in the cart" do
+ order = Order.create(status: "pending")
+
+ patch order_path(order), params: {
+ customer_name: "Barry Allen",
+ customer_email: "run@nike.com",
+ credit_card: "1123581321345589",
+ CVV: "890",
CC_expiration: "09/20",
shipping_address: "200 Washington St., Central City, NJ, 23456",
billing_address: "23456"
}
+ must_respond_with :redirect
+
+ Order.last.status.must_equal "pending"
+ end
+
+ it "does not allow the transaction to go through if the customer data is incomplete" do
+ order = Order.create(status: "pending")
+
+ order_item = OrderItem.create(quantity: 1, product: Product.first, order: order)
+
+ patch order_path(order), params: {
+ customer_name: "",
+ customer_email: "",
+ credit_card: "",
+ CVV: "",
+ CC_expiration: "",
+ shipping_address: "",
+ billing_address: ""
+ }
+
must_redirect_to order_path(order)
Order.last.status.must_equal "paid"
From ebfa1df4cb88745b40de08094574a4c7f1f97380 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Fri, 20 Apr 2018 10:29:10 -0700
Subject: [PATCH 034/242] Test that a valid rating can be created
---
test/models/review_test.rb | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
index e1a5999a4f..bbd22e4052 100644
--- a/test/models/review_test.rb
+++ b/test/models/review_test.rb
@@ -35,6 +35,13 @@
Review.count.must_equal @old_review_count
end
+ it "a valid rating can be created" do
+ @review.rating = 3
+ @review.must_be :valid?
+ @review.save
+ Review.count.must_equal @old_review_count + 1
+ end
+
end # validations
describe "relations" do
From 46ba28deea82ae2f3ce095cf069f1bb55e83a96e Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Fri, 20 Apr 2018 10:38:43 -0700
Subject: [PATCH 035/242] Call products on merchant in relations test
---
test/models/merchant_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
index 702f8cb1d0..0cbacd8e86 100644
--- a/test/models/merchant_test.rb
+++ b/test/models/merchant_test.rb
@@ -52,7 +52,7 @@
product.save
- merchant.product_ids.must_include product.id
+ merchant.products.must_include product
end
end # relations
From 6eed6b25329dda5559ff207cb31b6458f24c0b66 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Fri, 20 Apr 2018 10:56:40 -0700
Subject: [PATCH 036/242] Change Orders column names from upper case to lower
case
---
...80420175356_change_credit_card_columns_to_lower_case.rb | 6 ++++++
db/schema.rb | 7 ++++---
2 files changed, 10 insertions(+), 3 deletions(-)
create mode 100644 db/migrate/20180420175356_change_credit_card_columns_to_lower_case.rb
diff --git a/db/migrate/20180420175356_change_credit_card_columns_to_lower_case.rb b/db/migrate/20180420175356_change_credit_card_columns_to_lower_case.rb
new file mode 100644
index 0000000000..beff288d0b
--- /dev/null
+++ b/db/migrate/20180420175356_change_credit_card_columns_to_lower_case.rb
@@ -0,0 +1,6 @@
+class ChangeCreditCardColumnsToLowerCase < ActiveRecord::Migration[5.1]
+ def change
+ rename_column :orders, :CVV, :cvv
+ rename_column :orders, :CC_expiration, :cc_expiration
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index cd6233987a..1f8a30163d 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.define(version: 20180419210206) do
+ActiveRecord::Schema.define(version: 20180420175356) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -41,8 +41,8 @@
t.string "customer_name"
t.string "customer_email"
t.string "credit_card"
- t.string "CVV"
- t.string "CC_expiration"
+ t.string "cvv"
+ t.string "cc_expiration"
t.string "status"
t.string "shipping_address"
t.string "billing_address"
@@ -73,6 +73,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "product_id"
+ t.text "description"
t.index ["product_id"], name: "index_reviews_on_product_id"
end
From e2950c69098aa6ed22c21c8a3f4e83d324c934f6 Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Fri, 20 Apr 2018 10:59:15 -0700
Subject: [PATCH 037/242] added fixtures to order_items to run relation tests
in product model testing. Added resources for product in routes
---
config/routes.rb | 2 +
db/schema.rb | 3 +-
test/fixtures/order_items.yml | 4 +-
test/models/product_test.rb | 104 ++++++++++++++++++++++++++++++++--
4 files changed, 104 insertions(+), 9 deletions(-)
diff --git a/config/routes.rb b/config/routes.rb
index 787824f888..bfd11c917a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+ resources :products
end
diff --git a/db/schema.rb b/db/schema.rb
index fea17c2db7..03321c28b1 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.define(version: 20180419210206) do
+ActiveRecord::Schema.define(version: 20180420062814) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -59,6 +59,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "merchant_id"
+ t.boolean "retired", default: false
t.index ["merchant_id"], name: "index_products_on_merchant_id"
end
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
index 1cb6079d5a..dfa4915f27 100644
--- a/test/fixtures/order_items.yml
+++ b/test/fixtures/order_items.yml
@@ -2,8 +2,8 @@
one:
quantity: 1
- product_id: 1
- order_id: 1
+ product: batarang
+ order: one
two:
quantity: 1
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
index 8331479ad9..b010f0b7f1 100644
--- a/test/models/product_test.rb
+++ b/test/models/product_test.rb
@@ -3,6 +3,7 @@
describe Product do
describe 'relations' do
let (:product) { Product.new(name: 'Action Figure', stock: 3, price: 2.99, merchant: merchants(:merchant_one)) }
+ let (:merchant) { Merchant.first }
it 'has a list of categories' do
product = products(:batarang)
@@ -26,19 +27,37 @@
it 'connects products and merchants' do
- merchant = Merchant.first
-
product = Product.new(name: 'Green Hair Dye', stock: 24, price: 8.99, merchant_id: merchant.id)
product.merchant_id.must_equal merchant.id
end
+
+ it 'connects products and order_items' do
+ order_item = order_items(:one)
+
+ product = Product.create!(name: 'Green Hair Dye', stock: 24, price: 8.99, merchant_id: merchant.id)
+
+ product.order_items << order_item
+ product.valid?.must_equal true
+ product.order_item_ids.must_include order_item.id
+ end
+
+ it 'connects products and orders' do
+ order = orders(:one)
+
+ product = Product.create!(name: 'Green Hair Dye', stock: 24, price: 8.99, merchant_id: merchant.id)
+
+ product.orders << order
+ product.valid?.must_equal true
+ product.order_ids.must_include order.id
+ end
end
describe 'validations' do
- it 'cannot be created without a name' do
- merchant = Merchant.first
- categories = [Category.first]
+ let (:merchant) { Merchant.first }
+ let (:categories) { [Category.first] }
+ it 'cannot be created without a name' do
product_data = {
stock: 1,
price: 1.99,
@@ -49,7 +68,80 @@
product = Product.new(product_data)
product.valid?.must_equal false
- product.error.messages.must_include :name
+ product.errors.messages.must_include :name
+ end
+
+ it 'must have a unique name' do
+ product1_name = Product.first.name
+
+ product2_data = {
+ name: product1_name,
+ stock: 1,
+ price: 1.99,
+ merchant_id: merchant.id,
+ categories: categories
+ }
+
+ product = Product.new(product2_data)
+
+ product.valid?.must_equal false
+ product.errors.messages.must_include :name
+ end
+
+ it 'cannot be created without a price' do
+ product_data = {
+ name: 'product',
+ stock: 1,
+ merchant_id: merchant.id,
+ categories: categories
+ }
+
+ product = Product.new(product_data)
+
+ product.valid?.must_equal false
+ product.errors.messages.must_include :price
+ end
+
+ it 'cannot be created with a price below 0' do
+ product_data = {
+ name: 'product',
+ stock: 1,
+ price: -2.4,
+ merchant_id: merchant.id,
+ categories: categories
+ }
+
+ product = Product.new(product_data)
+ product.valid?.must_equal false
+ product.errors.messages.must_include :price
+ end
+
+ it 'cannot be created without a merchant ID' do
+ product_data = {
+ name: 'product',
+ stock: 1,
+ price: 2.4,
+ categories: categories
+ }
+
+ product = Product.new(product_data)
+ product.valid?.must_equal false
+ product.errors.messages.must_include :merchant
+ end
+
+ it 'can be created with appropriate data' do
+ product_data = {
+ name: 'product',
+ stock: 1,
+ price: 2.4,
+ merchant_id: merchant.id,
+ categories: categories
+ }
+ old_product_count = Product.count
+
+ product = Product.create(product_data)
+ product.valid?.must_equal true
+ Product.count.must_equal old_product_count + 1
end
end
end
From 8277c6709dd59539e17691c7fd2a2ab158d919df Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Fri, 20 Apr 2018 11:28:30 -0700
Subject: [PATCH 038/242] added simplecov
---
.gitignore | 2 ++
Gemfile | 1 +
Gemfile.lock | 8 ++++++++
test/test_helper.rb | 8 ++++++++
4 files changed, 19 insertions(+)
diff --git a/.gitignore b/.gitignore
index 82701fedc8..bd98b9cd78 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@
/yarn-error.log
.byebug_history
+
+/coverage/
diff --git a/Gemfile b/Gemfile
index 8490d0efb5..af107ae6a9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -69,4 +69,5 @@ end
group :test do
gem 'minitest-rails'
gem 'minitest-reporters'
+ gem 'simplecov', require: false
end
diff --git a/Gemfile.lock b/Gemfile.lock
index d528acb17a..bfea144982 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -68,6 +68,7 @@ GEM
concurrent-ruby (1.0.5)
crass (1.0.4)
debug_inspector (0.0.3)
+ docile (1.1.5)
erubi (1.7.1)
execjs (2.7.0)
ffi (1.9.23)
@@ -89,6 +90,7 @@ GEM
jquery-turbolinks (2.1.0)
railties (>= 3.1.0)
turbolinks
+ json (2.1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@@ -166,6 +168,11 @@ GEM
selenium-webdriver (3.11.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
+ simplecov (0.15.1)
+ docile (~> 1.1.0)
+ json (>= 1.8, < 3)
+ simplecov-html (~> 0.10.0)
+ simplecov-html (0.10.2)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
@@ -225,6 +232,7 @@ DEPENDENCIES
rails (~> 5.1.6)
sass-rails (~> 5.0)
selenium-webdriver
+ simplecov
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 10594a3248..e4e185ec86 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,3 +1,11 @@
+require 'simplecov'
+SimpleCov.start 'rails' do
+ add_filter '/bin/'
+ add_filter '/db/'
+ add_filter '/spec/' # for rspec
+ add_filter '/test/' # for minitest
+end
+
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
From 68b3a82ce94764641efe6dca0b2b92913e26555a Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Fri, 20 Apr 2018 12:36:10 -0700
Subject: [PATCH 039/242] fixed orderitem tests and methods; added in views for
placeholders, added in model validations
---
app/controllers/orderitems_controller.rb | 23 +++++----
app/models/order_item.rb | 9 ++++
app/views/orderitems/edit.html.erb | 0
app/views/orderitems/show.html.erb | 0
app/views/products/show.html.erb | 0
config/routes.rb | 6 ++-
.../controllers/orderitems_controller_test.rb | 50 +++++++++----------
7 files changed, 52 insertions(+), 36 deletions(-)
create mode 100644 app/views/orderitems/edit.html.erb
create mode 100644 app/views/orderitems/show.html.erb
create mode 100644 app/views/products/show.html.erb
diff --git a/app/controllers/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
index 5139a7fc9b..e3cabccca1 100644
--- a/app/controllers/orderitems_controller.rb
+++ b/app/controllers/orderitems_controller.rb
@@ -1,13 +1,13 @@
class OrderitemsController < ApplicationController
- before_action :find_order_item, only: [:edit, :update, :destroy]
+ before_action :find_order_item, only: [:update, :destroy]
- def index
- end
+ # def index
+ # end
# not sure we need this one
- def new
- @orderitem = OrderItem.new
- end
+ # def new
+ # @orderitem = OrderItem.new
+ # end
def create
@orderitem = OrderItem.new(order_item_params)
@@ -18,9 +18,12 @@ def create
else
flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
render "products/show", status: :bad_request
+ end
end
- def edit; end
+ # def edit
+ # puts "ran inside of edit"
+ # end
def update
@orderitem.assign_attributes(order_item_params)
@@ -31,11 +34,11 @@ def update
else
flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
render "products/show", status: :bad_request
-
+ end
end
- def show; end
- # do we even need this?
+ # def show; end
+ # # do we even need this?
def destroy
@orderitem.destroy
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index eecf9e7ebf..a5d06d00d2 100644
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -1,4 +1,13 @@
class OrderItem < ApplicationRecord
belongs_to :product
belongs_to :order
+
+ validate :available_quantity
+
+ def available_quantity
+ unless product.stock.to_i >= quantity
+ errors[:quantity] << 'Not enough stock'
+ end
+ end
+
end
diff --git a/app/views/orderitems/edit.html.erb b/app/views/orderitems/edit.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/orderitems/show.html.erb b/app/views/orderitems/show.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/config/routes.rb b/config/routes.rb
index c8f43278e0..53d0e4f619 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,5 +2,9 @@
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :orderitems do
-end
+ end
+
+ resources :products do
+ end
+
end
diff --git a/test/controllers/orderitems_controller_test.rb b/test/controllers/orderitems_controller_test.rb
index c10d2109ed..249eda0d9a 100644
--- a/test/controllers/orderitems_controller_test.rb
+++ b/test/controllers/orderitems_controller_test.rb
@@ -1,12 +1,12 @@
require "test_helper"
describe OrderitemsController do
- describe 'new' do
- it 'responds with success' do
- get new_orderitem_path
- must_respond_with :success
- end
- end
+ # describe 'new' do
+ # it 'responds with success' do
+ # get new_orderitem_path
+ # must_respond_with :success
+ # end
+ # end
describe 'create' do
it 'can add a valid orderitem' do
@@ -47,18 +47,18 @@
end
end
- describe 'edit' do
- it 'responds with success' do
- get edit_orderitem_path(OrderItem.last)
- must_respond_with :success
- end
-
- it 'sends not_found if order_item does not exist' do
- orderitem_id = OrderItem.last.id + 1
- get orderitem_path(orderitem_id)
- must_respond_with :not_found
- end
- end
+ # describe 'edit' do
+ # it 'responds with success' do
+ # get edit_orderitem_path(OrderItem.last)
+ # must_respond_with :success
+ # end
+ #
+ # it 'sends not_found if order_item does not exist' do
+ # orderitem_id = OrderItem.last.id + 1
+ # get orderitem_path(orderitem_id)
+ # must_respond_with :not_found
+ # end
+ # end
describe 'update' do
it 'updates an existing orderitem with valid data' do
@@ -66,15 +66,15 @@
oi_data = test_io.attributes
oi_data[:quantity] = 2
- test_io.assign_attributes(oi_Data)
- test_io.must_be :valid
+ test_io.assign_attributes(oi_data)
+ test_io.must_be :valid?
- patch orderitem_path(test_io), params: { orderitem: io_data }
+ patch orderitem_path(test_io), params: { orderitem: oi_data }
must_redirect_to products_path
test_io.reload
- test_io.quantity.must_equal io_data[:quantity]
+ test_io.quantity.must_equal oi_data[:quantity]
end
@@ -83,10 +83,10 @@
oi_data = test_io.attributes
oi_data[:quantity] = 20000
- test_io.assign_attributes(oi_Data)
- test_io.wont_be :valid
+ test_io.assign_attributes(oi_data)
+ test_io.wont_be :valid?
- patch orderitem_path(test_io), params: { orderitem: io_data }
+ patch orderitem_path(test_io), params: { orderitem: oi_data }
must_respond_with :bad_request
end
From 0207669100570238f3366e8fe2bbd24b78969e8d Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Fri, 20 Apr 2018 15:33:08 -0700
Subject: [PATCH 040/242] Comment next steps
---
app/controllers/orders_controller.rb | 2 ++
app/models/merchant.rb | 1 +
app/models/order.rb | 11 ++++++++++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index 5156bd95e2..56c841a191 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -23,6 +23,8 @@ def create
end
end
#
+ # non-restful view action for editing order_item quantities
+ # put customer info form here and edit quantities
# def edit
# end
#
diff --git a/app/models/merchant.rb b/app/models/merchant.rb
index 07aacc445d..61d590cf7a 100644
--- a/app/models/merchant.rb
+++ b/app/models/merchant.rb
@@ -1,3 +1,4 @@
class Merchant < ApplicationRecord
has_many :products
+ # has many orders through products
end
diff --git a/app/models/order.rb b/app/models/order.rb
index de3593055f..04c4a5a6b4 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -3,10 +3,19 @@ class Order < ApplicationRecord
has_many :products, through: :order_items
# validates :order_items, :length => { :minimum => 1 }
+ # validates :customer_name, presence: true, on: :update
+ # validates :customer_email, presence: true, on: :update
+ # validates :credit_card, presence: true, on: :update
+ # validates :cvv, presence: true, on: :update
+ # validates :cc_expiration, presence: true, on: :update
+ # validates :shipping_address, presence: true, on: :update
+ # validates :billing_address, presence: true, on: :update
+
validates :order_items, length: { minimum: 1 }, if: :customer_info?
def customer_info?
- if self.customer_name.nil? || self.customer_email.nil? || self.credit_card.nil? || self.CVV.nil? || self.CC_expiration.nil? || self.shipping_address.nil? || self.billing_address.nil?
+ if
+ self.customer_name.nil? || self.customer_email.nil? || self.credit_card.nil? || self.cvv.nil? || self.cc_expiration.nil? || self.shipping_address.nil? || self.billing_address.nil?
return false
end
return true
From a40c4078776e2eec5b7b0e6b7bac77796f56e954 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Fri, 20 Apr 2018 15:33:17 -0700
Subject: [PATCH 041/242] finalized orderitems controller tests and methods
---
app/controllers/orderitems_controller.rb | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/app/controllers/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
index e3cabccca1..56f87d31c2 100644
--- a/app/controllers/orderitems_controller.rb
+++ b/app/controllers/orderitems_controller.rb
@@ -1,14 +1,6 @@
class OrderitemsController < ApplicationController
before_action :find_order_item, only: [:update, :destroy]
- # def index
- # end
- # not sure we need this one
-
- # def new
- # @orderitem = OrderItem.new
- # end
-
def create
@orderitem = OrderItem.new(order_item_params)
@@ -21,10 +13,6 @@ def create
end
end
- # def edit
- # puts "ran inside of edit"
- # end
-
def update
@orderitem.assign_attributes(order_item_params)
@@ -37,9 +25,6 @@ def update
end
end
- # def show; end
- # # do we even need this?
-
def destroy
@orderitem.destroy
From d8f0bc77fd531c2a4ab29fc86ed4271859c8bce3 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sat, 21 Apr 2018 10:27:31 -0700
Subject: [PATCH 042/242] minor changes to files
---
app/controllers/orderitems_controller.rb | 45 +++++++
app/views/products/show.html.erb | 1 -
.../controllers/orderitems_controller_test.rb | 127 ++++++++++++++++++
3 files changed, 172 insertions(+), 1 deletion(-)
create mode 100644 app/controllers/orderitems_controller.rb
create mode 100644 test/controllers/orderitems_controller_test.rb
diff --git a/app/controllers/orderitems_controller.rb b/app/controllers/orderitems_controller.rb
new file mode 100644
index 0000000000..56f87d31c2
--- /dev/null
+++ b/app/controllers/orderitems_controller.rb
@@ -0,0 +1,45 @@
+class OrderitemsController < ApplicationController
+ before_action :find_order_item, only: [:update, :destroy]
+
+ def create
+ @orderitem = OrderItem.new(order_item_params)
+
+ if @orderitem.save
+ flash[:success] = "Item added successfully!"
+ redirect_to products_path
+ else
+ flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
+ render "products/show", status: :bad_request
+ end
+ end
+
+ def update
+ @orderitem.assign_attributes(order_item_params)
+
+ if @orderitem.save
+ flash[:success] = "Item added successfully!"
+ redirect_to products_path
+ else
+ flash.now[:failure] = "Oops! Something went wrong and we couldn't add this item."
+ render "products/show", status: :bad_request
+ end
+ end
+
+ def destroy
+ @orderitem.destroy
+
+ redirect_to "order/show"
+ end
+
+ private
+
+ def order_item_params
+ params.require(:orderitem).permit(:order_id, :product_id, :quantity)
+ end
+
+ def find_order_item
+ @orderitem = OrderItem.find_by(id: params[:id])
+ head :not_found unless @orderitem
+ end
+
+end
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
index 75a5d0d021..e69de29bb2 100644
--- a/app/views/products/show.html.erb
+++ b/app/views/products/show.html.erb
@@ -1 +0,0 @@
-<%= @product.name %>: <%= @product.price %>
diff --git a/test/controllers/orderitems_controller_test.rb b/test/controllers/orderitems_controller_test.rb
new file mode 100644
index 0000000000..249eda0d9a
--- /dev/null
+++ b/test/controllers/orderitems_controller_test.rb
@@ -0,0 +1,127 @@
+require "test_helper"
+
+describe OrderitemsController do
+ # describe 'new' do
+ # it 'responds with success' do
+ # get new_orderitem_path
+ # must_respond_with :success
+ # end
+ # end
+
+ describe 'create' do
+ it 'can add a valid orderitem' do
+ oi_data = {
+ product_id: Product.first.id,
+ order_id: Order.first.id,
+ quantity: 1
+ }
+
+ old_oi_count = OrderItem.count
+
+ OrderItem.new(oi_data).must_be :valid?
+
+ post orderitems_path, params: {orderitem: oi_data}
+
+ must_respond_with :redirect
+ must_redirect_to products_path
+
+ OrderItem.count.must_equal old_oi_count + 1
+
+ end
+
+ it "won't add an invalid orderitem" do
+ oi_data = {
+ product_id: Product.first.id,
+ quantity: 1
+ }
+
+ old_oi_count = OrderItem.count
+
+ OrderItem.new(oi_data).wont_be :valid?
+
+ post orderitems_path, params: {orderitem: oi_data}
+
+ must_respond_with :bad_request
+
+ OrderItem.count.must_equal old_oi_count
+ end
+ end
+
+ # describe 'edit' do
+ # it 'responds with success' do
+ # get edit_orderitem_path(OrderItem.last)
+ # must_respond_with :success
+ # end
+ #
+ # it 'sends not_found if order_item does not exist' do
+ # orderitem_id = OrderItem.last.id + 1
+ # get orderitem_path(orderitem_id)
+ # must_respond_with :not_found
+ # end
+ # end
+
+ describe 'update' do
+ it 'updates an existing orderitem with valid data' do
+ test_io = OrderItem.first
+ oi_data = test_io.attributes
+ oi_data[:quantity] = 2
+
+ test_io.assign_attributes(oi_data)
+ test_io.must_be :valid?
+
+ patch orderitem_path(test_io), params: { orderitem: oi_data }
+
+ must_redirect_to products_path
+
+ test_io.reload
+ test_io.quantity.must_equal oi_data[:quantity]
+
+ end
+
+ it 'sends bad_request for invalid data' do
+ test_io = OrderItem.first
+ oi_data = test_io.attributes
+ oi_data[:quantity] = 20000
+
+ test_io.assign_attributes(oi_data)
+ test_io.wont_be :valid?
+
+ patch orderitem_path(test_io), params: { orderitem: oi_data }
+
+ must_respond_with :bad_request
+ end
+
+ it 'sends not_found for orderitem that dne' do
+ io_id = OrderItem.last.id + 1
+ patch orderitem_path(io_id)
+
+ must_respond_with :not_found
+ end
+ end
+
+ describe 'destroy' do
+ it 'responds with success if an orderitem is deleted' do
+ io_id = OrderItem.first.id
+ old_oi_count = OrderItem.count
+
+ delete orderitem_path(io_id)
+
+ must_respond_with :redirect
+ must_redirect_to "order/show"
+
+ OrderItem.count.must_equal old_oi_count - 1
+ OrderItem.find_by(id: io_id).must_be_nil
+ end
+
+ it 'sends not_found if orderitem dne' do
+ io_id = OrderItem.last.id + 1
+ old_oi_count = OrderItem.count
+
+ delete orderitem_path(io_id)
+
+ must_respond_with :not_found
+ OrderItem.count.must_equal old_oi_count
+ end
+ end
+
+end
From 80280076fd5bd79a66178825fa0b58c0f66493f2 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sat, 21 Apr 2018 10:37:38 -0700
Subject: [PATCH 043/242] resolved conflict in migration file 2655
---
app/models/order_item.rb | 2 +-
app/views/products/show.html.erb | 0
db/migrate/20180419172655_add_product_to_order_item.rb | 3 ---
db/migrate/20180421173034_change_product_stock_to_integer.rb | 5 +++++
4 files changed, 6 insertions(+), 4 deletions(-)
delete mode 100644 app/views/products/show.html.erb
create mode 100644 db/migrate/20180421173034_change_product_stock_to_integer.rb
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index a5d06d00d2..b2ff6841cf 100644
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -5,7 +5,7 @@ class OrderItem < ApplicationRecord
validate :available_quantity
def available_quantity
- unless product.stock.to_i >= quantity
+ unless product.stock >= quantity
errors[:quantity] << 'Not enough stock'
end
end
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/db/migrate/20180419172655_add_product_to_order_item.rb b/db/migrate/20180419172655_add_product_to_order_item.rb
index 60cac95ea6..3672da38ca 100644
--- a/db/migrate/20180419172655_add_product_to_order_item.rb
+++ b/db/migrate/20180419172655_add_product_to_order_item.rb
@@ -1,9 +1,6 @@
class AddProductToOrderItem < ActiveRecord::Migration[5.1]
def change
-<<<<<<< HEAD
-=======
remove_column :order_items, :product_id, :integer
add_reference :order_items, :product, foreign_key: true
->>>>>>> relation_setup
end
end
diff --git a/db/migrate/20180421173034_change_product_stock_to_integer.rb b/db/migrate/20180421173034_change_product_stock_to_integer.rb
new file mode 100644
index 0000000000..b66b6c4170
--- /dev/null
+++ b/db/migrate/20180421173034_change_product_stock_to_integer.rb
@@ -0,0 +1,5 @@
+class ChangeProductStockToInteger < ActiveRecord::Migration[5.1]
+ def change
+ change_column :products, :stock, :integer
+ end
+end
From ce2cb6423cbf0fb733957f1bad12ba38f8ec93de Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sat, 21 Apr 2018 10:47:27 -0700
Subject: [PATCH 044/242] converted product.stock to integer from string and
modified orderitem validation to match
---
db/migrate/20180421173034_change_product_stock_to_integer.rb | 2 +-
db/schema.rb | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/db/migrate/20180421173034_change_product_stock_to_integer.rb b/db/migrate/20180421173034_change_product_stock_to_integer.rb
index b66b6c4170..f375900ea4 100644
--- a/db/migrate/20180421173034_change_product_stock_to_integer.rb
+++ b/db/migrate/20180421173034_change_product_stock_to_integer.rb
@@ -1,5 +1,5 @@
class ChangeProductStockToInteger < ActiveRecord::Migration[5.1]
def change
- change_column :products, :stock, :integer
+ change_column :products, :stock, :integer, using: 'stock::integer'
end
end
diff --git a/db/schema.rb b/db/schema.rb
index fea17c2db7..f2974d4839 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.define(version: 20180419210206) do
+ActiveRecord::Schema.define(version: 20180421173034) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -53,7 +53,7 @@
create_table "products", force: :cascade do |t|
t.string "name"
- t.string "stock"
+ t.integer "stock"
t.float "price"
t.text "description"
t.datetime "created_at", null: false
From 6999584ee5629606db0c5ed3eca5e22be9731cdc Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sat, 21 Apr 2018 13:51:03 -0700
Subject: [PATCH 045/242] started products show view; added order/viewcart
route
---
app/views/products/show.html.erb | 12 ++++++++++++
config/routes.rb | 9 ++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
index e69de29bb2..8df0b8671a 100644
--- a/app/views/products/show.html.erb
+++ b/app/views/products/show.html.erb
@@ -0,0 +1,12 @@
+
+
+
+
<%= @product.name %>
+
<%= @product.details %>
+
Quantity Available: <%= @product.stock %>
+
+
<%= link_to "Add to cart",
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 53d0e4f619..303d300768 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,10 +1,9 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- resources :orderitems do
- end
-
- resources :products do
- end
+ resources :orderitems
+ resources :products
+ resources :order
+ get 'order/viewcart', to: 'orders#viewcart', as: viewcart
end
From 9e5d58f871f0dd9c050082a5b179c7eb420db612 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Sat, 21 Apr 2018 14:56:28 -0700
Subject: [PATCH 046/242] Set up Sessions controller
---
app/assets/javascripts/sessions.js | 2 ++
app/assets/stylesheets/sessions.scss | 3 +++
app/controllers/sessions_controller.rb | 2 ++
app/helpers/sessions_helper.rb | 2 ++
test/controllers/sessions_controller_test.rb | 7 +++++++
5 files changed, 16 insertions(+)
create mode 100644 app/assets/javascripts/sessions.js
create mode 100644 app/assets/stylesheets/sessions.scss
create mode 100644 app/controllers/sessions_controller.rb
create mode 100644 app/helpers/sessions_helper.rb
create mode 100644 test/controllers/sessions_controller_test.rb
diff --git a/app/assets/javascripts/sessions.js b/app/assets/javascripts/sessions.js
new file mode 100644
index 0000000000..dee720facd
--- /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/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss
new file mode 100644
index 0000000000..7bef9cf826
--- /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/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000000..16d11b5710
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,2 @@
+class SessionsController < ApplicationController
+end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
new file mode 100644
index 0000000000..309f8b2eb3
--- /dev/null
+++ b/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 0000000000..c2632a720b
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe SessionsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
From 858ff78dc5656b347552aad32312b1ad1960cfb0 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Sat, 21 Apr 2018 15:50:40 -0700
Subject: [PATCH 047/242] Set up Google authentication
---
.gitignore | 1 +
Gemfile | 3 +++
Gemfile.lock | 31 ++++++++++++++++++++++++++
app/controllers/sessions_controller.rb | 6 +++++
config/initializers/omniauth.rb | 3 +++
config/routes.rb | 2 ++
6 files changed, 46 insertions(+)
create mode 100644 config/initializers/omniauth.rb
diff --git a/.gitignore b/.gitignore
index bd98b9cd78..15d8005fa7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,5 +17,6 @@
/yarn-error.log
.byebug_history
+.env
/coverage/
diff --git a/Gemfile b/Gemfile
index af107ae6a9..fc0c37073a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -32,6 +32,8 @@ gem 'jbuilder', '~> 2.5'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
+gem "omniauth"
+gem "omniauth-google-oauth2", "~> 0.2.1"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
@@ -64,6 +66,7 @@ end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
+ gem 'dotenv-rails'
end
group :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index bfea144982..4c5f117ca8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -69,8 +69,14 @@ GEM
crass (1.0.4)
debug_inspector (0.0.3)
docile (1.1.5)
+ dotenv (2.2.2)
+ dotenv-rails (2.2.2)
+ dotenv (= 2.2.2)
+ railties (>= 3.2, < 6.0)
erubi (1.7.1)
execjs (2.7.0)
+ faraday (0.12.2)
+ multipart-post (>= 1.2, < 3)
ffi (1.9.23)
foundation-rails (6.4.3.0)
railties (>= 3.1.0)
@@ -78,6 +84,7 @@ GEM
sprockets-es6 (>= 0.9.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
+ hashie (3.5.7)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
@@ -91,6 +98,7 @@ GEM
railties (>= 3.1.0)
turbolinks
json (2.1.0)
+ jwt (1.5.6)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@@ -113,10 +121,30 @@ GEM
minitest (>= 5.0)
ruby-progressbar
multi_json (1.13.1)
+ multi_xml (0.6.0)
+ multipart-post (2.0.0)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
normalize-rails (4.1.1)
+ oauth2 (1.4.0)
+ faraday (>= 0.8, < 0.13)
+ jwt (~> 1.0)
+ multi_json (~> 1.3)
+ multi_xml (~> 0.5)
+ rack (>= 1.2, < 3)
+ omniauth (1.8.1)
+ hashie (>= 3.4.6, < 3.6.0)
+ rack (>= 1.6.2, < 3)
+ omniauth-google-oauth2 (0.2.10)
+ addressable (~> 2.3)
+ jwt (~> 1.0)
+ multi_json (~> 1.3)
+ omniauth (>= 1.1.1)
+ omniauth-oauth2 (~> 1.3.1)
+ omniauth-oauth2 (1.3.1)
+ oauth2 (~> 1.0)
+ omniauth (~> 1.2)
pg (1.0.0)
pry (0.11.3)
coderay (~> 1.1.0)
@@ -218,6 +246,7 @@ DEPENDENCIES
binding_of_caller
byebug
capybara (~> 2.13)
+ dotenv-rails
foundation-rails
jbuilder (~> 2.5)
jquery-rails
@@ -226,6 +255,8 @@ DEPENDENCIES
minitest-rails
minitest-reporters
normalize-rails
+ omniauth
+ omniauth-google-oauth2 (~> 0.2.1)
pg (>= 0.18, < 2.0)
pry-rails
puma (~> 3.7)
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 16d11b5710..7315ab35d7 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,2 +1,8 @@
class SessionsController < ApplicationController
+
+ def create
+ auth_hash = request.env['omniauth.auth']
+ raise
+ end
+
end
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
new file mode 100644
index 0000000000..37d1409f01
--- /dev/null
+++ b/config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], scope: "user:email"
+end
diff --git a/config/routes.rb b/config/routes.rb
index 9a2b824a4c..bc52a2b9cf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,4 +6,6 @@
resources :orders
resources :products
+ get "/auth/:provider/callback", to: "sessions#create"
+
end
From e30224fdb0a734b6d9aaf3d067f4d4006dd8eaca Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Sat, 21 Apr 2018 16:05:44 -0700
Subject: [PATCH 048/242] Change merchant table for Google authentication
---
config/initializers/omniauth.rb | 2 +-
.../20180421225111_modify_merchant_for_authentication.rb | 6 ++++++
db/schema.rb | 4 +++-
3 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 db/migrate/20180421225111_modify_merchant_for_authentication.rb
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index 37d1409f01..049e821e4e 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -1,3 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do
- provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], scope: "user:email"
+ provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], scope: "email"
end
diff --git a/db/migrate/20180421225111_modify_merchant_for_authentication.rb b/db/migrate/20180421225111_modify_merchant_for_authentication.rb
new file mode 100644
index 0000000000..67523944db
--- /dev/null
+++ b/db/migrate/20180421225111_modify_merchant_for_authentication.rb
@@ -0,0 +1,6 @@
+class ModifyMerchantForAuthentication < ActiveRecord::Migration[5.1]
+ def change
+ add_column :merchants, :uid, :integer, options: { null: false }
+ add_column :merchants, :provider, :string, options: { null: false }
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 916abbba29..e739724308 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.define(version: 20180420175356) do
+ActiveRecord::Schema.define(version: 20180421225111) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -26,6 +26,8 @@
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "uid"
+ t.string "provider"
end
create_table "order_items", force: :cascade do |t|
From 990829d8c1a99e8c4ba02869c581bc8459de99a4 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Sat, 21 Apr 2018 16:39:20 -0700
Subject: [PATCH 049/242] Write sessions#create to authenticate and create new
merchants via Google
---
app/assets/javascripts/merchants.js | 2 ++
app/assets/stylesheets/merchants.scss | 3 ++
app/controllers/merchants_controller.rb | 2 ++
app/controllers/sessions_controller.rb | 35 ++++++++++++++++++-
app/helpers/merchants_helper.rb | 2 ++
config/initializers/omniauth.rb | 2 +-
test/controllers/merchants_controller_test.rb | 7 ++++
7 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 app/assets/javascripts/merchants.js
create mode 100644 app/assets/stylesheets/merchants.scss
create mode 100644 app/controllers/merchants_controller.rb
create mode 100644 app/helpers/merchants_helper.rb
create mode 100644 test/controllers/merchants_controller_test.rb
diff --git a/app/assets/javascripts/merchants.js b/app/assets/javascripts/merchants.js
new file mode 100644
index 0000000000..dee720facd
--- /dev/null
+++ b/app/assets/javascripts/merchants.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/merchants.scss b/app/assets/stylesheets/merchants.scss
new file mode 100644
index 0000000000..f4c164d600
--- /dev/null
+++ b/app/assets/stylesheets/merchants.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Merchants 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/merchants_controller.rb b/app/controllers/merchants_controller.rb
new file mode 100644
index 0000000000..ae95f7677b
--- /dev/null
+++ b/app/controllers/merchants_controller.rb
@@ -0,0 +1,2 @@
+class MerchantsController < ApplicationController
+end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 7315ab35d7..400cc3275a 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -2,7 +2,40 @@ class SessionsController < ApplicationController
def create
auth_hash = request.env['omniauth.auth']
- raise
+
+ if auth_hash['uid']
+
+ @merchant = Merchant.find_by(uid: auth_hash[:uid], provider: auth_hash[:provider])
+
+ if @merchant.nil?
+
+ @merchant = Merchant.new(
+ username: (auth_hash['info']['email']).split('@').first,
+ email: auth_hash['info']['email'],
+ uid: auth_hash['uid'],
+ provider: auth_hash['provider']
+ )
+
+ if @merchant.save
+ session[:merchant_id] = @merchant.id
+ flash[:success] = "Created new merchant and logged in successfully"
+ redirect_to root_path
+ else
+ flash[:error] = "Could not log in because merchant failed validations"
+ redirect_to root_path
+ end
+
+ else
+ session[:merchant_id] = @merchant.id
+ flash[:success] = "Logged in as existing merchant #{@merchant.username} successfully"
+ redirect_to root_path
+ end
+
+ else
+ flash[:error] = "Authentication failed. Could not log in."
+ redirect_to root_path
+ end
+
end
end
diff --git a/app/helpers/merchants_helper.rb b/app/helpers/merchants_helper.rb
new file mode 100644
index 0000000000..5337747b0f
--- /dev/null
+++ b/app/helpers/merchants_helper.rb
@@ -0,0 +1,2 @@
+module MerchantsHelper
+end
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index 049e821e4e..fc8641523e 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -1,3 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do
- provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], scope: "email"
+ provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], scope: "profile, email"
end
diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb
new file mode 100644
index 0000000000..6eb57f7baa
--- /dev/null
+++ b/test/controllers/merchants_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe MerchantsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
From 4c8dc50476356cd54d072f1004bdebb405f70c4d Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Sat, 21 Apr 2018 16:51:23 -0700
Subject: [PATCH 050/242] added more tests for ProductsController and nested
routes for merchant/products
---
app/controllers/products_controller.rb | 5 +-
app/views/layouts/application.html.erb | 1 +
app/views/products/_form.html.erb | 14 +++++
app/views/products/index.html.erb | 12 ++++-
app/views/products/new.html.erb | 1 +
config/routes.rb | 5 +-
db/schema.rb | 4 +-
test/controllers/products_controller_test.rb | 55 ++++++++++++++++++--
8 files changed, 89 insertions(+), 8 deletions(-)
create mode 100644 app/views/products/_form.html.erb
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 6a3c1fa875..1219a10455 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -14,9 +14,10 @@ def create
@product = Product.new(product_params)
if @product.save
- # do something
+ flash[:success] = 'Successfully added product'
+ redirect_to merchant_products_path
else
- render :new
+ render :new
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index cd60004891..4f9768d68f 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -7,6 +7,7 @@
<%= content_for?(:title) ? yield(:title) : "Untitled" %>
<%= stylesheet_link_tag "application" %>
+
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb
new file mode 100644
index 0000000000..8f9a4dc206
--- /dev/null
+++ b/app/views/products/_form.html.erb
@@ -0,0 +1,14 @@
+<%= page_title %>
+
+<%= form_for @product do |f| %>
+ <%= f.hidden_field :merchant_id %>
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+ <%= f.label :price %>
+ <%= f.text_field :price %>
+ <%= f.label :stock %>
+ <%= f.number_field :stock %>
+ <%= f.label :description %>
+ <%= f.text_area :description %>
+ <%= f.submit action_name %>
+<% end %>
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
index 6368bd49a1..153af958d7 100644
--- a/app/views/products/index.html.erb
+++ b/app/views/products/index.html.erb
@@ -1,3 +1,13 @@
+
<% @products.each do |product| %>
- <%= product.name %>: <%= product.price %>
+
<% end %>
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
index e69de29bb2..76de7ac1aa 100644
--- a/app/views/products/new.html.erb
+++ b/app/views/products/new.html.erb
@@ -0,0 +1 @@
+<%= render partial: 'form', locals: {action_name: 'Create New Product', page_title: 'Add a New Product'} %>
diff --git a/config/routes.rb b/config/routes.rb
index 53d0e4f619..09b795947c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,7 +4,10 @@
resources :orderitems do
end
- resources :products do
+ resources :products, only: [:index, :show]
+
+ resources :merchants do
+ resources :products
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 027b6fefd7..690a69a9a1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -30,11 +30,12 @@
create_table "order_items", force: :cascade do |t|
t.integer "quantity"
- t.integer "product_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.bigint "product_id"
t.bigint "order_id"
t.index ["order_id"], name: "index_order_items_on_order_id"
+ t.index ["product_id"], name: "index_order_items_on_product_id"
end
create_table "orders", force: :cascade do |t|
@@ -79,6 +80,7 @@
end
add_foreign_key "order_items", "orders"
+ add_foreign_key "order_items", "products"
add_foreign_key "products", "merchants"
add_foreign_key "reviews", "products"
end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
index 392a20e292..0411cea029 100644
--- a/test/controllers/products_controller_test.rb
+++ b/test/controllers/products_controller_test.rb
@@ -1,7 +1,56 @@
require "test_helper"
describe ProductsController do
- # it "must be a real test" do
- # flunk "Need real tests"
- # end
+ describe 'index' do
+ it 'succeeds with multiple products' do
+ Product.count.must_be :>, 0
+
+ get products_path
+ must_respond_with :success
+ end
+
+ it 'succeeds with no products' do
+ Product.destroy_all
+
+ Product.count.must_equal 0
+ get products_path
+ must_respond_with :success
+ end
+
+ it "it can show only one merchant's products" do
+
+ end
+ end
+
+ describe 'new' do
+ it 'succeeds' do
+ get new_merchant_product_path(Merchant.first.id)
+
+ must_respond_with :success
+ end
+ end
+
+ describe 'create' do
+ it "creates a work with valid data for a real category" do
+ product_data = {
+ name: 'Product',
+ stock: 3,
+ price: 3.00,
+ merchant_id: Merchant.first.id
+ }
+
+ old_product_count = Product.count
+
+ post merchant_products_path(Merchant.first.id), params: { product: product_data }
+
+ must_redirect_to merchant_products_path(Merchant.first.id)
+ Product.count.must_equal old_product_count + 1
+
+ end
+
+ it "renders bad_request and does not update the DB for bogus data" do
+ end
+
+ end
+
end
From 0a5f8d78c64b71b4b6bf95029cfeb7b6a6b5a7e0 Mon Sep 17 00:00:00 2001
From: Angelica Maria Ceja Morales
Date: Sat, 21 Apr 2018 17:05:46 -0700
Subject: [PATCH 051/242] Complete Google authentication log out functionality,
link to log in/out paths in view, update uid to type string
---
app/controllers/sessions_controller.rb | 6 ++++++
app/views/layouts/application.html.erb | 11 +++++++++++
config/routes.rb | 1 +
.../20180421234834_make_merchant_uid_big_int.rb | 5 +++++
db/migrate/20180421235138_make_merchant_uid_bigger.rb | 5 +++++
db/migrate/20180421235852_change_uid_to_string.rb | 5 +++++
db/schema.rb | 4 ++--
7 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 db/migrate/20180421234834_make_merchant_uid_big_int.rb
create mode 100644 db/migrate/20180421235138_make_merchant_uid_bigger.rb
create mode 100644 db/migrate/20180421235852_change_uid_to_string.rb
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 400cc3275a..456d572e46 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -38,4 +38,10 @@ def create
end
+ def destroy
+ session.delete(:merchant_id)
+ flash[:success] = "Logged out successfully."
+ redirect_to root_path
+ end
+
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index cd60004891..276668738a 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -13,6 +13,17 @@
+
+
+
+
<%= yield %>
diff --git a/config/routes.rb b/config/routes.rb
index bc52a2b9cf..539a2ebc8b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -7,5 +7,6 @@
resources :products
get "/auth/:provider/callback", to: "sessions#create"
+ delete "/logout", to: "sessions#destroy", as: "logout"
end
diff --git a/db/migrate/20180421234834_make_merchant_uid_big_int.rb b/db/migrate/20180421234834_make_merchant_uid_big_int.rb
new file mode 100644
index 0000000000..5eff310fab
--- /dev/null
+++ b/db/migrate/20180421234834_make_merchant_uid_big_int.rb
@@ -0,0 +1,5 @@
+class MakeMerchantUidBigInt < ActiveRecord::Migration[5.1]
+ def change
+ change_column :merchants, :uid, :integer, limit: 8
+ end
+end
diff --git a/db/migrate/20180421235138_make_merchant_uid_bigger.rb b/db/migrate/20180421235138_make_merchant_uid_bigger.rb
new file mode 100644
index 0000000000..32e2ef0a16
--- /dev/null
+++ b/db/migrate/20180421235138_make_merchant_uid_bigger.rb
@@ -0,0 +1,5 @@
+class MakeMerchantUidBigger < ActiveRecord::Migration[5.1]
+ def change
+ change_column :merchants, :uid, :bigint
+ end
+end
diff --git a/db/migrate/20180421235852_change_uid_to_string.rb b/db/migrate/20180421235852_change_uid_to_string.rb
new file mode 100644
index 0000000000..4697ea6efc
--- /dev/null
+++ b/db/migrate/20180421235852_change_uid_to_string.rb
@@ -0,0 +1,5 @@
+class ChangeUidToString < ActiveRecord::Migration[5.1]
+ def change
+ change_column :merchants, :uid, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e739724308..95af18ff61 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.define(version: 20180421225111) do
+ActiveRecord::Schema.define(version: 20180421235852) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -26,7 +26,7 @@
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.integer "uid"
+ t.string "uid"
t.string "provider"
end
From 99a9c2cbb384b96e18ee487c4b532167679182db Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Sat, 21 Apr 2018 18:15:25 -0700
Subject: [PATCH 052/242] ProductsController tests new, index, show, some
update
---
app/controllers/products_controller.rb | 17 ++-
config/routes.rb | 2 +-
test/controllers/products_controller_test.rb | 117 ++++++++++++++-----
3 files changed, 102 insertions(+), 34 deletions(-)
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 1219a10455..56afed3dcf 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -17,16 +17,25 @@ def create
flash[:success] = 'Successfully added product'
redirect_to merchant_products_path
else
- render :new
+ flash.now[:failure] = 'Product not created'
+ render :new, status: :bad_request
end
end
def show; end
- def edit
- end
+ def edit; end
def update
+ @product.assign_attributes(product_params)
+
+ if @product.save
+ flash[:succes] = "Successfully updated product #{@product.id}"
+ redirect_to merchant_products_path
+ else
+ flash.now[:failure] = 'Product not updated'
+ render :edit, status: :bad_request
+ end
end
def destroy # this will likely be replaced or used 'non-restfully' - can retire an item but not destroy it
@@ -40,6 +49,6 @@ def product_params
def find_product
@product = Product.find_by(id: params[:id])
- render_404 unless @product
+ head :not_found unless @product
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 09b795947c..0113bb9ca2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -7,7 +7,7 @@
resources :products, only: [:index, :show]
resources :merchants do
- resources :products
+ resources :products, except: [:show]
end
end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
index 0411cea029..32e6314760 100644
--- a/test/controllers/products_controller_test.rb
+++ b/test/controllers/products_controller_test.rb
@@ -1,56 +1,115 @@
require "test_helper"
describe ProductsController do
- describe 'index' do
- it 'succeeds with multiple products' do
- Product.count.must_be :>, 0
+ describe 'guest user' do
+ describe 'index' do
+ it 'succeeds with multiple products for a guest user' do
+ Product.count.must_be :>, 0
+ get products_path
+ must_respond_with :success
+ end
+
+ it 'succeeds with no products for a guest user' do
+ Product.destroy_all
+
+ Product.count.must_equal 0
get products_path
must_respond_with :success
+ end
end
- it 'succeeds with no products' do
- Product.destroy_all
+ describe 'show' do
+ it 'succeeds for an existing product' do
+ product_id = Product.first.id
- Product.count.must_equal 0
- get products_path
- must_respond_with :success
- end
+ get product_path(product_id)
- it "it can show only one merchant's products" do
+ must_respond_with :success
+ end
- end
- end
+ it 'renders not_found for a non-existing id' do
+ product_id = Product.last.id + 1
- describe 'new' do
- it 'succeeds' do
- get new_merchant_product_path(Merchant.first.id)
+ get product_path(product_id)
- must_respond_with :success
+ must_respond_with :not_found
+ end
end
end
- describe 'create' do
- it "creates a work with valid data for a real category" do
- product_data = {
- name: 'Product',
- stock: 3,
- price: 3.00,
- merchant_id: Merchant.first.id
+
+
+# TODO update all to have signed in user
+ describe 'authenticated user' do
+ describe 'create' do
+ let (:product_data) {
+ {
+ name: 'Product',
+ stock: 3,
+ price: 3.00,
+ merchant_id: Merchant.first.id
+ }
}
- old_product_count = Product.count
+ it "creates a work with valid data for a real category for an authenticated user" do
+ old_product_count = Product.count
+
+ post merchant_products_path(Merchant.first.id), params: { product: product_data }
+
+ must_redirect_to merchant_products_path(Merchant.first.id)
+ Product.count.must_equal old_product_count + 1
+ end
+
+ it "renders bad_request and does not update the DB for bogus data for an authenticated user" do
+ product_data[:name] = nil
+
+ old_product_count = Product.count
- post merchant_products_path(Merchant.first.id), params: { product: product_data }
+ post merchant_products_path(Merchant.first.id), params: { product: product_data }
- must_redirect_to merchant_products_path(Merchant.first.id)
- Product.count.must_equal old_product_count + 1
+ must_respond_with :bad_request
+ Product.count.must_equal old_product_count
+ end
+ end
+
+ describe 'new' do
+ it 'succeeds for an authenticated user' do
+ get new_merchant_product_path(Merchant.first.id)
+ must_respond_with :success
+ end
end
- it "renders bad_request and does not update the DB for bogus data" do
+ describe 'edit' do
+ it 'succeeds for an authenticated user'
end
- end
+ describe 'update' do
+ let (:merchant) { Merchant.first }
+ let (:product) { Product.first }
+ let (:old_product_count) { Product.count }
+
+ it 'succeeds with good data' do
+ old_product_stock = product.stock
+
+ product_data = {
+ name: product.name,
+ stock: product.stock - 1,
+ price: product.price,
+ merchant_id: product.merchant_id
+ }
+ patch merchant_product_path(product.merchant.id, product.id), params: { product: product_data }
+ product.reload
+
+ must_redirect_to merchant_products_path
+ Product.count.must_equal old_product_count
+
+ product.stock.must_equal (old_product_stock - 1)
+ end
+ end
+
+
+ end
end
From 24a11c4806f41cea09766a25a644aecc8bd49d2b Mon Sep 17 00:00:00 2001
From: Tor Shimizu
Date: Sat, 21 Apr 2018 21:00:00 -0700
Subject: [PATCH 053/242] preliminary tests for product destroy, edit, show -
waiting for authentication merge to test with an authenticated user
---
app/controllers/products_controller.rb | 15 ++++++++++++---
app/views/products/_form.html.erb | 2 ++
test/controllers/products_controller_test.rb | 20 ++++++++++++++++++--
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 56afed3dcf..e7a30f9079 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -1,9 +1,9 @@
class ProductsController < ApplicationController
- before_action :find_product, only: [:show, :edit, :update]
+ before_action :find_product, only: [:show, :edit, :update, :destroy]
def index
- @products = Product.all
+ @products = Product.where(retired: false)
end
def new
@@ -38,7 +38,16 @@ def update
end
end
- def destroy # this will likely be replaced or used 'non-restfully' - can retire an item but not destroy it
+ def destroy
+ @product.retired = true
+
+ if @product.save
+ flash[:success] = 'Product has been retired'
+ else
+ flash[:failure] = 'Could not retire product'
+ end
+
+ redirect_to merchant_products_path
end
private
diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb
index 8f9a4dc206..bfab32a846 100644
--- a/app/views/products/_form.html.erb
+++ b/app/views/products/_form.html.erb
@@ -8,6 +8,8 @@
<%= f.text_field :price %>
<%= f.label :stock %>
<%= f.number_field :stock %>
+ <%= f.label :categories %>
+ <%= collection_check_boxes :product, :category_ids, Category.all, :id, :name %>
<%= f.label :description %>
<%= f.text_area :description %>
<%= f.submit action_name %>
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
index 32e6314760..63b40eb26b 100644
--- a/test/controllers/products_controller_test.rb
+++ b/test/controllers/products_controller_test.rb
@@ -52,12 +52,14 @@
}
}
- it "creates a work with valid data for a real category for an authenticated user" do
+ it 'must have a authenticated user'
+
+ it "creates a work with valid data" do
old_product_count = Product.count
post merchant_products_path(Merchant.first.id), params: { product: product_data }
- must_redirect_to merchant_products_path(Merchant.first.id)
+ must_redirect_to merchant_products_path(Product.last.merchant_id)
Product.count.must_equal old_product_count + 1
end
@@ -108,8 +110,22 @@
product.stock.must_equal (old_product_stock - 1)
end
+
+ it 'returns bad_request for bad data'
end
+ describe 'destroy' do
+ let (:merchant) { Merchant.first }
+ let (:product) { merchant.products.first }
+
+ it 'retires an existing product' do
+ delete merchant_product_path(merchant.id, product.id)
+
+ product.reload
+ product.retired.must_equal true
+ must_redirect_to merchant_products_path
+ end
+ end
end
end
From edeffeac585b144aedc25f8efd68f226db102ce2 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sun, 22 Apr 2018 11:10:58 -0700
Subject: [PATCH 054/242] added in links to add to cart and view additional
merchant products - added in nested merchant routes to facilitate this
---
app/views/products/show.html.erb | 4 ++--
config/routes.rb | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
index 8df0b8671a..f33616fd8b 100644
--- a/app/views/products/show.html.erb
+++ b/app/views/products/show.html.erb
@@ -5,8 +5,8 @@
<%= @product.details %>
Quantity Available: <%= @product.stock %>
-
<%= link_to "Add to cart",
-
<% else %>
- # put table here
+ <% raise %>
+ <% @orders.each do |order| %>
+ <%= order.id %>
+ <%= order.customer_name %>
+ <% order.order_items.each do |order_item| %>
+ <%= order_item.id %>
+ <%= order_item.product.name %>
+ <%= order_item.quantity %>
+ <%= order_item.created_at %>
+ <% end %>
+ <% end %>
<% end %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 5dad0d860c..92c6545527 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,7 +6,7 @@
resources :orders
resources :products
resources :merchants do
- resources :orders
+ resources :orders, only: [:index]
end
get "/auth/:provider/callback", to: "sessions#create", as: "auth_callback"
From 6a90dcf5598cc463f8945b5ac2b23ea5e7215ae8 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sun, 22 Apr 2018 21:44:20 -0700
Subject: [PATCH 071/242] added order#edit method
---
app/controllers/orders_controller.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index 373cb7c424..0f649a04bc 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -25,9 +25,10 @@ def create
#
# non-restful view action for editing order_item quantities
# put customer info form here and edit quantities
- # def edit
- # end
- #
+ def edit
+ @order = Order.find_by(id: params[:id])
+ end
+
def update
@order.assign_attributes(customer_params)
From 716d3a97404798d86e5874e3d0d6c10efc6e20a0 Mon Sep 17 00:00:00 2001
From: Hannah Cameron
Date: Sun, 22 Apr 2018 22:28:03 -0700
Subject: [PATCH 072/242] ran db:migrations, give app.html som structure,
finished up edit and starting show
---
app/controllers/orders_controller.rb | 2 +-
app/views/layouts/application.html.erb | 8 +++---
app/views/orders/edit.html.erb | 35 ++++++++++++++------------
app/views/orders/show.html.erb | 1 +
db/schema.rb | 4 ++-
5 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb
index 0f649a04bc..90adb67897 100644
--- a/app/controllers/orders_controller.rb
+++ b/app/controllers/orders_controller.rb
@@ -60,7 +60,7 @@ def order_params
end
def customer_params
- return params.permit(:customer_name, :customer_email, :credit_card, :CVV, :CC_expiration, :shipping_address, :billing_address)
+ return params.permit(:customer_name, :customer_email, :credit_card, :cvv, :cc_expiration, :shipping_address, :billing_address)
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index cd60004891..f1bdb92a68 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -12,8 +12,10 @@
-
- <%= yield %>
-
+
+
+
+ <%= yield %>
+