diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
new file mode 100644
index 0000000000..036f093135
--- /dev/null
+++ b/app/views/products/new.html.erb
@@ -0,0 +1,3 @@
+
+
+<%= render partial: "layouts/form", locals: { page_title: "Add a new product"} %>
diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb
new file mode 100644
index 0000000000..e4aa29ffe9
--- /dev/null
+++ b/app/views/products/root.html.erb
@@ -0,0 +1,120 @@
+
+
+
+
SWEATSY
+
+
Get ready to get sweaty!
+
+
+
+
Our Story
+
+
+
+
Sweatsy, adj.: being both sweaty and sexy.
+
+
+
Are you ready to get sweaty? Sweatsy is the brainchild of Ludwig Von Swetson and Lucretia Sweatovsky, two exercise enterpreneur enthusiasts. Their vision was to start business to offer people of all walks of life high-end couture active wear. From leggings to spandex, to leotards and scrunchies, our apparel is guaranteed to make you sweat in as fabulous a way possible. We source from the most elite factories of the Lithuanian countryside and use the most sweatastic and semipermeable textiles. We hope you enjoy perusing our stock of sweaty accessories and consider buying something to help you reach sweat success! Don't sweat the small stuff! Start your day with sweatsy and love your life bigly. Hashtag live life to the sweatiest. Hashtag life is sweet and sweaty. Don't forget to follow us on Instagram puh-lease! Thank you for visiting our beautiful website! It is the best website, trust us no bugs just sweat.
+
+
+
+
+
+
Browse Top Products
+
+
+
+
+
Red Leotard
+
+
+
+
+
+
+
+
+
Jazz Legs
+
+
+
+
+
+
+
+
+
+
Dry-Fit Shirt
+
+
+
+
+
+
+
+ <%= link_to "See More", products_path, class:'button' %>
+
+
+
+
+
+
+
Browse by Category
+
+
+
+
+
<%= link_to 'Shirts', categories_path %>
+
+
+
+
+
+
+
+
+
<%= link_to 'Shoes', categories_path %>
+
+
+
+
+
+
+
+
+
<%= link_to 'Accessories', categories_path %>
+
+
+
+
+
+
+
+
+
<%= link_to 'Tights', categories_path %>
+
+
+
+
+
+
+
+ <%= link_to "See More", categories_path, class:'button' %>
+
+<%= form_for @review do |f| %>
+ <%= f.label :rating %>
+ <%= f.number_field :rating %>
+
+ <%= f.label :description %>
+ <%= f.text_field :description %>
+
+ <%= f.submit %>
+<% end %>
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..f97f2af958
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,93 @@
+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')
+ config.serve_static_assets = true
+ config.assets.compile = true
+
+ 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/omniauth.rb b/config/initializers/omniauth.rb
new file mode 100644
index 0000000000..fd4416122a
--- /dev/null
+++ b/config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email"
+end
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..6e20d5dada
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,40 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+ root 'products#root'
+
+ patch '/products/:id/retire', to: 'products#retire', as: 'retire'
+
+ get '/:id/ship_order', to: 'orders#ship_order', as: 'ship_order'
+
+ post '/products/:id/add_review', to: 'products#create_review', as: :create_review
+
+ get '/auth/github', as: 'github_login'
+
+ delete '/logout', to: 'sessions#destroy', as: 'logout'
+
+ get "/auth/:provider/callback", to: "sessions#create", as: 'auth_callback'
+
+ resources :products do
+ resources :reviews, only: [:new, :show, :create]
+ end
+
+ resources :orders, only: [:show, :create, :update]
+
+ get '/checkout', to: 'carts#edit', as: :checkout
+ get '/order_confirmation', to: 'carts#confirmation', as: :confirmation
+
+ # may not need all routes for order_products
+ resources :order_products
+ resource :cart, only: [:show, :update]
+
+ resources :categories, only: [:new, :create, :index, :show] do
+ resources :product, only: [:root]
+ end
+
+ resources :merchants, except: [:edit, :update, :destroy] do
+ resources :products, only: [:index]
+ resources :orders, only: [:index]
+ end
+
+end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 0000000000..7f68fb3891
--- /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: 55a259c3241bf3d44e4e4b5b21aaefa1793e2ff067ae9a4dd34c9d9494c9d99f9f5aa16f311b45f1582027f9c5c360a61f2558b4671f57923c1db5344b0d6aaf
+
+test:
+ secret_key_base: 7fd84c0d006d6c01509c844e7b9e5ba1e7b3e18397001daf50b05eecc3e13ee272c34de9df91fa521a549d132193c937faf2235831adaf09217968432d55703a
+
+# 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/migrate/20180419192941_create_merchants.rb b/db/migrate/20180419192941_create_merchants.rb
new file mode 100644
index 0000000000..64a57c904c
--- /dev/null
+++ b/db/migrate/20180419192941_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/db/migrate/20180419200734_create_reviews.rb b/db/migrate/20180419200734_create_reviews.rb
new file mode 100644
index 0000000000..68962656fc
--- /dev/null
+++ b/db/migrate/20180419200734_create_reviews.rb
@@ -0,0 +1,10 @@
+class CreateReviews < ActiveRecord::Migration[5.1]
+ def change
+ create_table :reviews do |t|
+ t.integer "rating"
+ t.string "description"
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419204902_create_orders.rb b/db/migrate/20180419204902_create_orders.rb
new file mode 100644
index 0000000000..4c82956027
--- /dev/null
+++ b/db/migrate/20180419204902_create_orders.rb
@@ -0,0 +1,8 @@
+class CreateOrders < ActiveRecord::Migration[5.1]
+ def change
+ create_table :orders do |t|
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419204920_all_columns_to_order.rb b/db/migrate/20180419204920_all_columns_to_order.rb
new file mode 100644
index 0000000000..b1127e0873
--- /dev/null
+++ b/db/migrate/20180419204920_all_columns_to_order.rb
@@ -0,0 +1,13 @@
+class AllColumnsToOrder < ActiveRecord::Migration[5.1]
+ def change
+ add_column :orders, :date, :date
+ add_column :orders, :status, :string
+ add_column :orders, :name, :string
+ add_column :orders, :email, :string
+ add_column :orders, :address, :string
+ add_column :orders, :cc_num, :string
+ add_column :orders, :expiry_date, :date
+ add_column :orders, :cc_cvv, :string
+ add_column :orders, :zip, :string
+ end
+end
diff --git a/db/migrate/20180419212035_create_products.rb b/db/migrate/20180419212035_create_products.rb
new file mode 100644
index 0000000000..f7229bfe9a
--- /dev/null
+++ b/db/migrate/20180419212035_create_products.rb
@@ -0,0 +1,11 @@
+class CreateProducts < ActiveRecord::Migration[5.1]
+ def change
+ create_table :products do |t|
+ t.string :name
+ t.integer :price
+ t.integer :available
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419214250_create_categories.rb b/db/migrate/20180419214250_create_categories.rb
new file mode 100644
index 0000000000..9528428eb8
--- /dev/null
+++ b/db/migrate/20180419214250_create_categories.rb
@@ -0,0 +1,8 @@
+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/20180420002031_change_expiry_data_type.rb b/db/migrate/20180420002031_change_expiry_data_type.rb
new file mode 100644
index 0000000000..40b193d8c0
--- /dev/null
+++ b/db/migrate/20180420002031_change_expiry_data_type.rb
@@ -0,0 +1,6 @@
+class ChangeExpiryDataType < ActiveRecord::Migration[5.1]
+ def change
+ change_column :orders, :date, :timestamp
+ change_column :orders, :expiry_date, :string
+ end
+end
diff --git a/db/migrate/20180420003356_delete_date_column_from_order.rb b/db/migrate/20180420003356_delete_date_column_from_order.rb
new file mode 100644
index 0000000000..8a2ebf8920
--- /dev/null
+++ b/db/migrate/20180420003356_delete_date_column_from_order.rb
@@ -0,0 +1,5 @@
+class DeleteDateColumnFromOrder < ActiveRecord::Migration[5.1]
+ def change
+ remove_column :orders, :date
+ end
+end
diff --git a/db/migrate/20180420210859_createorderproductsjoin.rb b/db/migrate/20180420210859_createorderproductsjoin.rb
new file mode 100644
index 0000000000..000d4417b4
--- /dev/null
+++ b/db/migrate/20180420210859_createorderproductsjoin.rb
@@ -0,0 +1,8 @@
+class Createorderproductsjoin < ActiveRecord::Migration[5.1]
+ def change
+ create_table :order_products do |t|
+ t.belongs_to :order, index: true
+ t.belongs_to :product, index: true
+ end
+ end
+end
diff --git a/db/migrate/20180420212840_add_quantity_field_to_order_products_table.rb b/db/migrate/20180420212840_add_quantity_field_to_order_products_table.rb
new file mode 100644
index 0000000000..6105b5bcf8
--- /dev/null
+++ b/db/migrate/20180420212840_add_quantity_field_to_order_products_table.rb
@@ -0,0 +1,5 @@
+class AddQuantityFieldToOrderProductsTable < ActiveRecord::Migration[5.1]
+ def change
+ add_column :order_products, :quantity, :integer
+ end
+end
diff --git a/db/migrate/20180420213433_category_product_join_table.rb b/db/migrate/20180420213433_category_product_join_table.rb
new file mode 100644
index 0000000000..9afdf35e6a
--- /dev/null
+++ b/db/migrate/20180420213433_category_product_join_table.rb
@@ -0,0 +1,8 @@
+class CategoryProductJoinTable < ActiveRecord::Migration[5.1]
+ def change
+ create_table :categories_products do |t|
+ t.belongs_to :category, index: true
+ t.belongs_to :product, index: true
+ end
+ end
+end
diff --git a/db/migrate/20180420214528_add_merchant_id_to_products.rb b/db/migrate/20180420214528_add_merchant_id_to_products.rb
new file mode 100644
index 0000000000..45930fd0d9
--- /dev/null
+++ b/db/migrate/20180420214528_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/20180421042831_add_product_id_to_reviews.rb b/db/migrate/20180421042831_add_product_id_to_reviews.rb
new file mode 100644
index 0000000000..aa157d4e07
--- /dev/null
+++ b/db/migrate/20180421042831_add_product_id_to_reviews.rb
@@ -0,0 +1,5 @@
+class AddProductIdToReviews < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :reviews, :product, foreign_key: true
+ end
+end
diff --git a/db/migrate/20180422033227_add_description_and_image_to_new_product_form.rb b/db/migrate/20180422033227_add_description_and_image_to_new_product_form.rb
new file mode 100644
index 0000000000..fe56fe3ab5
--- /dev/null
+++ b/db/migrate/20180422033227_add_description_and_image_to_new_product_form.rb
@@ -0,0 +1,6 @@
+class AddDescriptionAndImageToNewProductForm < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :description, :string
+ add_column :products, :photo, :string
+ end
+end
diff --git a/db/migrate/20180422220445_add_product_id_to_review.rb b/db/migrate/20180422220445_add_product_id_to_review.rb
new file mode 100644
index 0000000000..b1c7939a32
--- /dev/null
+++ b/db/migrate/20180422220445_add_product_id_to_review.rb
@@ -0,0 +1,4 @@
+class AddProductIdToReview < ActiveRecord::Migration[5.1]
+ def change
+ end
+end
diff --git a/db/migrate/20180422222854_fix_last_migration.rb b/db/migrate/20180422222854_fix_last_migration.rb
new file mode 100644
index 0000000000..cd82375ebd
--- /dev/null
+++ b/db/migrate/20180422222854_fix_last_migration.rb
@@ -0,0 +1,7 @@
+require_relative '20180422220445_add_product_id_to_review'
+
+class FixLastMigration < ActiveRecord::Migration[5.1]
+ def change
+ revert AddProductIdToReview
+ end
+end
diff --git a/db/migrate/20180424175628_add_uid_and_provider_to_merchants.rb b/db/migrate/20180424175628_add_uid_and_provider_to_merchants.rb
new file mode 100644
index 0000000000..22e8a4f2a6
--- /dev/null
+++ b/db/migrate/20180424175628_add_uid_and_provider_to_merchants.rb
@@ -0,0 +1,6 @@
+class AddUidAndProviderToMerchants < ActiveRecord::Migration[5.1]
+ def change
+ add_column :merchants, :uid, :integer, null: false
+ add_column :merchants, :provider, :string, null: false
+ end
+end
diff --git a/db/migrate/20180426150803_add_total_to_orders_table.rb b/db/migrate/20180426150803_add_total_to_orders_table.rb
new file mode 100644
index 0000000000..fec35a9dfc
--- /dev/null
+++ b/db/migrate/20180426150803_add_total_to_orders_table.rb
@@ -0,0 +1,5 @@
+class AddTotalToOrdersTable < ActiveRecord::Migration[5.1]
+ def change
+ add_column :orders, :total, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..cb2585884a
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,85 @@
+# 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: 20180426150803) 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 "categories_products", force: :cascade do |t|
+ t.bigint "category_id"
+ t.bigint "product_id"
+ t.index ["category_id"], name: "index_categories_products_on_category_id"
+ t.index ["product_id"], name: "index_categories_products_on_product_id"
+ 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
+ t.integer "uid", null: false
+ t.string "provider", null: false
+ end
+
+ create_table "order_products", force: :cascade do |t|
+ t.bigint "order_id"
+ t.bigint "product_id"
+ t.integer "quantity"
+ t.index ["order_id"], name: "index_order_products_on_order_id"
+ t.index ["product_id"], name: "index_order_products_on_product_id"
+ end
+
+ create_table "orders", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "status"
+ t.string "name"
+ t.string "email"
+ t.string "address"
+ t.string "cc_num"
+ t.string "expiry_date"
+ t.string "cc_cvv"
+ t.string "zip"
+ t.integer "total"
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "name"
+ t.integer "price"
+ t.integer "available"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.bigint "merchant_id"
+ t.string "description"
+ t.string "photo"
+ t.index ["merchant_id"], name: "index_products_on_merchant_id"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.integer "rating"
+ t.string "description"
+ 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
diff --git a/db/seed_data/categories-products.csv b/db/seed_data/categories-products.csv
new file mode 100644
index 0000000000..97fc2a98ef
--- /dev/null
+++ b/db/seed_data/categories-products.csv
@@ -0,0 +1,31 @@
+category_name,product_name
+Pants,Track Pants
+Accessories,Pink Head Band
+Accessories,Orange Head Band
+Accessories,Sweaty Accessory
+Shirts,Rain Jacket
+Outerwear,Rain Jacket
+Shoes,White Sneakers
+Outerwear,White Sneakers
+Outerwear,Head Band
+Accessories,Head Band
+Accessories,Purple Leotard
+Tights,Purple Leotard
+Accessories,Red Leotard
+Tights,Red Leotard
+Tights,Black Tights
+Accessories,Black Tights
+Outerwear,Track Jacket
+Shirts,Track Jacket
+Tights,Spandex
+Tights,Green Spandex
+Accessories,Neon Head Band
+Tights,Touquoise Tights
+Shirts,Dry fit Shirt
+Dry fit,Dry fit Shirt
+Shoes,Purple Sneakers
+Shoes,Neon Sneakers
+Dry fit,Silk Leotard
+Accessories,Silk Leotard
+Accessories,Jazz legs
+Legwarmers,Jazz legs
diff --git a/db/seed_data/categories.csv b/db/seed_data/categories.csv
new file mode 100644
index 0000000000..3dbb14fe35
--- /dev/null
+++ b/db/seed_data/categories.csv
@@ -0,0 +1,10 @@
+name
+Shirts
+Pants
+Shoes
+Outerwear
+Accessories
+Leotards
+Legwarmers
+Tights
+Dry fit
diff --git a/db/seed_data/merchants.csv b/db/seed_data/merchants.csv
new file mode 100644
index 0000000000..868f373174
--- /dev/null
+++ b/db/seed_data/merchants.csv
@@ -0,0 +1,6 @@
+username,email,uid,provider
+gregg,gregg.popovich@nba.com,1,github
+tyronn,tyronn.lue@nba.com,2,github
+steve,steve.kerr@nba.com,3,github
+becky,becky.hammon@nba.com,4,github
+mark,mark.jackson@nba.com,5,github
diff --git a/db/seed_data/orders-products.csv b/db/seed_data/orders-products.csv
new file mode 100644
index 0000000000..0d1deb9261
--- /dev/null
+++ b/db/seed_data/orders-products.csv
@@ -0,0 +1,9 @@
+order_id,product_name,quantity
+1,Sweaty Accessory,1
+2,White Sneakers,3
+2,Rain Jacket,1
+3,Track Pants,2
+3,Rain Jacket,1
+3,White Sneakers,1
+3,Sweaty Accessory,1
+4,Head Band,4
diff --git a/db/seed_data/orders.csv b/db/seed_data/orders.csv
new file mode 100644
index 0000000000..2f133e44d9
--- /dev/null
+++ b/db/seed_data/orders.csv
@@ -0,0 +1,5 @@
+status,name,email,address,cc_num,expiry_date,cc_cvv,zip, order
+pending,Danny Green,danny@nba.com,"1234 5th Street Seattle, WA 98125",1234567888888888,1020,100,98312,
+paid,Lebron James,lebron@nba.com,"6789 10th Street Seattle, WA 98125",1234512345123456,1118,200,98004,
+complete,Harrison Barnes,harrison@nba.com,"1112 13th Street Seattle, WA 98125",3334445556667778,1119,300,98111,
+cancelled,Kyrie Irving,kyrie@nba.com,"1415 16th Street Seattle, WA 98125",1010101111223345,1220,400,98332,
diff --git a/db/seed_data/products.csv b/db/seed_data/products.csv
new file mode 100644
index 0000000000..5aee46a96b
--- /dev/null
+++ b/db/seed_data/products.csv
@@ -0,0 +1,2 @@
+name,price,available,description,photo,merchant
+Track Pants,5000,20,Run faster sweat less,https://img.etsystatic.com/il/557be1/1397617100/il_570xN.1397617100_hbfj.jpg?version=2,1
diff --git a/db/seed_data/products2.csv b/db/seed_data/products2.csv
new file mode 100644
index 0000000000..7a8ef418db
--- /dev/null
+++ b/db/seed_data/products2.csv
@@ -0,0 +1,21 @@
+name,price,available,description,photo,merchant
+Track Pants,5000,20,Run faster sweat less,https://img.etsystatic.com/il/557be1/1397617100/il_570xN.1397617100_hbfj.jpg?version=2,1
+Pink Head Band,699,20,No more sweat on your brows,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ7hS4Q98DdAFHMLc0KiU70V1w9_-Vj63hfb4HAbSeAF7EhrMO4Og,1
+Orange Head Band,699,20,No more sweat on your brows,https://images-na.ssl-images-amazon.com/images/I/2105qPRuO3L.jpg,1
+Rain Jacket,3545,20,It will fight off the rain,https://img.etsystatic.com/il/bc058f/1469960898/il_570xN.1469960898_1l2g.jpg?version=0,2
+White Sneakers,6405,20,Protection for all the sweat, https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSi0uC5YCQw4wPrSqbF4f_Vy6bj7of4xU2UfcWaFgaBJENIGUSswg,4
+Sweaty Accessory,225,20, reduces sweat from everywhere you put it,http://d3eum8lucccgeh.cloudfront.net/designs/32518/DontSweat_grn.jpg,5
+Purple Leotard,100,20,Move around easier,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2pcWWgkfWtT9sCk7uJLoiSJXxVNZFZ-BUUGfSkIl75eHj0IFKfA,2
+Red Leotard,200,20,Let it shine,https://img.etsystatic.com/il/ba4e45/1088013044/il_570xN.1088013044_iqj2.jpg?version=1,2
+Black Tights,90,10,Release the sweat,https://rlv.zcache.co.uk/black_and_white_80s_style_leggings-rfc5f404502bc4d8e96e0024d6923df38_6ftq3_260.jpg?rlvnet=1,1
+Track Jacket,2700,20,Run faster sweat less,http://picture-cdn.wheretoget.it/yu7qzh-l.jpg,1
+Spandex,5000,20,Run faster sweat less, https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRjePGQzichk23U5SuvA3lfx6bs5Kk1gDIPd0uf_vNRmtrMUnjFvA,1
+Neon Head Band,699,20,No more sweat on your brows,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTja6mFBrA_bETAZxt7VFuhLQJ6cxblasq5UZikxycFH6hdI3vp,3
+Green Spandex,5000,20,Run faster sweat less, https://images-na.ssl-images-amazon.com/images/I/41oVO%2BPcNuL.jpg,1
+Touquoise Tights,90,10,Release the sweat,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzwAoa1ivQNHyTTkcQpxAdx6kKfDwouri_Dhx9mIfhZdD77nkT,2
+Dry fit Shirt,90,10,Release the sweat,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQEwKyPTI4qtkNvqj5V4i5fjDTTJ0WpErK6AFZp0Jf9MgBlRKwMg,1
+Neon Sneakers,6405,20,Protection for all the sweat, https://c2.staticflickr.com/4/3259/2786550775_62cc73ca14_z.jpg?zz=1,3
+Purple Sneakers,6405,20,Protection for all the sweat, https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQVlQpQlULhphplRcysE375sKUo8Z6mwCiCeFYYrZ-jmBbrA10QaA,4
+Silk Leotard,200,20,Let it shine,https://cdn-img-1.wanelo.com/p/d32/571/6b5/5e4564e57ff129f747ad555/x354-q80.jpg,2
+Head Band,699,20,No more sweat on your brows,https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIO2Fgsx7PxowCtLuzPtRLIR7yIam8ayH97oBYStJBSBbsqNVs,3
+Jazz legs,200,20,Let it shine,https://i.pinimg.com/originals/23/de/e8/23dee8bb0263a8507325f0cdbd8b37f9.jpg,2
diff --git a/db/seed_data/reviews.csv b/db/seed_data/reviews.csv
new file mode 100644
index 0000000000..0ab8fbed9b
--- /dev/null
+++ b/db/seed_data/reviews.csv
@@ -0,0 +1,7 @@
+rating,description,product_name
+1,Horrible product! Sweat everywhere!!,Sweaty Accessory
+2,"Eh, I'm not impressed. Not so great and I wouldn't buy it again.",Track Pants
+3,"This product is okay. Nothing to call home about, but it gets the job done.",Purple Leotard
+4,I like it! Very nice...minimal sweat.,White Sneakers
+5,This is a really fabulous product. It controlled my sweat!,Head Band
+2,"Meh! Too tight.",Silk Leotard
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..03c559e07a
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,161 @@
+require 'csv'
+
+CATEGORIES_FILE = Rails.root.join('db', 'seed_data', 'categories.csv')
+puts "Loading raw category data from #{CATEGORIES_FILE}"
+
+category_failures = []
+CSV.foreach(CATEGORIES_FILE, :headers => true) do |row|
+ category = Category.new
+ category.name = row['name']
+ successful = category.save
+ if !successful
+ category_failures << category
+ puts "Failed to save category: #{category.inspect}"
+ else
+ puts "Created category: #{category.inspect}"
+ end
+end
+
+puts "Added #{Category.count} category records"
+puts "#{category_failures.count} categories failed to save"
+
+
+
+MERCHANTS_FILE = Rails.root.join('db', 'seed_data', 'merchants.csv')
+puts "Loading raw merchant data from #{MERCHANTS_FILE}"
+
+merchant_failures = []
+CSV.foreach(MERCHANTS_FILE, :headers => true) do |row|
+ merchant = Merchant.new
+ merchant.username = row['username']
+ merchant.email = row['email']
+ merchant.uid = row['uid']
+ merchant.provider = row['provider']
+ successful = merchant.save
+ if !successful
+ merchant_failures << merchant
+ puts "Failed to save merchant: #{merchant.inspect}"
+ else
+ puts "Created merchant: #{merchant.inspect}"
+ end
+end
+
+puts "Added #{Merchant.count} merchant records"
+puts "#{merchant_failures.count} merchants failed to save"
+
+
+
+ORDERS_FILE = Rails.root.join('db', 'seed_data', 'orders.csv')
+puts "Loading raw order data from #{ORDERS_FILE}"
+
+order_failures = []
+CSV.foreach(ORDERS_FILE, :headers => true) do |row|
+ order = Order.new
+ order.status = row['status']
+ order.name = row['name']
+ order.email = row['email']
+ order.address = row['address']
+ order.cc_num = row['cc_num']
+ order.expiry_date = row['expiry_date']
+ order.cc_cvv = row['cc_cvv']
+ order.zip = row['zip']
+ order.total = row['total']
+ successful = order.save
+ if !successful
+ order_failures << order
+ puts "Failed to save order: #{order.inspect}"
+ else
+ puts "Created order: #{order.inspect}"
+ end
+end
+
+puts "Added #{Order.count} order records"
+puts "#{order_failures.count} orders failed to save"
+
+
+
+PRODUCTS_FILE = Rails.root.join('db', 'seed_data', 'products2.csv')
+puts "Loading raw category data from #{PRODUCTS_FILE}"
+
+product_failures = []
+CSV.foreach(PRODUCTS_FILE, :headers => true) do |row|
+ product = Product.new
+ product.name = row['name']
+ product.price = row['price']
+ product.available = row['available']
+ product.description = row['description']
+ product.photo = row['photo']
+ product.merchant_id = row['merchant']
+ successful = product.save
+ if !successful
+ product_failures << product
+ puts "Failed to save product: #{product.inspect}"
+ else
+ puts "Created product: #{product.inspect}"
+ end
+end
+
+puts "Added #{Product.count} product records"
+puts "#{product_failures.count} products failed to save"
+
+
+
+
+REVIEWS_FILE = Rails.root.join('db', 'seed_data', 'reviews.csv')
+puts "Loading raw review data from #{REVIEWS_FILE}"
+
+review_failures = []
+CSV.foreach(REVIEWS_FILE, :headers => true) do |row|
+ review = Review.new
+ review.rating = row['rating']
+ review.description = row['description']
+ product = Product.find_by(name: row['product_name'])
+ review.product_id = product.id
+ successful = review.save
+ if !successful
+ review_failures << review
+ puts "Failed to save review: #{review.inspect}"
+ else
+ puts "Created review: #{review.inspect}"
+ end
+end
+
+puts "Added #{Review.count} review records"
+puts "#{review_failures.count} reviews failed to save"
+
+
+
+CATEGORIESPRODUCTS_FILE = Rails.root.join('db', 'seed_data', 'categories-products.csv')
+puts "Loading raw categories_products data from #{CATEGORIESPRODUCTS_FILE}"
+
+
+CSV.foreach(CATEGORIESPRODUCTS_FILE, :headers => true) do |row|
+ category = Category.find_by(name: row['category_name'])
+ product = Product.find_by(name: row['product_name'])
+ category.products << product
+end
+
+puts "done with categories-products"
+
+
+
+ORDERSPRODUCTS_FILE = Rails.root.join('db', 'seed_data', 'orders-products.csv')
+puts "Loading raw orders_products data from #{ORDERSPRODUCTS_FILE}"
+
+orderproduct_failures = []
+CSV.foreach(ORDERSPRODUCTS_FILE, :headers => true) do |row|
+ order_product = OrderProduct.new
+ order_product.order_id = Order.find(row['order_id']).id
+ order_product.product_id = Product.find_by(name: row['product_name']).id
+ order_product.quantity = row['quantity']
+ successful = order_product.save
+ if !successful
+ orderproduct_failures << order_product
+ puts "Failed to save order_product: #{order_product.inspect}"
+ else
+ puts "Created order_product: #{order_product.inspect}"
+ end
+end
+
+puts "Added #{OrderProduct.count} order_product records"
+puts "#{orderproduct_failures.count} order_product records failed to save"
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/controllers/carts_controller_test.rb b/test/controllers/carts_controller_test.rb
new file mode 100644
index 0000000000..f6b1fd8761
--- /dev/null
+++ b/test/controllers/carts_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe CartsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb
new file mode 100644
index 0000000000..d57d338ee5
--- /dev/null
+++ b/test/controllers/categories_controller_test.rb
@@ -0,0 +1,39 @@
+require "test_helper"
+
+describe CategoriesController do
+
+ describe "index" do
+ it "sends a success reponse when there are many categories" do
+ Category.count.must_be :>, 0
+ get categories_path
+ must_respond_with :success
+ end
+
+ it "sends a success response when there are no categories" do
+ # destroy all products before destroying all categories
+ Product.destroy_all
+ Category.destroy_all
+ Category.count.must_equal 0
+ get merchants_path
+ must_respond_with :success
+ end
+ end
+
+ describe "create" do
+ it "saves a valid category" do
+ category_data = {name: 'new category'}
+ merchant = Merchant.first
+ old_category_count = Category.count
+
+ Category.new(category_data).must_be :valid?
+ login(merchant)
+
+ post categories_path, params: {category: category_data}
+
+ must_respond_with :redirect
+ must_redirect_to merchant_path(id: merchant.id)
+ Category.count.must_equal old_category_count + 1
+ end
+ end
+
+end
diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb
new file mode 100644
index 0000000000..230f0c5710
--- /dev/null
+++ b/test/controllers/merchants_controller_test.rb
@@ -0,0 +1,50 @@
+require "test_helper"
+require 'pry'
+describe MerchantsController do
+
+ describe "index" do
+ it "sends a success reponse when there are many merchants" do
+ Merchant.count.must_be :>, 0
+ get merchants_path
+ must_respond_with :success
+ end
+
+ it "sends a success response when there are no merchants" do
+ # destroy all products before destroying all merchants due to foreign key constraint
+ Product.destroy_all
+ Merchant.destroy_all
+ Merchant.count.must_equal 0
+ get merchants_path
+ must_respond_with :success
+ end
+
+ end
+
+ describe "new" do
+ it "sends a success response" do
+ get new_merchant_path
+ must_respond_with :found
+ end
+ end
+
+ describe "show" do
+ it "sends a success response if the merchant exists in the database" do
+ merchant = Merchant.first
+
+ merchant.must_be :valid?
+
+ get merchant_path(merchant)
+
+ must_respond_with :found
+ end
+
+ it "sends not_found if the merchant does not exist in the database" do
+ merchant = Merchant.last.id + 1
+
+ get merchant_path(merchant)
+
+ must_redirect_to root_path
+ end
+ end
+
+end
diff --git a/test/controllers/order_products_controller_test.rb b/test/controllers/order_products_controller_test.rb
new file mode 100644
index 0000000000..b4e157b21c
--- /dev/null
+++ b/test/controllers/order_products_controller_test.rb
@@ -0,0 +1,61 @@
+require "test_helper"
+require 'pry'
+describe OrderProductsController do
+
+ describe 'create' do
+
+ it "can create an OrderProduct with valid data" do
+ order = Order.first
+
+ item_data = {
+ order_id: order.id,
+ quantity: 10,
+ product_id: Product.first.id
+ }
+
+ # equals 0
+ old_count = order.order_products.count
+
+ post order_products_path, params: { order_product: item_data }
+
+ must_respond_with :redirect
+ must_redirect_to products_path
+
+ # still equals 0, not saving
+ order.order_products.count.must_equal old_count + 1
+ end
+
+ it "does not create an OrderProduct with incomplete data" do
+ order = Order.first
+
+ item_data = {
+ quantity: 10,
+ }
+ old_count = order.order_products.count
+
+ post order_products_path, params: { order_product: item_data }
+
+ must_respond_with :bad_request
+ # still equals 0, not saving
+ order.order_products.count.must_equal old_count
+ end
+
+ end
+
+ describe 'update' do
+
+ it "updates the quantity of an existing OrderProduct with a valid number" do
+ order = Order.first
+
+ order_product = OrderProduct.create!(quantity: 1, order_id: order.id, product_id: Product.first.id)
+
+ item_data = order_product.attributes
+ item_data[:quantity] = 2
+
+ patch order_product_path(order_product), params: { order_product: item_data }
+
+ end
+
+ end
+
+end
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
new file mode 100644
index 0000000000..eb3408d086
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,95 @@
+require "test_helper"
+
+describe OrdersController do
+
+ describe 'show' do
+
+ it "succeeds if order exists" do
+ get order_path(Order.first)
+ must_respond_with :found
+ end
+
+ it "sends not_found if order doesn't exit" do
+ merchant = Merchant.first
+ login(merchant)
+ order_id = Order.last.id + 5
+
+ get order_path(order_id)
+
+ must_respond_with :not_found
+ end
+
+ end
+
+ describe 'create' do
+
+ it "can add a valid order" do
+ order_data = {
+ status: "in progress",
+ name: "Max",
+ email: "max@adaacademy.com",
+ # address zip
+ address: "2627 107th Ave NE Bellevue, WA 98004",
+ cc_num: "1234567891011121",
+ expiry_date: "1020",
+ cc_cvv: "123",
+ # billing zip
+ zip: "98004"
+ }
+ old_order_count = Order.count
+
+ Order.new(order_data).must_be :valid?
+
+ post orders_path, params: { order: order_data}
+
+ must_respond_with :redirect
+ must_redirect_to order_path(Order.last.id)
+
+ # 2 bc a new cart is created when order_path is run
+ # after it's complete there's an empty cart in addition to the order added
+ Order.count.must_equal old_order_count + 2
+ Order.last.name.must_equal order_data[:name]
+ end
+
+ # cart is created with only some of the payment validation errors
+ # this can't actually occur on the website bc validations are ran when payment details are processed
+ it "accepts invalid order bc it will hit validations at payment" do
+ order_data = {
+ name: "Max",
+ email: "max@adaacademy.com",
+ # address zip
+ address: "2627 107th Ave NE Bellevue, WA 98004",
+ cc_num: nil,
+ expiry_date: "1020",
+ cc_cvv: "123",
+ # billing zip
+ zip: "98004",
+ }
+ old_order_count = Order.count
+
+ Order.new(order_data).must_be :valid?
+
+ post orders_path, params: { order: order_data }
+
+ must_respond_with :redirect
+ must_redirect_to order_path(Order.last.id)
+
+ # 2 bc a new cart is created when order_path is run
+ # after it's complete there's an empty cart in addition to the order added
+ Order.count.must_equal old_order_count + 2
+ end
+
+ end
+
+ describe "index" do
+ it "finds merchants orders" do
+ merchant = Merchant.first
+ login(merchant)
+ order_id = Order.last
+
+ get merchant_orders_path(merchant)
+ must_respond_with :success
+ end
+ end
+
+end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
new file mode 100644
index 0000000000..8f4721d0ed
--- /dev/null
+++ b/test/controllers/products_controller_test.rb
@@ -0,0 +1,206 @@
+require "test_helper"
+
+describe ProductsController do
+
+ describe 'index' do
+ it "sends a success response where there are products" do
+
+ Product.count.must_be :>,0
+
+ get products_path
+
+ must_respond_with :success
+
+ end
+
+ it "sends a success response when there are no products" do
+ Product.destroy_all
+
+ get products_path
+
+ Product.count.must_equal 0
+ must_respond_with :success
+ end
+ end
+
+ describe 'new' do
+ it "sends a success response when merchant adds a new product" do
+ login(Merchant.first)
+ get new_product_path
+ must_respond_with :success
+ end
+
+ # it "sends bad request when a guest tries to add a new product" do
+ # get new_product_path
+ # must_respond_with :bad_request
+ # end
+ end
+
+ describe 'create' do
+
+ it "can add a product with valid data" do
+ merchant = Merchant.first
+ product_data = {
+ name: 'random',
+ price: 3,
+ available: 4,
+ merchant_id: merchant.id
+ }
+ old_product_count = Product.count
+
+ product = Product.new(product_data)
+
+ product.must_be :valid?
+
+ post products_path, params: { product: product_data}
+
+ must_respond_with :redirect
+
+ must_redirect_to merchant_products_path(merchant.id)
+
+ Product.count.must_equal old_product_count + 1
+
+ Product.last.name.must_equal product_data[:name]
+ end
+
+ it "renders error for invalid data" do
+
+ product_data = {
+ merchant_id: Merchant.first.id
+ }
+ old_product_count = Product.count
+
+ product = Product.new(product_data)
+
+ product.wont_be :valid?
+
+ post products_path, params: { product: product_data}
+
+ must_respond_with :bad_request
+
+ Product.count.must_equal old_product_count
+ end
+ end
+
+ describe 'edit' do
+
+ it "send success if form loads" do
+ merchant = Merchant.first
+ login(merchant)
+ get edit_product_path(Product.find_by(merchant: merchant))
+ must_respond_with :success
+ end
+
+ it "sends not_found if product does not exist" do
+
+ product_id = Product.last.id + 1
+
+ get edit_product_path(product_id)
+ must_respond_with :not_found
+
+ end
+ end
+
+ describe 'show' do
+ it "send success if the product exists" do
+
+ get product_path(Product.first)
+ must_respond_with :success
+ end
+
+ it "sends not_found if product does not exist" do
+
+ product_id = Product.last.id + 1
+
+ get product_path(product_id)
+ must_respond_with :not_found
+
+ end
+ end
+
+ describe 'update' do
+ it "updates existing product with valid data" do
+
+ # product = Product.first
+ # product_data = product.attributes
+ #
+ # product_data[:name] = "sweaty stuff"
+ #
+ # product.assign_attributes(product_data)
+ #
+ # product.must_be :valid?
+ #
+ # patch product_path(product), params: { product: product_data }
+ #
+ # must_redirect_to product_path(product)
+ #
+ # product.reload
+ # product.name.must_equal product_data[:name]
+ end
+
+ it "sends bad_request when data is invalid" do
+
+ merchant = Merchant.first
+ login(merchant)
+
+ product = Product.find_by(merchant: merchant)
+
+ product_data = product.attributes
+
+ product_data[:name] = ""
+
+ product.assign_attributes(product_data)
+
+ product.wont_be :valid?
+
+ patch product_path(product), params: { product: product_data }
+
+ must_respond_with :bad_request
+
+ product.reload
+ product.name.wont_equal product_data[:name]
+ end
+
+ it "sends not_found for a product that does not exist" do
+
+ product_id = Product.last.id + 1
+
+ patch product_path(product_id)
+
+ must_respond_with :not_found
+ end
+
+ end
+
+ describe 'destroy' do
+ it "can destroy a product" do
+
+ merchant = Merchant.first
+ login(merchant)
+
+ product_id = Product.find_by(merchant: merchant).id
+
+ old_product_count = Product.count
+
+ delete product_path(product_id)
+
+ must_respond_with :redirect
+ must_redirect_to products_path
+
+ Product.count.must_equal old_product_count - 1
+ end
+
+ it "sends not_found when product does not exist" do
+
+ product_id = Product.first.id + 1
+ old_product_count = Product.count
+
+ delete product_path(product_id)
+
+ must_respond_with :not_found
+
+ Product.count.must_equal old_product_count
+
+ end
+ end
+end
diff --git a/test/controllers/reviews_controller_test.rb b/test/controllers/reviews_controller_test.rb
new file mode 100644
index 0000000000..f86912b9a2
--- /dev/null
+++ b/test/controllers/reviews_controller_test.rb
@@ -0,0 +1,34 @@
+require "test_helper"
+require 'pry'
+
+describe ReviewsController do
+ describe 'create' do
+ it "creates a review with valid data" do
+ product_id = Product.first.id
+ review_data = { rating: 5, description: 'review description', product_id: product_id }
+
+ old_review_count = Review.count
+
+ Review.new(review_data).must_be :valid?
+ post product_reviews_path(product_id), params: { review: review_data}
+
+ must_respond_with :redirect
+ must_redirect_to product_path(product_id)
+ Review.count.must_equal old_review_count + 1
+ Review.last.description.must_equal 'review description'
+ end
+
+ it "responds with bad request for missing input" do
+ product_id = Product.first.id
+ review_data = { description: 'review description', product_id: product_id }
+
+ old_review_count = Review.count
+
+ Review.new(review_data).wont_be :valid?
+ post product_reviews_path(product_id), params: { review: review_data}
+
+ must_respond_with :bad_request
+ Review.count.must_equal old_review_count
+ end
+ end
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 0000000000..0a68cade44
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,71 @@
+require "test_helper"
+
+describe SessionsController do
+ describe 'create action via auth_callback_path' do
+ it "creates a new DB entry for a new user" do
+ merchant = Merchant.new(
+ provider: 'github',
+ uid: 0000,
+ email: 'test@test.org',
+ username: 'testuser'
+ )
+
+ merchant.must_be :valid?
+ old_merchant_count = Merchant.count
+
+ login(merchant)
+
+ Merchant.count.must_equal old_merchant_count + 1
+ session[:merchant_id].must_equal Merchant.last.id
+ end
+ it "cannot create new user due to invalid data" do
+ merchant = Merchant.new(
+ provider: 'github',
+ uid: 0000,
+ username: 'testuser'
+ )
+
+ merchant.wont_be :valid?
+ old_merchant_count = Merchant.count
+
+ login(merchant)
+
+ Merchant.count.must_equal old_merchant_count
+ end
+
+ it "logs in existing merchant" do
+ merchant = Merchant.first
+ old_merchant_count = Merchant.count
+
+ login(merchant)
+
+ session[:merchant_id].must_equal Merchant.first.id
+ must_redirect_to merchant_path(Merchant.first.id)
+ Merchant.count.must_equal old_merchant_count
+ end
+
+ it "flashes error for invalid info in callback path" do
+ merchant = Merchant.new(
+ provider: 'github',
+ email: 'test@test.org',
+ username: 'testuser'
+ )
+
+ login(merchant)
+
+ flash[:error].must_equal "Could not authenticate user via Github"
+ must_redirect_to root_path
+ end
+ end
+
+ describe 'destroy action' do
+ it "logs user out" do
+ merchant = Merchant.first
+
+ login(merchant)
+ logout(merchant)
+
+ session[:merchant_id].must_be_nil
+ end
+ end
+end
diff --git a/test/fixtures/.keep b/test/fixtures/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml
new file mode 100644
index 0000000000..e49dbb20b1
--- /dev/null
+++ b/test/fixtures/categories.yml
@@ -0,0 +1,19 @@
+# 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
+
+
+shorts:
+ name: Shorts
+
+shirts:
+ name: Shirts
+
+pants:
+ name: Pants
+
+accessories:
+ name: Accessories
+
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
new file mode 100644
index 0000000000..2739b20ae7
--- /dev/null
+++ b/test/fixtures/merchants.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+merchant_one:
+ username: merchant_one
+ email: merchant_one@gmail.com
+ uid: 1
+ provider: github
+
+merchant_two:
+ username: merchant_two
+ email: merchant_two@gmail.com
+ uid: 2
+ provider: github
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..de6207ff56
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,25 @@
+# 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
+
+basic_order:
+ status: in progress
+ name: Dan
+ email: dan@adaacademy.org
+ address: 1215 4th Ave, Seattle, WA 98161
+ cc_num: 1234567891011121
+ expiry_date: 1020
+ cc_cvv: 111
+ zip: 98161
+
+paid_order:
+ status: in progress
+ name: Kari
+ email: kari@adaacademy.org
+ address: 3333 8th Ave, Seattle, WA 98161
+ cc_num: 1234567892323232
+ expiry_date: 0120
+ cc_cvv: 101
+ zip: 98111
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
new file mode 100644
index 0000000000..5564084b12
--- /dev/null
+++ b/test/fixtures/products.yml
@@ -0,0 +1,22 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+hb:
+ name: headband
+ price: 10
+ available: 6
+ merchant: merchant_one
+ categories: accessories
+
+water:
+ name: bottled water
+ price: 1
+ available: 100
+ merchant: merchant_two
+ categories: accessories
+
+pants:
+ name: sweatpants
+ price: 20
+ available: 10
+ merchant: merchant_two
+ categories: pants
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..de9a25ae04
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,15 @@
+# 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:
+ rating: 1
+ description: This review is for product 1
+ product: hb
+
+two:
+ rating: 2
+ description: This is review is for product 2
+ product: water
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/models/category_test.rb b/test/models/category_test.rb
new file mode 100644
index 0000000000..04adf4721a
--- /dev/null
+++ b/test/models/category_test.rb
@@ -0,0 +1,15 @@
+require "test_helper"
+
+describe Category do
+ let(:category) { Category.new(name: "accessories") }
+
+ it "must be valid" do
+ value(category).must_be :valid?
+ end
+
+ it "must be invalid without a name" do
+ category = Category.new(name: nil)
+ category.wont_be :valid?
+ end
+
+end
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
new file mode 100644
index 0000000000..5854b7187a
--- /dev/null
+++ b/test/models/merchant_test.rb
@@ -0,0 +1,81 @@
+require "test_helper"
+
+describe Merchant do
+
+ describe "validations" do
+
+ before do
+ @merchant = merchants(:merchant_one)
+ end
+
+ it "is valid with all the required fields" do
+ result = @merchant.valid?
+
+ value(result).must_equal true
+ end
+
+ it "is invalid without a username" do
+ @merchant.username = nil
+
+ result = @merchant.valid?
+
+ value(result).must_equal false
+ end
+
+ it "is invalid without an email" do
+ @merchant.email = nil
+
+ result = @merchant.valid?
+
+ value(result).must_equal false
+ end
+
+ it "is invalid when there is a duplicate username" do
+ duplicate = merchants(:merchant_two)
+ duplicate.username = "merchant_one"
+
+ result = duplicate.valid?
+
+ value(result).must_equal false
+ end
+
+ it "is invalid when there is a duplicate email" do
+ duplicate = merchants(:merchant_two)
+ duplicate.email = "merchant_one@gmail.com"
+
+ result = duplicate.valid?
+
+ value(result).must_equal false
+ end
+
+ end
+
+ describe 'relations' do
+
+ before do
+ @merchant = merchants(:merchant_one)
+ end
+
+ it "has a list of products to sell" do
+ @merchant.must_respond_to :products
+ @merchant.products.each do |product|
+ product.must_be_kind_of Product
+ end
+ end
+
+ it "has many orders" do
+ @merchant.must_respond_to :orders
+ @merchant.orders.each do |order|
+ order.must_be_kind_of Order
+ end
+ end
+
+ it "has many product categories" do
+ @merchant.product_categories.each do |category|
+ category.must_be_kind_of Category
+ end
+ end
+
+ end
+
+end
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..c5b14b12cb
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,180 @@
+require "test_helper"
+
+describe Order do
+
+ describe "validations" do
+ before do
+ @order = orders(:basic_order)
+ @progress_order = Order.new(status: "in progress")
+ end
+
+ it 'can be created with all required fields' do
+ result = @order.valid?
+ result.must_equal true
+ end
+
+ # WHEN IN PROGRESS IT....
+ it "requires a name" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :name
+ end
+
+ # email
+ it "requires an email" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :email
+ end
+
+ it "requires an @ sign in the email when in progress" do
+ @progress_order.email = "emailnoatsign"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :email
+ end
+
+ # address
+ it "requires an address" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :address
+ end
+
+ it "requires a number at beginning of address" do
+ @progress_order.address = "not starting w/ numbers"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :address
+ end
+
+ # cc_num
+ it "requires a cc_num" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_num
+ end
+
+ it "requires 16 digits" do
+ @progress_order.cc_num = "111222"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_num
+ end
+
+ it "requires digits only - test with letters only" do
+ @progress_order.cc_num = "no numbersssssss"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_num
+ end
+
+ it "requires digits only - test with some letters" do
+ @progress_order.cc_num = "1letters23456789"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_num
+ end
+
+ # cc_cvv
+ it "requires a cc_cvv" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_cvv
+ end
+
+ it "requires 3 digits" do
+ @progress_order.cc_cvv = "1234"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_cvv
+ end
+
+ it "requires digits only - test with letters only" do
+ @progress_order.cc_cvv = "xxx"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_cvv
+ end
+
+ it "requires digits only - test with some letters" do
+ @progress_order.cc_cvv = "1x2"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :cc_cvv
+ end
+
+ # zip
+ it "requires a zip" do
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :zip
+ end
+
+ it "requires digits only - test with letters only" do
+ @progress_order.zip = "xxxxx"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :zip
+ end
+
+ it "requires digits only - test with some letters" do
+ @progress_order.zip = "1x3x5"
+ @progress_order.valid?.must_equal false
+ @progress_order.errors.messages.must_include :zip
+ end
+ end
+
+ # describe "relations" do
+ # it "has a merchant" do
+ # end
+ #
+ # it "has a list of products" do
+ # # order = orders(:order_one)
+ # # order.must_respond_to :products
+ # # order.products.each do |product|
+ # # product.must_be_kind_of Product
+ # end
+ # end
+
+ describe 'order_total' do
+ before do
+ @paid_order = orders(:paid_order)
+ @p_one = products(:hb)
+ @p_two = products(:water)
+ @p_three = products(:pants)
+ end
+
+ it "returns zero with no products" do
+ @paid_order.order_total.must_equal 0
+ end
+
+ it "calculates total with one of one product" do
+ OrderProduct.create(order: @paid_order, product: @p_one, quantity: 1)
+ @paid_order.order_total.must_equal 10
+ end
+
+ it "calculates total with many of one product" do
+ OrderProduct.create(order: @paid_order, product: @p_one, quantity: 4)
+ @paid_order.order_total.must_equal 40
+ end
+
+ it "calculates total with many products" do
+ OrderProduct.create(order: @paid_order, product: @p_one, quantity: 1)
+ OrderProduct.create(order: @paid_order, product: @p_two, quantity: 3)
+ OrderProduct.create(order: @paid_order, product: @p_three, quantity: 5)
+
+ @paid_order.order_total.must_equal 113
+ end
+ end
+
+ describe 'update_status' do
+
+ it "updates status when nil" do
+ new_order = Order.new()
+ new_order.save
+
+ new_order.status == nil
+
+ new_order.update_status
+
+ new_order.status.must_equal "pending"
+ end
+
+ it "doesn't update status when not nil" do
+ order = Order.create(status: 'notnil')
+ order.status.must_equal 'notnil'
+
+ order.update_status
+
+ order.status.must_equal 'notnil'
+ end
+
+ end
+
+end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
new file mode 100644
index 0000000000..2fc6aaac3c
--- /dev/null
+++ b/test/models/product_test.rb
@@ -0,0 +1,111 @@
+require "test_helper"
+
+describe Product do
+ describe 'validations' do
+ before do
+
+ @product = Product.new(
+ name: 'headband',
+ price: 8,
+ available: 300)
+ end
+
+ it "can be created with all required fields" do
+ # result = @product.valid?
+ #
+ # result.must_equal true
+ end
+
+ it "is invalid without a name" do
+ @product.name = nil
+
+ result = @product.valid?
+ result.must_equal false
+ @product.errors.messages.must_include :name
+ end
+
+ it "is invalid with a duplicate name" do
+ dup_product = Product.first
+
+ @product.name = dup_product.name
+
+ result = @product.valid?
+ result.must_equal false
+ @product.errors.messages.must_include :name
+ end
+
+ it "it is invalid without a price" do
+ @product.price = nil
+
+ result = @product.valid?
+ result.must_equal false
+ @product.errors.messages.must_include :price
+ end
+
+ it "it is invaild if price is 0 or less" do
+ @product.price = -2
+
+ result = @product.valid?
+ result.must_equal false
+ @product.errors.messages.must_include :price
+ end
+
+ it "it is invalid if price is not an integer" do
+ @product.price = 'hi'
+
+ result = @product.valid?
+ result.must_equal false
+ @product.errors.messages.must_include :price
+
+ end
+ end
+
+ describe 'relationships' do
+ before do
+ @product = Product.new(
+ name: 'headband',
+ price: 8,
+ available: 300,
+ merchant_id: Merchant.first.id)
+ end
+
+ it "connects merchant and merchant_id" do
+ merchant = Merchant.first
+
+ @product.merchant = merchant
+
+ @product.must_respond_to :merchant
+ @product.merchant_id.must_equal merchant.id
+ @product.merchant.must_be_kind_of Merchant
+ end
+
+ it "connects categories and category_ids" do
+
+ category = Category.first
+
+ @product.categories << category
+
+ @product.must_respond_to :categories
+ @product.category_ids.must_include category.id
+
+ end
+
+ it "has a list of categories" do
+ @product.must_respond_to :categories
+
+ @product.categories.each do |category|
+ category.must_be_kind_of Categories
+ end
+ end
+
+ it "has a list of order_products" do
+ @product = Product.first
+
+ @product.must_respond_to :order_products
+
+ @product.order_products.each do |order_product|
+ order_product.must_be_kind_of Order_product
+ end
+ end
+ end
+end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..a94442361d
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,92 @@
+require "test_helper"
+
+describe Review do
+ describe 'validations' do
+ it "creates a review with complete form data" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(rating: 5, description: 'test review', product_id: product_id )
+ review.save
+
+ review.valid?.must_equal true
+ Review.count.must_equal old_review_count + 1
+ Review.last.description.must_equal 'test review'
+ end
+
+ it "rejects a review with non-numeric rating" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(rating: '10', description: 'test review', product_id: product_id )
+ review.save
+
+ review.valid?.must_equal false
+ Review.count.must_equal old_review_count
+ end
+
+ it "rejects a review without description" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(rating: 1, product_id: product_id )
+ review.save
+
+ review.valid?.must_equal false
+ Review.count.must_equal old_review_count
+ end
+
+ it "rejects a review without rating" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(description: 'test review', product_id: product_id )
+ review.save
+
+ review.valid?.must_equal false
+ Review.count.must_equal old_review_count
+ end
+
+ it "rejects review with rating less than 1" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(rating: 0, description: 'test review', product_id: product_id )
+ review.save
+
+ review.valid?.must_equal false
+ Review.count.must_equal old_review_count
+ end
+
+ it "rejects review with rating greater than 5" do
+ product_id = Product.first.id
+ old_review_count = Review.count
+
+ review = Review.new(rating: 6, description: 'test review', product_id: product_id )
+ review.save
+
+ review.valid?.must_equal false
+ Review.count.must_equal old_review_count
+ end
+ end
+
+
+ it "connects merchant and merchant_id" do
+ merchant = Merchant.first
+ product = Product.find_by(merchant_id: Merchant.first.id)
+
+ product.must_respond_to :merchant
+ product.merchant_id.must_equal merchant.id
+ product.merchant.must_be_kind_of Merchant
+ end
+
+
+ describe 'relations' do
+ it "must respond to product" do
+ review = Review.first
+
+ review.must_respond_to :product
+ review.product.must_be_kind_of Product
+ end
+ end
+end
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..0bf1f053e3
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,57 @@
+require "simplecov"
+SimpleCov.start :rails do
+ add_filter "/channels/"
+ add_filter "/jobs/"
+ add_filter "/mailers/"
+end
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters"
+
+# 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...
+ def setup
+ OmniAuth.config.test_mode = true
+ end
+
+ def mock_auth_hash(user)
+ return {
+ provider: user.provider,
+ uid: user.uid,
+ info: {
+ email: user.email,
+ nickname: user.username
+ }
+ }
+ end
+
+ def login(user)
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+ end
+
+ def logout(user)
+ OmniAuth.config.mock_auth[:github] = nil
+ delete logout_path
+ end
+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