diff --git a/app/views/pages/contact_us.html.erb b/app/views/pages/contact_us.html.erb
new file mode 100644
index 0000000000..6a1e90b6aa
--- /dev/null
+++ b/app/views/pages/contact_us.html.erb
@@ -0,0 +1,64 @@
+
+
About us
+
Our Mission
+
+
+
+
We are serious about pasta.
+
At Spagh-ettsi, we care deeply about the health, well-being and culinary delight of our customers. We share a passion for – and commitment to – a philosophy of wholesome nutrition.
+
We carefully pick the best products that we can find based on a few important criteria: wholesome and pure, fresh and full-flavored. Wherever feasible, we seek out organic products, however, we do not limit ourselves to a strict, “organic only” platform. In addition, we are dedicated to educating our customers about the benefits of foods free of artificial, industrial additives
+
We are zealous in our search for and creation of full-flavored foods. And, we get great satisfaction out of sharing our new finds and creations with others.
+
+
+
+
+
Our Team
+
+
+
+
Amanda
+
Chief Pasta Officer
+
+
+
+
+
+
Daniela
+
Founder & Pasta Innovator
+
+
+
+
+
+
Hannah
+
Director of Pasta Development
+
+
+
+
+
+
Christina
+
Chief Gluten-Free Officer
+
+
+
+
+
+
+
+
+
Talk pasta to us!
+
+
diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb
new file mode 100644
index 0000000000..4fb6683cfc
--- /dev/null
+++ b/app/views/pages/home.html.erb
@@ -0,0 +1,165 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= image_tag("pg7.jpg", alt: "plate of pasta") %>
+
+
+ <%= link_to "Dashboard", dashboard_path %>
+ <%= link_to "Add a Product", new_product_path %>
+ <%= link_to "My Products", merchant_my_products_path %>
+ <%= link_to "My Orders", merchant_orders_path %>
+
diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb
new file mode 100644
index 0000000000..216e0f2f6a
--- /dev/null
+++ b/app/views/products/edit.html.erb
@@ -0,0 +1,4 @@
+<%= render partial: "form", locals: {origin: 'edit', form_intro: 'Edit an Existing Product!',
+ quote: "Spaghetti is good with ranch, and spaghetti is good with sugar.
+ You put all of that together and make a sandwich out of it, and you get greatness.
+ People shouldn't judge unless they try it", quoteauthor: "--- Terry Rozier" } %>
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
new file mode 100644
index 0000000000..10e41965e1
--- /dev/null
+++ b/app/views/products/index.html.erb
@@ -0,0 +1,59 @@
+
+
+ <%= link_to "Dashboard", dashboard_path %>
+ <%= link_to "Add a Product", new_product_path %>
+ <%= link_to "My Products", merchant_my_products_path %>
+ <%= link_to "My Orders", merchant_orders_path %>
+
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 0000000000..f19acf5b5c
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+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..94fd4d7977
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+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..58bfaed518
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+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')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+ 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..460dd565b4
--- /dev/null
+++ b/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path('..', __dir__)
+Dir.chdir(APP_ROOT) do
+ begin
+ exec "yarnpkg", *ARGV
+ 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..fa35ab4973
--- /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 SpaghEttsi
+ 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.2
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration can go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded after loading
+ # the framework and any gems in your application.
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 0000000000..b9e460cef3
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,4 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000000..04767e4e87
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: spagh-ettsi_production
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
new file mode 100644
index 0000000000..3a47d52bd1
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+k1kFfWDmq2biOGljgYWVRsffw/KAyg2RTIi1R99w1mqgCuXwJ8CJFW7u0xc72VJh+bTrtIIpRLjyfVQskqXbrktT0MMsPBqniMUCfnH9aCdweih6i7jllcThmVoyYJKxvz9d/MZ0cYfcfDp4unNY5bs87cR8F8e39M1gvALWwj6gtoUHUN5VqYSdU3ZvB/lzCdTkAgQsyVWzRoTn4p2m/sQpH8LIye84W+SpC0BtM8tCWcBJjvqPAkgsNoQYnIEdgvsfMxOgopqBX+AWScUocncpYp/Y7ppoglnsGmknSYFXZ/B9+GZ17JQteYIAW4xpB6R9iaguePYeY/4EGbVSLmYu/ra0ZTWYHy6q93bo8mP058RrLLZrQJssNfTGjME8oK0ZQeMurT7eff9GAEZ5lF5EpeWRBKOErEAh--kZj56Dq2i1xOuoXB--+WEEl+0JSyi7DckTdqAZCg==
\ No newline at end of file
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000000..a20237c4f0
--- /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: spagh-ettsi_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: spagh-ettsi
+
+ # 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: spagh-ettsi_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: spagh-ettsi_production
+ username: spagh-ettsi
+ password: <%= ENV['SPAGH-ETTSI_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..1311e3e4ef
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,61 @@
+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.
+ # Run rails dev:cache to toggle caching.
+ 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.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # 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
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # 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..a1ca265dbe
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,94 @@
+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
+
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = 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
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # 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 = "spagh-ettsi_#{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..0a38fd3ce9
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,46 @@
+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.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
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
+ 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/action_view.rb b/config/initializers/action_view.rb
new file mode 100644
index 0000000000..142d382f87
--- /dev/null
+++ b/config/initializers/action_view.rb
@@ -0,0 +1 @@
+Rails.application.config.action_view.form_with_generates_remote_forms = false
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/content_security_policy.rb b/config/initializers/content_security_policy.rb
new file mode 100644
index 0000000000..d3bcaa5ec8
--- /dev/null
+++ b/config/initializers/content_security_policy.rb
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy
+# For further information see the following documentation
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+# Rails.application.config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+
+# If you are using UJS then enable automatic nonce generation
+# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+# Report CSP violations to a specified URI
+# For further information see the following documentation:
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+# Rails.application.config.content_security_policy_report_only = true
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..bb776f6750
--- /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", callback_path:'/auth/github/callback'
+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..a5eccf816b
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,34 @@
+# 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.
+#
+# preload_app!
+
+# 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..2dad4c29ca
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,46 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ root 'pages#home'
+ get "/auth/:provider/callback", to: "sessions#create", as: 'auth_callback'
+ get '/dashboard', to: "users#dashboard", as: 'dashboard'
+ get '/pages/contact_us', to: 'pages#contact_us', as: 'contact_us'
+ delete "/logout", to: "sessions#destroy", as: "logout"
+ get '/shopping_cart', to: 'orders#shopping_cart', as: 'shopping_cart'
+ patch '/shopping_cart', to: 'order_products#update', as: 'order_product'
+ get '/checkout', to: 'orders#edit', as: 'checkout'
+ post '/checkout', to: 'orders#update'
+
+ get '/account', to: 'users#show', as: 'account'
+ patch '/product/:id', to: 'products#deactivate', as: 'deactivate_product'
+ patch '/users/:id', to: 'users#update', as: 'update_user'
+ post '/users/:id', to: 'users#update'
+ get '/merchant/orders', to: 'users#orders_index', as: 'merchant_orders'
+ get '/merchant/orders/:id', to: 'users#order_show', as: 'merchant_order'
+ patch '/merchant/orders/:id', to: 'orders#mark_as_shipped', as: 'mark_as_shipped'
+ get '/products_by_merchant', to: 'products#index_by_merchant', as: 'products_by_merchant' #should change this to products_index_by_merchant
+ get '/merchant/my_products', to: 'users#products_index', as: 'merchant_my_products'
+
+ get '/product/:id/reviews/new', to: 'reviews#new', as: 'new_product_review'
+ post '/product/:id/reviews/', to: 'reviews#create', as: 'create_review'
+ resources :products do
+ resources :reviews, only: [:index, :create]
+ end
+
+
+ resources :reviews, only: [:index, :new, :create]
+
+
+
+ resources :users, only: [:create, :show] #do
+ # resources :products, only: [:show, :edit]
+ # end
+ resources :addresses
+ resources :payments
+
+ resources :orders
+ resources :sessions, only: [:create, :destroy]
+ resources :order_products, only: [:create]
+ # resources :orders do
+ # resources :products, only: [:create]
+ # end
+end
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 0000000000..9fa7863f99
--- /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/config/storage.yml b/config/storage.yml
new file mode 100644
index 0000000000..d32f76e8fb
--- /dev/null
+++ b/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket
+
+# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/db/address_seeds.csv b/db/address_seeds.csv
new file mode 100644
index 0000000000..16b589324a
--- /dev/null
+++ b/db/address_seeds.csv
@@ -0,0 +1,21 @@
+user_id,first_name,last_name,street,street_2,city,state,zip
+6,Malinda,Smith,73094 Keira Shores,Apt. 320,Bartonfort,OK,79875
+9,Sean,Murazik,748 Bartell Mountains,Apt. 959,Windlerhaven,AZ,16790
+2,Kelly,Cormier,79946 Anna Stream,Apt. 237,Lloydstad,IL,96189
+15,Solomon,Balistreri,41093 Bailey Creek,Suite 129,Lake Feliceview,OK,24238
+9,Emory,Shields,4890 Kovacek Views,Apt. 775,Port Sadehaven,NV,23438
+19,Maximo,Schimmel,26934 Rolande Knoll,Suite 565,New Lizamouth,OH,14311
+1,Jude,Satterfield,4040 Maryam Motorway,Suite 513,New Kraigmouth,LA,93230
+18,Stephen,Jacobs,78156 Deonna Courts,Suite 233,Lake Regena,NH,13366
+20,Matt,Medhurst,1500 Cathie Terrace,Apt. 420,Lake Harrison,MD,36730
+10,Ira,Bahringer,66856 Leigh Fords,Apt. 869,South Lavon,SC,46067
+20,Mohamed,Herzog,763 Mosciski Cove,Apt. 784,South Yulanda,OH,89261
+17,Wilburn,Padberg,2971 Nicky Wells,Suite 282,Jodytown,WY,99912
+20,Cory,Gleichner,67856 Howell Valleys,Suite 596,Roryville,ID,14195
+7,Lin,Sporer,610 Rory Trafficway,Apt. 627,North Calandraborough,ME,78945
+16,Angel,Lubowitz,88326 Hildegarde Green,Apt. 188,South Janee,GA,53829
+20,Jimmy,Runte,19077 Borer Islands,Suite 127,South Margyville,MS,45979
+19,Owen,Legros,995 Hammes Causeway,Apt. 752,Raymondberg,TX,83075
+16,Deandre,Bartell,188 Stehr Parks,Suite 816,West Claretta,VT,53136
+1,Tristan,Mraz,937 Yee Fort,Apt. 652,North Mahalia,IL,51076
+3,Dusty,Moen,87314 Clifton Glen,Apt. 949,East See,SD,76376
diff --git a/db/generate_seeds.rb b/db/generate_seeds.rb
new file mode 100644
index 0000000000..6db3b8b7d8
--- /dev/null
+++ b/db/generate_seeds.rb
@@ -0,0 +1,140 @@
+require 'faker'
+require 'date'
+require 'csv'
+
+CSV.open('db/user_seeds.csv', "w", :write_headers=> true,
+ :headers => ["full_name", "email", "is_a_seller", "uid", "provider"]) do |csv|
+
+ 20.times do
+ full_name = Faker::Name.name
+ email = Faker::Internet.email("#{full_name.split}")
+ is_a_seller = true
+ uid = rand(11111111..99999999)
+ provider = %w(github twitter facebook google).sample
+
+ csv << [full_name, email, is_a_seller, uid, provider]
+ end
+end
+
+CSV.open('db/address_seeds.csv', "w", :write_headers=> true,
+ :headers => ["user_id", "first_name", "last_name", "street", "street_2", "city","state", "zip"]) do |csv|
+
+ 20.times do
+ user_id = rand(1..20)
+ first_name = Faker::Name.first_name
+ last_name = Faker::Name.last_name
+ street = Faker::Address.street_address
+ street_2 = Faker::Address.secondary_address
+ city = Faker::Address.city
+ state = Faker::Address.state_abbr
+ zip = rand(11111..99999)
+
+
+ csv << [user_id, first_name, last_name, street, street_2, city, state, zip]
+ end
+end
+
+CSV.open('db/payment_seeds.csv', "w", :write_headers=> true,
+ :headers => ["user_id", "address_id", "card_number", "expiration_date", "cvv", "card_type"]) do |csv|
+
+ 20.times do
+
+ user_id = rand(1..20)
+ address_id = rand(1..20)
+ card_number = rand(111111111111111..999999999999999)
+ expiration_date = Faker::Date.forward(600)
+ cvv = rand(111..9999)
+ card_type = %w(AMEX VISA MASTERCARD DISCOVER).sample
+
+
+ csv << [user_id, address_id, card_number, expiration_date, cvv, card_type]
+ end
+end
+
+
+CSV.open("db/product_seeds.csv", "w", :write_headers=> true,
+ :headers => ["category", "name", "user_id", "price_in_cents", "description", "quantity", "image_url"]) do |csv|
+ pasta = ["Callentani", "Capellini", "Ditalini", "Elbow", "Farfalle",
+ "Fettuccine", "Gemelli", "Gluten-free Shells", "Jumbo Shells", "Lasagna",
+ "Manicotti", "Medium Shells", "Orzo", "Pappardelle", "Pastina",
+ "Penne", "Ravioli", "Rotini", "Spaghetti", "Tortellini"]
+ images = ["callentani.jpg", "capellini.jpg", "ditalini.jpg", "elbow.jpg",
+ "farfalle.jpg", "fettuccine.jpg", "gemelli.jpg", "gluten-free.jpg",
+ "large-shell.jpg", "lasagna.jpg", "manicotti.jpg", "medium-shell.jpg",
+ "orzo.jpg", "pappardelle.jpg", "pastina.jpg", "penne.jpg", "ravioli.jpg",
+ "rotini.jpg", "spaghetti.jpg", "tortellini.jpg"]
+ categories = ["short", "long", "soup", "short", "short", "long", "short", "shell",
+ "shell", "sheet", "filled", "shell", "soup", "long", "soup", "short", "filled",
+ "short", "long", "filled"]
+
+ 20.times do |i|
+
+ category = categories[i]
+ name = pasta[i]
+ user_id = rand(1..20)
+ price_in_cents = rand(100..699)
+ description = Faker::Cannabis.health_benefit
+ quantity = rand(1..20)
+ image_url = images[i]
+
+ csv << [category, name, user_id, price_in_cents, description, quantity, image_url]
+
+ end
+
+ CSV.open('db/order_seeds.csv', "w", :write_headers=> true,
+ :headers => ["user_id", "status", "payment_id", "address_id"]) do |csv|
+
+ 20.times do
+ user_id = rand(1..20)
+ status = "paid"
+ payment_id = rand(1..20)
+ address_id = rand(1..20)
+
+ csv << [user_id, status, payment_id, address_id]
+ end
+
+ end
+
+ CSV.open('db/order_products_seeds.csv', "w", :write_headers=> true,
+ :headers => ["order_id", "product_id", "quantity"]) do |csv|
+
+ 20.times do
+ order_id = rand(1..20)
+ product_id = rand(1..20)
+ quantity = rand(1..20)
+
+ csv << [order_id, product_id, quantity]
+ end
+
+ end
+
+ CSV.open('db/review_seeds.csv', "w", :write_headers=> true,
+ :headers => ["user_id", "product_id", "review", "rating"]) do |csv|
+
+ 20.times do
+
+ user_id = rand(1..20)
+ product_id = rand(1..20)
+ review = Faker::Lorem.paragraph(3)
+ rating = rand(1..5)
+
+ csv << [user_id, product_id, review, rating]
+ end
+
+ end
+
+end
+
+# CSV.open("db/order_products_seeds.csv", "w", :write_headers=> true,
+# :headers => ["user_id", "status","payment_id", "address_id"]) do |csv|
+#
+# 20.times do
+# user_id = rand(1..25)
+# status = %w(pending paid complete cancelled).sample
+# payment_id = rand(1..2000)
+# address_id = rand(1..200)
+#
+#
+# csv << [user_id, status, payment_id, address_id]
+# end
+# end
diff --git a/db/migrate/20181017210518_create_users.rb b/db/migrate/20181017210518_create_users.rb
new file mode 100644
index 0000000000..084bce50cc
--- /dev/null
+++ b/db/migrate/20181017210518_create_users.rb
@@ -0,0 +1,14 @@
+class CreateUsers < ActiveRecord::Migration[5.2]
+ def change
+ create_table :users do |t|
+ t.string :first_name
+ t.string :last_name
+ t.string :email
+ t.boolean :is_a_seller
+ t.integer :uid
+ t.string :provider
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017210746_create_addresses.rb b/db/migrate/20181017210746_create_addresses.rb
new file mode 100644
index 0000000000..84f10c0ff9
--- /dev/null
+++ b/db/migrate/20181017210746_create_addresses.rb
@@ -0,0 +1,16 @@
+class CreateAddresses < ActiveRecord::Migration[5.2]
+ def change
+ create_table :addresses do |t|
+ t.references :user, foreign_key: true
+ t.string :first_name
+ t.string :last_name
+ t.string :street
+ t.string :street_2
+ t.string :city
+ t.string :state
+ t.integer :zip
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017211246_create_payments.rb b/db/migrate/20181017211246_create_payments.rb
new file mode 100644
index 0000000000..9ff68e335e
--- /dev/null
+++ b/db/migrate/20181017211246_create_payments.rb
@@ -0,0 +1,14 @@
+class CreatePayments < ActiveRecord::Migration[5.2]
+ def change
+ create_table :payments do |t|
+ t.references :user, foreign_key: true
+ t.references :address, foreign_key: true
+ t.integer :card_number
+ t.date :expiration_date
+ t.integer :cvv
+ t.string :card_type
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017211745_create_products.rb b/db/migrate/20181017211745_create_products.rb
new file mode 100644
index 0000000000..e57bc8fecd
--- /dev/null
+++ b/db/migrate/20181017211745_create_products.rb
@@ -0,0 +1,14 @@
+class CreateProducts < ActiveRecord::Migration[5.2]
+ def change
+ create_table :products do |t|
+ t.string :name
+ t.references :user, foreign_key: true
+ t.integer :price_in_cents
+ t.integer :quantity
+ t.string :category
+ t.text :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017212150_create_orders.rb b/db/migrate/20181017212150_create_orders.rb
new file mode 100644
index 0000000000..6033b78ac1
--- /dev/null
+++ b/db/migrate/20181017212150_create_orders.rb
@@ -0,0 +1,12 @@
+class CreateOrders < ActiveRecord::Migration[5.2]
+ def change
+ create_table :orders do |t|
+ t.references :user, foreign_key: true
+ t.string :status
+ t.references :payment, foreign_key: true
+ t.references :address, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017212433_create_reviews.rb b/db/migrate/20181017212433_create_reviews.rb
new file mode 100644
index 0000000000..cee8a6a07b
--- /dev/null
+++ b/db/migrate/20181017212433_create_reviews.rb
@@ -0,0 +1,12 @@
+class CreateReviews < ActiveRecord::Migration[5.2]
+ def change
+ create_table :reviews do |t|
+ t.references :user, foreign_key: true
+ t.references :product, foreign_key: true
+ t.text :review
+ t.integer :rating
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017212647_create_order_products.rb b/db/migrate/20181017212647_create_order_products.rb
new file mode 100644
index 0000000000..552bae0591
--- /dev/null
+++ b/db/migrate/20181017212647_create_order_products.rb
@@ -0,0 +1,10 @@
+class CreateOrderProducts < ActiveRecord::Migration[5.2]
+ def change
+ create_table :order_products do |t|
+ t.references :order, foreign_key: true
+ t.references :product, foreign_key: true
+ t.integer :quantity
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018031441_change_cc_to_big_int.rb b/db/migrate/20181018031441_change_cc_to_big_int.rb
new file mode 100644
index 0000000000..10c6bcee6d
--- /dev/null
+++ b/db/migrate/20181018031441_change_cc_to_big_int.rb
@@ -0,0 +1,5 @@
+class ChangeCcToBigInt < ActiveRecord::Migration[5.2]
+ def change
+ change_column :payments, :card_number, :bigint
+ end
+end
diff --git a/db/migrate/20181019205406_add_image_attribute_to_products.rb b/db/migrate/20181019205406_add_image_attribute_to_products.rb
new file mode 100644
index 0000000000..d558b3ce92
--- /dev/null
+++ b/db/migrate/20181019205406_add_image_attribute_to_products.rb
@@ -0,0 +1,5 @@
+class AddImageAttributeToProducts < ActiveRecord::Migration[5.2]
+ def change
+ add_column :products, :image_url, :string
+ end
+end
diff --git a/db/migrate/20181020192042_change_user_name_field.rb b/db/migrate/20181020192042_change_user_name_field.rb
new file mode 100644
index 0000000000..572d77259d
--- /dev/null
+++ b/db/migrate/20181020192042_change_user_name_field.rb
@@ -0,0 +1,7 @@
+class ChangeUserNameField < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :users, :first_name
+ remove_column :users, :last_name
+ add_column :users, :full_name, :string
+ end
+end
diff --git a/db/migrate/20181022180831_add_default_value_users.rb b/db/migrate/20181022180831_add_default_value_users.rb
new file mode 100644
index 0000000000..e6de3a9cc3
--- /dev/null
+++ b/db/migrate/20181022180831_add_default_value_users.rb
@@ -0,0 +1,5 @@
+class AddDefaultValueUsers < ActiveRecord::Migration[5.2]
+ def change
+ change_column :users, :is_a_seller, :boolean, :default => false
+ end
+end
diff --git a/db/migrate/20181023010956_add_column_to_products.rb b/db/migrate/20181023010956_add_column_to_products.rb
new file mode 100644
index 0000000000..11bffe3445
--- /dev/null
+++ b/db/migrate/20181023010956_add_column_to_products.rb
@@ -0,0 +1,5 @@
+class AddColumnToProducts < ActiveRecord::Migration[5.2]
+ def change
+ add_column :products, :is_active, :boolean, :default => true
+ end
+end
diff --git a/db/order_products_seeds.csv b/db/order_products_seeds.csv
new file mode 100644
index 0000000000..3eb1bc4f3e
--- /dev/null
+++ b/db/order_products_seeds.csv
@@ -0,0 +1,21 @@
+order_id,product_id,quantity
+17,9,6
+10,2,4
+10,17,3
+5,2,5
+9,9,12
+7,17,18
+17,9,17
+14,2,10
+8,10,14
+8,5,17
+2,14,11
+2,4,16
+7,13,3
+10,8,17
+8,13,12
+13,17,19
+1,11,7
+15,2,9
+18,9,6
+4,7,5
diff --git a/db/order_seeds.csv b/db/order_seeds.csv
new file mode 100644
index 0000000000..877757a5c4
--- /dev/null
+++ b/db/order_seeds.csv
@@ -0,0 +1,21 @@
+user_id,status,payment_id,address_id
+4,paid,14,9
+1,paid,19,11
+17,paid,2,5
+5,paid,9,4
+18,paid,16,13
+16,paid,5,2
+14,paid,5,12
+9,paid,17,7
+1,paid,5,17
+15,paid,9,15
+17,paid,20,8
+20,paid,13,11
+9,paid,18,15
+19,paid,18,12
+9,paid,4,16
+8,paid,13,9
+1,paid,2,18
+17,paid,13,8
+13,paid,16,16
+15,paid,18,13
diff --git a/db/payment_seeds.csv b/db/payment_seeds.csv
new file mode 100644
index 0000000000..a14d0c0def
--- /dev/null
+++ b/db/payment_seeds.csv
@@ -0,0 +1,21 @@
+user_id,address_id,card_number,expiration_date,cvv,card_type
+5,19,648310350969462,2019-03-21,1699,VISA
+4,2,864580070827161,2020-06-02,6811,VISA
+15,20,808172804817563,2019-08-20,5901,AMEX
+15,16,259211036110080,2019-07-20,2343,DISCOVER
+17,19,592593981154352,2020-05-20,8690,MASTERCARD
+13,7,465144674086463,2019-09-28,6260,MASTERCARD
+14,2,323889356816708,2019-07-18,9237,VISA
+11,9,994190517085571,2019-04-17,7309,VISA
+8,13,890096716811943,2019-01-11,9899,MASTERCARD
+5,15,319477663022404,2019-10-25,5624,AMEX
+16,17,265566687666886,2019-08-05,2975,MASTERCARD
+13,1,760737854449123,2019-05-20,8339,AMEX
+20,6,280982471294632,2019-07-29,3359,MASTERCARD
+2,20,566404910252770,2019-04-30,6907,AMEX
+18,16,868738353152065,2020-04-04,3414,VISA
+5,18,931999412440854,2019-01-13,2496,DISCOVER
+12,17,362093968991114,2019-12-03,9312,AMEX
+18,16,885111029073865,2018-10-30,7087,AMEX
+15,17,631079298655678,2019-01-14,5120,AMEX
+7,3,985811364391153,2018-11-10,8037,MASTERCARD
diff --git a/db/product_seeds.csv b/db/product_seeds.csv
new file mode 100644
index 0000000000..629d4d0ba6
--- /dev/null
+++ b/db/product_seeds.csv
@@ -0,0 +1,21 @@
+category,name,user_id,price_in_cents,description,quantity,image_url
+short,Callentani,17,170,tranquilizing,18,callentani.jpg
+long,Capellini,17,236,reduces blood sugar levels,8,capellini.jpg
+soup,Ditalini,11,106,treats fungal infection,1,ditalini.jpg
+short,Elbow,4,576,relieves pain,14,elbow.jpg
+short,Farfalle,9,640,inhibits cell growth in tumors/cancer cells,19,farfalle.jpg
+long,Fettuccine,16,472,treats fungal infection,11,fettuccine.jpg
+short,Gemelli,2,644,relieves congestion,1,gemelli.jpg
+shell,Gluten-free Shells,6,341,reduces inflammation,13,gluten-free.jpg
+shell,Jumbo Shells,7,160,stimulates function in the immune system,4,large-shell.jpg
+sheet,Lasagna,11,159,protects against nervous system degeneration,10,lasagna.jpg
+filled,Manicotti,8,376,aids sleep,2,manicotti.jpg
+shell,Medium Shells,11,518,relieves pain,3,medium-shell.jpg
+soup,Orzo,15,532,treats depression,15,orzo.jpg
+long,Pappardelle,5,416,reduces blood sugar levels,3,pappardelle.jpg
+soup,Pastina,14,591,improves airflow to lungs,9,pastina.jpg
+short,Penne,4,439,tranquilizing,14,penne.jpg
+filled,Ravioli,8,641,treats fungal infection,17,ravioli.jpg
+short,Rotini,14,439,stimulates function in the immune system,20,rotini.jpg
+long,Spaghetti,8,699,kills or slows bacteria growth,13,spaghetti.jpg
+filled,Tortellini,5,381,treats allergy symptoms,20,tortellini.jpg
diff --git a/db/review_seeds.csv b/db/review_seeds.csv
new file mode 100644
index 0000000000..d4f5a89b9a
--- /dev/null
+++ b/db/review_seeds.csv
@@ -0,0 +1,21 @@
+user_id,product_id,review,rating
+20,3,Necessitatibus nostrum ullam. Qui est eos. Debitis quia alias.,4
+1,16,Laudantium et nemo. Id consequatur non. Ut amet ea.,3
+15,19,Sit possimus modi. Omnis velit ullam. Laboriosam non totam.,3
+7,8,Impedit est ut. Quae laudantium aliquam. Autem dolor iure.,4
+10,10,Autem quia quam. Animi fuga nihil. Qui aut est.,4
+3,17,Fuga id dicta. Sint fugit cupiditate. Voluptatum qui laudantium.,1
+8,12,Praesentium repellat tempore. Facere deleniti eos. In inventore et.,2
+9,12,Eius qui sed. Est iusto eum. Maxime facilis commodi.,4
+18,6,Illo minima commodi. Aut tenetur earum. Saepe consequuntur dolor.,5
+17,8,Deleniti corrupti reiciendis. Velit nulla repudiandae. Eum voluptatibus vero.,5
+20,11,Consectetur praesentium quisquam. Dolores et totam. Qui impedit quo.,5
+2,6,Eligendi voluptas voluptatem. Officia sed qui. Qui iste deleniti.,1
+9,6,Modi magnam qui. Nesciunt fugiat non. Rerum sit eaque.,2
+6,19,Repellendus consequuntur officiis. Sunt dolores reiciendis. Ratione voluptatem et.,3
+18,3,Eum quas non. Eius eos sit. Pariatur sequi enim.,1
+7,14,Dignissimos accusantium enim. Nesciunt non voluptatibus. Consequuntur aut eaque.,3
+4,2,Porro architecto facere. Voluptatem sequi natus. Ut natus provident.,3
+18,14,Et at vitae. Quo et ea. Ratione quos commodi.,2
+1,5,Quae suscipit fugit. Amet sequi qui. Sit aut expedita.,3
+1,8,Et dolor magnam. Et molestias quo. Optio iste voluptatem.,2
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..0254079dc5
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,113 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 2018_10_23_010956) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "addresses", force: :cascade do |t|
+ t.bigint "user_id"
+ t.string "first_name"
+ t.string "last_name"
+ t.string "street"
+ t.string "street_2"
+ t.string "city"
+ t.string "state"
+ t.integer "zip"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["user_id"], name: "index_addresses_on_user_id"
+ end
+
+ create_table "order_products", force: :cascade do |t|
+ t.bigint "order_id"
+ t.bigint "product_id"
+ t.integer "quantity"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ 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.bigint "user_id"
+ t.string "status"
+ t.bigint "payment_id"
+ t.bigint "address_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["address_id"], name: "index_orders_on_address_id"
+ t.index ["payment_id"], name: "index_orders_on_payment_id"
+ t.index ["user_id"], name: "index_orders_on_user_id"
+ end
+
+ create_table "payments", force: :cascade do |t|
+ t.bigint "user_id"
+ t.bigint "address_id"
+ t.bigint "card_number"
+ t.date "expiration_date"
+ t.integer "cvv"
+ t.string "card_type"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["address_id"], name: "index_payments_on_address_id"
+ t.index ["user_id"], name: "index_payments_on_user_id"
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "name"
+ t.bigint "user_id"
+ t.integer "price_in_cents"
+ t.integer "quantity"
+ t.string "category"
+ t.text "description"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "image_url"
+ t.boolean "is_active", default: true
+ t.index ["user_id"], name: "index_products_on_user_id"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.bigint "user_id"
+ t.bigint "product_id"
+ t.text "review"
+ t.integer "rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_reviews_on_product_id"
+ t.index ["user_id"], name: "index_reviews_on_user_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "email"
+ t.boolean "is_a_seller", default: false
+ t.integer "uid"
+ t.string "provider"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "full_name"
+ end
+
+ add_foreign_key "addresses", "users"
+ add_foreign_key "order_products", "orders"
+ add_foreign_key "order_products", "products"
+ add_foreign_key "orders", "addresses"
+ add_foreign_key "orders", "payments"
+ add_foreign_key "orders", "users"
+ add_foreign_key "payments", "addresses"
+ add_foreign_key "payments", "users"
+ add_foreign_key "products", "users"
+ add_foreign_key "reviews", "products"
+ add_foreign_key "reviews", "users"
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..83078d48b1
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,217 @@
+# 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)
+require 'csv'
+
+USER_FILE = Rails.root.join('db', 'user_seeds.csv')
+puts "Loading raw user data from #{USER_FILE}"
+
+user_failures = []
+CSV.foreach(USER_FILE, :headers => true) do |row|
+
+ user = User.new(
+ full_name: row['full_name'],
+ email: row['email'],
+ is_a_seller: row['is_a_seller'],
+ uid: row['uid'],
+ provider: row['provider']
+ )
+
+
+ successful = user.save
+
+ if !successful
+ user_failures << user
+ puts "Failed to save user: #{user.inspect}"
+ puts "#{user.errors.full_messages}"
+ else
+ puts "Created user: #{user.inspect}"
+ end
+end
+
+
+ADDRESSES_FILE = Rails.root.join('db', 'address_seeds.csv')
+puts "Loading raw user data from #{ADDRESSES_FILE}"
+
+address_failures = []
+CSV.foreach(ADDRESSES_FILE, :headers => true) do |row|
+ address = Address.new(
+ user_id: row['user_id'],
+ first_name: row['first_name'],
+ last_name: row['last_name'],
+ street: row['street'],
+ street_2: row['street_2'],
+ city: row['city'],
+ state: row['state'],
+ zip: row['zip'],
+ )
+
+ successful = address.save
+
+ if !successful
+ address_failures << address
+ puts "Failed to save address: #{address.inspect}"
+ puts "#{address.errors.full_messages}"
+ else
+ puts "Created address: #{address.inspect}"
+ end
+end
+
+
+PAYMENTS_FILE = Rails.root.join('db', 'payment_seeds.csv')
+puts "Loading raw user data from #{PAYMENTS_FILE}"
+
+payment_failures = []
+CSV.foreach(PAYMENTS_FILE, :headers => true) do |row|
+ payment = Payment.new(
+ user_id: row['user_id'],
+ address_id: row['address_id'],
+ card_number: row['card_number'],
+ expiration_date: row['expiration_date'],
+ cvv: row['cvv'],
+ card_type: row['card_type']
+ )
+
+ successful = payment.save
+
+ if !successful
+ payment_failures << payment
+ puts "Failed to save payment: #{payment.inspect}"
+ puts "#{payment.errors.full_messages}"
+ else
+ puts "Created payment: #{payment.inspect}"
+ end
+end
+
+
+
+
+PRODUCT_FILE = Rails.root.join('db', 'product_seeds.csv')
+puts "Loading raw product data from #{PRODUCT_FILE}"
+
+product_failures = []
+CSV.foreach(PRODUCT_FILE, :headers => true) do |row|
+ product = Product.new(
+
+ category: row['category'],
+ name: row['name'],
+ user_id: row['user_id'],
+ price_in_cents: row['price_in_cents'],
+ description: row['description'],
+ quantity: row['quantity'],
+ image_url: row['image_url']
+ )
+
+ successful = product.save
+
+ if !successful
+ product_failures << product
+ puts "Failed to save product: #{product.inspect}"
+ puts "#{product.errors.full_messages}"
+ else
+ puts "Created product: #{product.inspect}"
+ end
+end
+
+ORDER_FILE = Rails.root.join('db', 'order_seeds.csv')
+puts "Loading raw user data from #{ORDER_FILE}"
+
+order_failures = []
+CSV.foreach(ORDER_FILE, :headers => true) do |row|
+ order = Order.new(
+ user_id: row['user_id'],
+ status: row['status'],
+ payment_id: row['payment_id'],
+ address_id: row['address_id'],
+ )
+
+ successful = order.save
+
+
+ if !successful
+ order_failures << user
+ puts "Failed to save order: #{order.inspect}"
+ puts "#{order.errors.full_messages}"
+ else
+ puts "Created order: #{order.inspect}"
+ end
+end
+
+ORDER_PRODUCTS_FILE = Rails.root.join('db', 'order_products_seeds.csv')
+puts "Loading raw user data from #{ORDER_PRODUCTS_FILE}"
+
+order_product_failures = []
+CSV.foreach(ORDER_PRODUCTS_FILE, :headers => true) do |row|
+ order_product = OrderProduct.new(
+ order_id: row['order_id'],
+ product_id: row['product_id'],
+ quantity: row['quantity']
+ )
+
+ successful = order_product.save
+
+ if !successful
+ order_product_failures << order_product
+ puts "Failed to save order_products: #{order_product.inspect}"
+ puts "#{order_product.errors.full_messages}"
+ else
+ puts "Created order_products: #{order_product.inspect}"
+ end
+end
+
+REVIEWS_FILE = Rails.root.join('db', 'review_seeds.csv')
+puts "Loading raw user data from #{REVIEWS_FILE}"
+
+review_failures = []
+CSV.foreach(REVIEWS_FILE, :headers => true) do |row|
+ review = Review.new(
+ user_id: row['user_id'],
+ product_id: row['product_id'],
+ review: row['review'],
+ rating: row['rating']
+ )
+
+ successful = review.save
+
+ if !successful
+ review_failures << review
+
+ puts "Failed to save review: #{review.inspect}"
+ puts "#{review.errors.full_messages}"
+ else
+ puts "Created reviews: #{review.inspect}"
+ end
+end
+
+puts "Added #{User.count} user records"
+puts "#{user_failures.length} users failed to save."
+
+puts "Added #{Product.count} product records"
+puts "#{product_failures.length} products failed to save."
+
+puts "Added #{OrderProduct.count} order_product records"
+puts "#{order_product_failures.length} order_products failed to save."
+
+puts "Added #{Order.count} order records"
+puts "#{order_failures.length} orders failed to save."
+
+puts "Added #{Address.count} address records"
+puts "#{address_failures.length} address failed to save."
+
+puts "Added #{Payment.count} payment records"
+puts "#{payment_failures.length} payments failed to save."
+
+puts "Added #{Review.count} review records"
+puts "#{review_failures.length} reviews failed to save."
+
+
+puts "Manually resetting PK sequence on each table"
+ActiveRecord::Base.connection.tables.each do |t|
+ ActiveRecord::Base.connection.reset_pk_sequence!(t)
+
+
+end
diff --git a/db/user_seeds.csv b/db/user_seeds.csv
new file mode 100644
index 0000000000..eb5fecf754
--- /dev/null
+++ b/db/user_seeds.csv
@@ -0,0 +1,21 @@
+full_name,email,is_a_seller,uid,provider
+Mrs. Branden Yost,mrsbrandenyost@emardbatz.io,true,82675057,github
+Mae Will,maewill@lemke.org,true,22266046,twitter
+Myles Goldner,mylesgoldner@cormierkrajcik.io,true,75295767,github
+Margarete Gleichner IV,ivmargaretegleichner@schimmelshanahan.io,true,45989803,google
+Emerson Smitham DDS,ddsemersonsmitham@zemlakwintheiser.com,true,98811369,facebook
+Lovella Swaniawski,lovellaswaniawski@franecki.biz,true,65227756,github
+Nicki Mohr,mohrnicki@feil.com,true,50455725,github
+Valorie Grant,valoriegrant@hirthe.info,true,20968976,google
+Lizette Kerluke,lizettekerluke@gislason.info,true,82410707,twitter
+Frederick Upton,frederickupton@schmeler.name,true,85416006,twitter
+Rodolfo Kris,krisrodolfo@crist.io,true,68733380,twitter
+Ms. Dwayne Klocko,klockomsdwayne@hintzgibson.biz,true,92676257,facebook
+Kyle Legros,legroskyle@bradtkeschulist.info,true,22305621,twitter
+Tracy Auer,auertracy@mcdermott.name,true,21183803,facebook
+Donny Goldner,goldnerdonny@west.biz,true,19867062,google
+Danna Romaguera,romagueradanna@kilbackgottlieb.com,true,32144852,google
+Dominique Pfannerstill,dominiquepfannerstill@ledner.biz,true,67623444,twitter
+Casey Bauch DVM,caseybauchdvm@pagaclindgren.info,true,61658205,google
+Dr. Isabella Rosenbaum,isabelladrrosenbaum@dibbert.biz,true,98480819,github
+Eddie Herzog,herzogeddie@batz.io,true,40224299,google
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..190fd20420
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "spagh-ettsi",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/public/.DS_Store b/public/.DS_Store
new file mode 100644
index 0000000000..95962d0909
Binary files /dev/null and b/public/.DS_Store differ
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/images/.DS_Store b/public/images/.DS_Store
new file mode 100644
index 0000000000..5008ddfcf5
Binary files /dev/null and b/public/images/.DS_Store differ
diff --git a/public/images/welcome.scss b/public/images/welcome.scss
new file mode 100644
index 0000000000..0e3aa7915f
--- /dev/null
+++ b/public/images/welcome.scss
@@ -0,0 +1,184 @@
+@import url('https://fonts.googleapis.com/css?family=K2D');
+
+.homepage {
+ font-family: 'K2D';
+ height: 100%;
+ width: 100%;
+ display: grid;
+ grid-template-columns: repeat(6, 1fr);
+ grid-template-rows: repeat(10, 1fr);
+ grid-template-areas:
+ "h h h h h h"
+ "k k k k k k"
+ "d d d p p p"
+ "d d d p p p"
+ "d d d p p p"
+ "d d d p p p"
+ "d d d p p p"
+ "i i i i i i"
+ "i i i i i i"
+ "i i i i i i"
+ "f f f f f f"
+}
+
+.welcome-header {
+ height: 80px;
+ grid-area: h;
+ font-family: 'K2D';
+ background-color: black;
+ color: white;
+ display: flex;
+ align-items: center;
+ // text-align: center;
+ border-bottom: 10px solid white;
+}
+.welcome-header h1, h2 {
+ text-align: center;
+}
+
+.tagline {
+ grid-area: k;
+ text-align: center;
+}
+
+.smurf {
+ width: 50px;
+ height: 50px;
+}
+
+.home-button {
+ margin-left: auto;
+}
+
+.home-button img{
+ width: 35px;
+ height: 35px;
+ padding-right: 50px;
+ padding-top: 20px;
+}
+
+.main-part {
+ height: 500px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.driver {
+ grid-area: d;
+ background-image: url('driver.jpg');
+ // margin: 10px;
+}
+
+.passenger {
+ grid-area: p;
+ background-image: url('passenger.jpg');
+ // margin: 10px;
+}
+
+.info {
+ grid-area: i;
+ text-align: center;
+ padding: 2em;
+}
+
+footer {
+ grid-area: f;
+ background-color: black;
+ color: white;
+ text-align: center;
+ border-top: 10px solid white;
+}
+
+ .welcome-button{
+ font-family: 'K2D';
+ background:white;
+ color: black;
+ border: 2px solid black;
+ border-radius: 8px;
+ position:relative;
+ height:60px;
+ font-size:1.6em;
+ padding:2em;
+ vertical-align: center;
+ margin-top: 30%;
+ cursor:pointer;
+ transition:800ms ease all;
+ outline:none;
+ background-image: linear-gradient(white,#F0FFFF);
+ text-decoration: none;
+
+ }
+ .welcome-button:hover{
+ background:#fff;
+ color:#1AAB8A;
+ }
+ .welcome-button:before,button:after{
+ content:'';
+ position:absolute;
+ top:0;
+ right:0;
+ height:5px;
+ width:0;
+ background: black;
+ transition:400ms ease all;
+ }
+ .welcome-button:after{
+ right:inherit;
+ top:inherit;
+ left:0;
+ bottom:0;
+ }
+ .welcome-button:hover:before,button:hover:after{
+ width:100%;
+ transition:800ms ease all;
+ }
+
+ /* Dropdown Button */
+.dropbtn {
+ background-color: black;
+ color: white;
+ padding: 15px;
+ font-size: 16px;
+ border: none;
+ border-bottom: 3px solid white;
+ margin: 10px;
+}
+
+/* The container
- needed to position the dropdown content */
+.dropdown {
+ position: relative;
+ display: inline-block;
+ font-family: 'K2D';
+}
+
+.driver-dropdown {
+ margin-left: 50%;
+}
+
+/* Dropdown Content (Hidden by Default) */
+.dropdown-content {
+ display: none;
+ position: absolute;
+ background-color: #f1f1f1;
+ min-width: 160px;
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
+ z-index: 1;
+}
+
+/* Links inside the dropdown */
+.dropdown-content a {
+ color: black;
+ padding: 12px 16px;
+ text-decoration: none;
+ display: block;
+}
+
+/* Change color of dropdown links on hover */
+.dropdown-content a:hover {background-color: #DEB887;}
+
+/* Show the dropdown menu on hover */
+.dropdown:hover .dropdown-content {display: block;}
+
+/* Change the background color of the dropdown button when the dropdown content is shown */
+.dropdown:hover .dropbtn {background-color: #5F9EA0;}
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/storage/.keep b/storage/.keep
new file mode 100644
index 0000000000..e69de29bb2
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/addresses_controller_test.rb b/test/controllers/addresses_controller_test.rb
new file mode 100644
index 0000000000..41db21eee1
--- /dev/null
+++ b/test/controllers/addresses_controller_test.rb
@@ -0,0 +1,102 @@
+require "test_helper"
+
+describe AddressesController do
+ let(:buyer) {users(:buyer)}
+ let(:seller) {users(:seller)}
+ let(:mock_params) {
+ {
+ address: {
+ user_id: buyer.id,
+ first_name: "Gunther",
+ last_name: "Centralperk",
+ street: "Central Perk",
+ street_2: nil,
+ city: "New York",
+ state: "NY",
+ zip: 10001
+ }
+ }
+ }
+
+
+ describe "new" do
+
+ it "succeeds when user is logged in" do
+ perform_login(buyer)
+ get new_address_path
+ must_respond_with :success
+ end
+
+ it 'responds with bad request with no user logged in' do
+ get new_address_path
+
+ must_respond_with :bad_request
+
+ end
+ end
+
+ describe "create" do
+
+ it "creates an address with valid data with a logged in user" do
+ perform_login(buyer)
+
+ expect {
+ post addresses_path, params: mock_params
+ }.must_change 'Address.count', 1
+
+ address = Address.last
+
+ expect(address.user_id).must_equal mock_params[:address][:user_id]
+ expect(address.first_name).must_equal mock_params[:address][:first_name]
+ expect(address.last_name).must_equal mock_params[:address][:last_name]
+ expect(address.street).must_equal mock_params[:address][:street]
+ expect(address.street_2).must_equal mock_params[:address][:street_2]
+ expect(address.city).must_equal mock_params[:address][:city]
+ expect(address.state).must_equal mock_params[:address][:state]
+ expect(address.zip).must_equal mock_params[:address][:zip]
+
+ must_redirect_to checkout_path
+
+ end
+
+ it "responds with bad request and won't change DB if address user is not logged in user" do
+ perform_login(seller)
+
+ expect {
+ post addresses_path, params: mock_params
+ }.wont_change 'Address.count'
+
+
+ must_respond_with :bad_request
+
+ end
+
+ it "responds with bad request and won't change DB if no user logged in" do
+
+
+ expect {
+ post addresses_path, params: mock_params
+ }.wont_change 'Address.count'
+
+
+ must_respond_with :bad_request
+
+ end
+
+ it "renders bad_request and does not update the DB for bogus data" do
+ perform_login(buyer)
+
+ mock_params[:address][:street] = nil
+
+ expect {
+ post addresses_path, params: mock_params
+ }.wont_change 'Address.count'
+
+ must_respond_with :bad_request
+ 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..2eb4b98ff5
--- /dev/null
+++ b/test/controllers/order_products_controller_test.rb
@@ -0,0 +1,372 @@
+require "test_helper"
+
+describe OrderProductsController do
+ let(:order_one) {orders(:order_one)}
+ let(:fusilli) {products(:fusilli)}
+ let(:spaghetti) {products(:spaghetti)}
+ let(:buyer) {users(:buyer)}
+ let(:seller) {users(:seller)}
+ let(:order_one_spaghetti) {order_products(:order_one_spaghetti)}
+ let(:mock_params) {
+ {
+ order_product: {
+ product_id: fusilli.id,
+ quantity: 5
+ }
+ }
+ }
+
+
+
+ describe 'create' do
+ it 'creates a row in the OrderProducts table with valid unique data and logged in user' do
+
+ perform_login(buyer)
+
+ expect {
+ post order_products_path, params: mock_params
+ }.must_change 'OrderProduct.count', 1
+
+ must_redirect_to shopping_cart_path
+
+ end
+
+ it 'adds the product to the shopping cart of the logged-in user' do
+ perform_login(buyer)
+
+ expect {
+ post order_products_path, params: mock_params
+ }.must_change 'OrderProduct.count', 1
+
+ new_entry = OrderProduct.last
+
+ #the order_one fixture has the status of pending and user = buyer
+ expect(new_entry.order).must_equal order_one
+ expect(new_entry.product).must_equal fusilli
+ expect(new_entry.quantity).must_equal 5
+
+ must_redirect_to shopping_cart_path
+ end
+
+ it 'modifies an existing row if the product/order combo is already in the table' do
+
+ perform_login(buyer)
+
+ mock_params[:order_product][:product_id] = spaghetti.id
+
+ expect(order_one_spaghetti.quantity).must_equal 5
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ order_one_spaghetti.reload
+
+ expect(order_one_spaghetti.quantity).must_equal 10
+
+ must_redirect_to shopping_cart_path
+
+ end
+
+ it 'will not add to cart if there is not enough stock' do
+ perform_login(buyer)
+
+ expect(fusilli.quantity).must_equal 20
+
+ mock_params[:order_product][:quantity] = 21
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ fusilli.reload
+
+ expect(fusilli.quantity).must_equal 20
+
+ must_redirect_to root_path
+
+
+ end
+
+ it 'does not change db with invalid data' do
+ perform_login(buyer)
+
+ mock_params[:order_product][:quantity] = nil
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ must_redirect_to root_path
+
+
+ end
+
+ it 'decrements the quantity in the product model appropriately' do
+ perform_login(buyer)
+
+ # fusilli wasn't already in cart
+ old_quantity = fusilli.quantity
+
+ expect {
+ post order_products_path, params: mock_params
+ }.must_change 'OrderProduct.count', 1
+
+ fusilli.reload
+
+ new_quantity = fusilli.quantity
+
+ expect(old_quantity - new_quantity).must_equal 5
+
+ #spaghetti was already in cart
+
+ mock_params[:order_product][:product_id] = spaghetti.id
+
+ old_quantity = spaghetti.quantity
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ spaghetti.reload
+
+ new_quantity = spaghetti.quantity
+
+ expect(old_quantity - new_quantity).must_equal 5
+
+ end
+
+ it 'prevents a seller from buying their own products' do
+ perform_login(seller)
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ must_respond_with :redirect
+ expect(flash[:warning]).must_equal "Mamma Mia! You can't purchase your own products. Just steal some from the supply closet!"
+ end
+
+ it 'redirects to root path with a warning if invalid data is given' do
+ perform_login(buyer)
+ mock_params[:order_product][:product_id] = nil
+
+ expect {
+ post order_products_path, params: mock_params
+ }.wont_change 'OrderProduct.count'
+
+ must_redirect_to root_path
+ end
+ end
+
+
+ describe 'check_login' do
+ it 'does nothing if a user is already logged in' do
+ perform_login(buyer)
+
+ expect(session[:user_id]).must_equal buyer.id
+
+ #call create which uses check_login as a helper method
+ expect{
+ post order_products_path, params: mock_params
+ }.wont_change 'User.count'
+
+ expect(session[:user_id]).must_equal buyer.id
+
+ end
+
+ it 'with no user logged in, creates a new guest user instance and logs the guest user in' do
+
+ expect{
+ post order_products_path, params: mock_params
+ }.must_change 'User.count', 1
+
+ new_user = User.last
+
+ expect(new_user.full_name).must_equal 'Guest user'
+ expect(new_user.email).must_equal 'example@example.com'
+ expect(new_user.is_a_seller).must_equal false
+ expect(new_user.provider).must_equal 'guest_login'
+
+ expect(session[:user_id]).must_equal new_user.id
+ end
+ end
+
+ describe 'check_shopping_cart' do
+ it 'sets the session shopping cart id if the user has an order with pending status' do
+ perform_login(buyer)
+
+ #call create which uses check_shopping_cart as a helper method
+ expect{
+ post order_products_path, params: mock_params
+ }.wont_change 'Order.count'
+
+ #buyer has an open order called order_one
+ expect(session[:user_id]).must_equal buyer.id
+ expect(session[:shopping_cart_id]).must_equal order_one.id
+
+ end
+
+ it 'creates a new shopping cart attached to the logged-in user if the user does not have one and sets the session shopping cart id' do
+ perform_login(seller)
+
+ #call create which uses check_shopping_cart as a helper method
+ #seller has no orders yet
+ expect{
+ post order_products_path, params: mock_params
+ }.must_change 'Order.count', 1
+
+ new_order = Order.last
+
+ expect(new_order.user).must_equal seller
+
+ expect(session[:user_id]).must_equal seller.id
+ expect(session[:shopping_cart_id]).must_equal new_order.id
+
+ end
+
+ it 'creates a new shopping cart for the guest user' do
+
+ #nobody logged in, no orders yet
+ old_order_count = Order.count
+
+ expect{
+ post order_products_path, params: mock_params
+ }.must_change 'User.count', 1
+
+ new_order_count = Order.count
+
+ expect(new_order_count - old_order_count).must_equal 1
+
+ guest_user = User.last
+ guest_order = Order.last
+
+ expect(guest_order.user).must_equal guest_user
+ expect(session[:user_id]).must_equal guest_user.id
+ expect(session[:shopping_cart_id]).must_equal guest_order.id
+ end
+ end
+
+ describe 'update' do
+ let(:mock_update_params) {
+ {
+ order_product:
+ {
+ quantity: 3,
+ id: order_one_spaghetti.id
+ }
+ }
+ }
+
+ it 'modifies an existing row given a valid id' do
+ #order_one_spaghetti = 5 in cart
+
+ perform_login(buyer)
+
+ expect(order_one_spaghetti.quantity).must_equal 5
+
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.wont_change 'OrderProduct.count'
+
+ order_one_spaghetti.reload
+ expect(order_one_spaghetti.quantity).must_equal 3
+
+ must_redirect_to shopping_cart_path
+
+ end
+
+ it 'fails with invalid id' do
+ perform_login(buyer)
+
+ mock_update_params[:order_product][:id] = -1
+
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.wont_change 'OrderProduct.count'
+
+ must_redirect_to root_path
+
+ end
+
+ it 'deletes row if quantity is set to zero' do
+ perform_login(buyer)
+
+ #no more spaghetti in order one
+ mock_update_params[:order_product][:quantity] = 0
+
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.must_change 'OrderProduct.count', -1
+
+ expect(OrderProduct.find_by(order: order_one, product: spaghetti)).must_equal nil
+
+ end
+
+ it 'updates the product inventory appropriately when buying more' do
+ # ----- increase order quantity by 10
+
+ perform_login(buyer)
+
+ #in cart
+ expect(order_one_spaghetti.quantity).must_equal 5
+
+ #inventory
+ expect(spaghetti.quantity).must_equal 50
+
+ mock_update_params[:order_product][:quantity] = 15
+
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.wont_change 'OrderProduct.count'
+
+ #in cart plus 10
+ order_one_spaghetti.reload
+ expect(order_one_spaghetti.quantity).must_equal 15
+
+ #inventory minus 10
+ spaghetti.reload
+ expect(spaghetti.quantity).must_equal 40
+ end
+
+ it 'updates the product inventory appropriately when buying fewer' do
+ # ------ decrease order quantity by 3
+
+ expect(order_one_spaghetti.quantity).must_equal 5
+
+ mock_update_params[:order_product][:quantity] = 2
+
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.wont_change 'OrderProduct.count'
+
+ #in cart minus 3
+ order_one_spaghetti.reload
+ expect(order_one_spaghetti.quantity).must_equal 2
+
+ #inventory plus 3
+ spaghetti.reload
+ expect(spaghetti.quantity).must_equal 53
+ end
+
+ it 'updates the product inventory appropriately when buying zero' do
+ # ------ decrease order quantity by 5
+
+ expect(order_one_spaghetti.quantity).must_equal 5
+
+ mock_update_params[:order_product][:quantity] = 0
+
+ #deletes row from order_products table
+ expect{
+ patch shopping_cart_path, params: mock_update_params
+ }.must_change 'OrderProduct.count', -1
+
+
+ #inventory plus 5
+ spaghetti.reload
+ expect(spaghetti.quantity).must_equal 55
+ 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..76556aeb7f
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,184 @@
+require "test_helper"
+
+describe OrdersController do
+ let(:order_one) {orders(:order_one)}
+ let(:order_two) {orders(:order_two)}
+ let(:order_three) {orders(:order_three)}
+ let(:buyer) {users(:buyer)}
+ let(:seller) {users(:seller)}
+
+ let(:order_params) {
+ {
+ full_name: 'Ron Howard',
+ email: 'happy@days.com',
+ payment_id: payments(:amex).id,
+ address_id: addresses(:school).id,
+ status: :paid
+
+ }
+ }
+
+ let(:op_params) {
+ {
+ order_product: {
+ product_id: products(:fusilli).id,
+ quantity: 5
+ }
+ }
+ }
+
+ describe 'show' do
+ it 'succeeds with a logged-in user viewing their own non-pending order given a valid ID' do
+ perform_login(buyer)
+ get order_path(order_two.id)
+
+ must_respond_with :success
+ end
+
+ it 'responds with not found with a logged-in user trying to view a pending order given a valid ID' do
+ perform_login(buyer)
+ get order_path(order_one.id)
+
+ must_respond_with :not_found
+ end
+
+ it 'responds with not found with a logged-in user trying to view someone elses order with valid ID' do
+ perform_login(buyer)
+ get order_path(order_three.id)
+
+ must_respond_with :not_found
+ end
+
+ it 'responds with not found with a logged-in user given an invalid ID' do
+ perform_login(buyer)
+ get order_path(-1)
+
+ must_respond_with :not_found
+ end
+
+ it 'redirects to root if a user is not logged in given a valid ID' do
+ get order_path(order_two.id)
+
+ must_redirect_to root_path
+ end
+
+ it 'clears the session to remove a guest login after displaying order summary' do
+ post order_products_path, params: op_params #start a shopping cart to create guest login
+ new_order = Order.last
+ expect(new_order.user.provider).must_equal 'guest_login'
+
+ patch order_path(new_order.id), params: order_params #complete the order
+
+ get order_path(new_order.id)
+
+ expect(session[:user_id]).must_equal nil
+ end
+ end
+
+ describe 'edit, which is actually checkout form' do
+ it 'succeeds with a logged-in user given a pending order with valid ID' do
+ perform_login(buyer)
+ get edit_order_path(order_one.id)
+
+ must_respond_with :success
+ end
+
+ it 'succeeds as checkout_path when a user has a pending order' do
+ perform_login(buyer)
+ get checkout_path
+
+ must_respond_with :success
+ end
+
+ it 'responds with not found if a user has no pending order' do
+ perform_login(seller)
+ get checkout_path
+ must_respond_with :not_found
+ end
+
+
+ # it 'responds with not found with a logged-in user given a non-pending order with valid ID' do
+ # perform_login(buyer)
+ # get edit_order_path(order_two.id)
+ #
+ # must_respond_with :not_found
+ # end
+ #changed edit path to checkout so overrides this capability
+ #
+ # it 'responds with not found with a logged-in user with someone elses valid order ID' do
+ # perform_login(buyer)
+ # get edit_order_path(order_three.id)
+ #
+ # must_respond_with :not_found
+ # end
+
+ it 'redirects to root with no user logged in (guest user is technically a login)' do
+ get edit_order_path(order_three.id)
+
+ must_redirect_to root_path
+ end
+
+ end
+
+ describe 'mark_as_shipped' do
+ it 'changes order status from paid to shipped with logged in user and valid ID' do
+ perform_login(seller)
+
+ expect(order_two.status).must_equal 'paid'
+
+ patch mark_as_shipped_path(order_two.id)
+
+ order_two.reload
+ expect(order_two.status).must_equal 'complete'
+ end
+
+ end
+
+ describe 'update' do
+ it 'updates the order with a logged-in user given valid data and redirects to order show page' do
+ perform_login(buyer)
+ patch order_path(order_one.id), params: order_params
+
+ must_redirect_to order_path(order_one.id)
+ end
+
+ it 'redirects back with a flash warning with logged-in user given invalid data' do
+ perform_login(buyer)
+ order_params[:payment_id] = nil
+
+ patch order_path(order_one.id), params: order_params
+
+ must_respond_with :redirect
+ expect(flash[:warning]).must_equal "Unable to place order"
+ end
+
+ it 'redirects back with a flash warning with logged-in user (guest mock login) using invalid name or email' do
+ perform_login(buyer)
+ order_params[:full_name] = nil
+
+ patch order_path(order_one.id), params: order_params
+
+ must_respond_with :redirect
+ expect(flash[:warning]).must_equal "An error occurred. Please try again."
+ end
+
+ it 'redirects to root path with no login user' do
+ patch order_path(order_one.id), params: order_params
+
+ must_redirect_to root_path
+ end
+
+ it 'prevents checkout with an empty cart' do
+ perform_login(buyer)
+ order_one.order_products.each do |op|
+ op.delete
+ end
+ post checkout_path, params: order_params
+
+ must_redirect_to products_path
+ end
+
+ end
+
+
+end
diff --git a/test/controllers/payments_controller_test.rb b/test/controllers/payments_controller_test.rb
new file mode 100644
index 0000000000..ebfe62170f
--- /dev/null
+++ b/test/controllers/payments_controller_test.rb
@@ -0,0 +1,65 @@
+require "test_helper"
+
+describe PaymentsController do
+ let(:buyer) {users(:buyer)}
+ let(:home) {addresses(:home)}
+ let(:mock_payment_params) {
+ {
+ payment: {
+ user_id: buyer.id,
+ address_id: home.id,
+ card_number: 123456789012334,
+ expiration_date: Date.today,
+ cvv: 123,
+ card_type: 'AMEX'
+ }
+ }
+ }
+
+ describe 'new' do
+ it "succeeds when a user is logged in" do
+ @login_user = buyer
+ get new_payment_path
+ must_respond_with :success
+ end
+
+ it "succeeds if a user is not logged in" do
+ @login_user = nil
+ get new_payment_path
+ must_respond_with :success
+ end
+ end
+
+ describe 'create' do
+ it "creates a payment with valid data" do
+ expect {
+ post payments_path, params: mock_payment_params
+ }.must_change 'Payment.count', 1
+
+ payment = Payment.find_by(card_number: mock_payment_params[:payment][:card_number])
+
+ expect(payment.user.id).must_equal mock_payment_params[:payment][:user_id]
+ expect(payment.address.id).must_equal mock_payment_params[:payment][:address_id]
+ expect(payment.card_number).must_equal mock_payment_params[:payment][:card_number]
+ expect(payment.expiration_date).must_equal mock_payment_params[:payment][:expiration_date]
+ expect(payment.cvv).must_equal mock_payment_params[:payment][:cvv]
+ expect(payment.card_type).must_equal mock_payment_params[:payment][:card_type]
+
+ must_redirect_to checkout_path
+
+ end
+
+ it "renders bad_request and does not update the DB for missing data" do
+ mock_payment_params[:payment][:card_number] = nil
+
+ expect {
+ post payments_path, params: mock_payment_params
+ }.wont_change 'Payment.count'
+
+ must_respond_with :bad_request
+ 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..12b56f735b
--- /dev/null
+++ b/test/controllers/products_controller_test.rb
@@ -0,0 +1,282 @@
+require "test_helper"
+
+describe ProductsController do
+ let(:spaghetti) {products(:spaghetti)}
+ let(:lasagne) {products(:lasagne)}
+ let(:seller) {users(:seller)}
+ let(:buyer) {users(:buyer)}
+
+ let(:mock_params) {
+ {
+ product:
+ {
+ name: 'ziti',
+ user_id: seller.id,
+ price_in_cents: 3.49,
+ category: 'short',
+ quantity: 100,
+ description: 'these ones are ziti',
+ image_url: http
+ }
+ }
+ }
+
+ describe 'guest users' do
+ describe 'index' do
+ it 'succeeds' do
+ get products_path
+
+ must_respond_with :success
+ end
+
+ end
+
+ describe 'show' do
+ it 'succeeds given a valid ID' do
+ get product_path(spaghetti.id)
+
+ must_respond_with :success
+ end
+
+ it 'responds with not found given an invalid ID' do
+ get product_path(-1)
+
+ must_respond_with :not_found
+ end
+
+ end
+
+
+ describe 'guest restrictions' do
+
+ it "cannot access new" do
+ get new_product_path
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal "You must be a merchant to sell a product. Sign up as a merchant to continue!"
+ end
+ end
+ end
+
+
+ describe 'authorized and logged in user functionality' do
+ let(:seller) {users(:seller)}
+ let(:buyer) {users(:buyer)}
+
+ describe 'logged in user that is not a seller' do
+
+ it 'does not allow a non-seller user to create a new product' do
+ perform_login(buyer)
+ get new_product_path
+ must_redirect_to user_path(buyer.id)
+ expect(flash[:warning]).must_equal "You must be a merchant to sell a product. Sign up as a merchant to continue!"
+ end
+ end
+
+ describe "logged in user that is a seller" do
+
+ describe 'new and create' do
+ it 'allows a seller user to create a new product' do
+ perform_login(seller)
+ get new_product_path
+ assert_response :success
+
+ expect {
+ post products_path, params: mock_params
+ }.must_change 'Product.count', 1
+
+ product = Product.last
+
+ expect(product.name).must_equal mock_params[:product][:name]
+ expect(product.user_id).must_equal seller.id
+ expect(product.price_in_cents).must_equal 349
+ expect(product.category).must_equal mock_params[:product][:category]
+ expect(product.quantity).must_equal mock_params[:product][:quantity]
+ expect(product.description).must_equal mock_params[:product][:description]
+
+ must_redirect_to product_path(product.id)
+
+ end
+
+ it "renders bad_request and does not update the DB for bogus data" do
+ mock_params[:product][:price_in_cents] = 'words'
+ perform_login(seller)
+
+
+ expect {
+ post products_path, params: mock_params
+ }.wont_change 'Product.count'
+
+ must_respond_with :bad_request
+ end
+ end
+
+ end
+
+
+
+ describe "edit for product created by user" do
+ #login user as seller
+ #user product that belongs to the seller
+
+ it "succeeds with valid id that belongs to them" do
+ perform_login(seller)
+ get edit_product_path(spaghetti.id)
+
+ must_respond_with :success
+
+ end
+
+ it "renders 404 not_found for an invalid id" do
+ #create a product is theirs
+ #delete products, run this test
+ perform_login(seller)
+ get edit_product_path(-1)
+
+ must_respond_with :not_found
+ end
+
+ it "doesn't allow a user that is not a seller to edit a valid item" do
+ #try editing a product that is not theirs and gives error messages
+ perform_login(buyer)
+ get edit_product_path(spaghetti.id)
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal "You don't have permission to see that."
+ end
+
+ it "fails with valid id that does not belong to them" do
+ ada = users(:ada)#try editing a product that is not theirs and gives error messages
+ perform_login(ada)
+ get edit_product_path(spaghetti.id)
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal "You can only edit your own products."
+ end
+ end
+
+ describe "update product" do
+ it 'can update a product' do
+ mock_product_params = {
+ product: {
+ quantity: 30,
+ price_in_cents: 5.99
+ }
+ }
+
+ lasagne = products(:lasagne)
+ expect(lasagne.quantity).must_equal 25
+ perform_login(seller)
+
+ expect{
+ patch product_path(lasagne.id), params: mock_product_params
+ #binding.pry
+ }.must_change 'lasagne.reload.quantity', 5
+
+ must_redirect_to product_path(lasagne.id)
+ expect(flash[:success]).must_equal "Successfully updated lasagne"
+ expect(lasagne.quantity).must_equal 30
+ expect(lasagne.price_in_cents).must_equal 599
+ end
+
+ it 'can flashes an error for invalid params for updating a product' do
+ mock_product_params = {
+ product: {
+ quantity: -2,
+ price_in_cents: 5.99
+ }
+ }
+
+ lasagne = products(:lasagne)
+ expect(lasagne.quantity).must_equal 25
+ perform_login(seller)
+
+ expect{
+ patch product_path(lasagne.id), params: mock_product_params
+ }.wont_change 'lasagne.reload.quantity'
+
+ expect(flash[:warning]).must_equal "A problem occurred: Could not update lasagne"
+ expect(lasagne.quantity).must_equal 25
+ expect(lasagne.price_in_cents).must_equal 499
+ end
+ end
+
+ describe 'deactivate products' do
+ it 'prevents a guest user from deactivating a product' do
+
+ patch deactivate_product_path(lasagne.id)
+
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal "You don't have permission to see that."
+ end
+
+ it 'allows a logged-in user to deactivate their own product' do
+ perform_login(seller)
+
+ expect(lasagne.is_active).must_equal true
+
+ patch deactivate_product_path(lasagne.id)
+
+ lasagne.reload
+
+ expect(lasagne.is_active).must_equal false
+
+ must_redirect_to merchant_my_products_path
+
+ end
+
+ it 'allows a logged-in user to activate their own product' do
+ perform_login(seller)
+
+ lasagne.is_active = false
+ lasagne.save
+
+ patch deactivate_product_path(lasagne.id)
+
+ lasagne.reload
+
+ expect(lasagne.is_active).must_equal true
+
+ must_redirect_to merchant_my_products_path
+
+ end
+
+ it 'redirects to root if someone tries to deactivate someone elses product' do
+ buyer.is_a_seller = true
+
+ buyer.save
+
+ perform_login(buyer)
+
+ expect(lasagne.is_active).must_equal true
+
+ patch deactivate_product_path(lasagne.id)
+
+ lasagne.reload
+
+ expect(lasagne.is_active).must_equal true
+
+ must_redirect_to root_path
+ end
+
+ it 'redirects to root if a non-seller tries to deactivate' do
+ perform_login(buyer)
+
+ expect(lasagne.is_active).must_equal true
+
+ patch deactivate_product_path(lasagne.id)
+
+ lasagne.reload
+
+ expect(lasagne.is_active).must_equal true
+
+ must_redirect_to root_path
+ end
+ end
+
+ describe 'index by merchant' do
+ it 'successfully renders the index by merchant view' do
+ get products_by_merchant_path
+
+ must_respond_with :success
+ end
+ 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..fc7901923d
--- /dev/null
+++ b/test/controllers/reviews_controller_test.rb
@@ -0,0 +1,96 @@
+require "test_helper"
+
+describe ReviewsController do
+ let(:spaghetti) {products(:spaghetti)}
+ let(:seller) {users(:seller)}
+ let(:review_hash) do
+ {
+ review: {
+ review: 'relieves anxiety',
+ rating: 5,
+
+ product_id: spaghetti.id
+ }
+ }
+ end
+ it 'succeeds' do
+ get reviews_path
+
+ must_respond_with :success
+ end
+
+ describe "index" do
+ it "index action should show all the reviews" do
+ @reviews = Review.all
+
+ get reviews_url
+ value(response).must_be :successful?
+ end
+
+ it "should display no reviews when there are no reviews" do
+ Review.destroy_all
+
+ get reviews_path
+ must_respond_with :success
+ expect(Review.all.count).must_equal 0
+ end
+ end
+
+
+ describe "new" do
+
+ it "succeeds" do
+
+ get new_product_review_path(spaghetti.id)
+
+ must_respond_with :success
+ end
+
+ it "checks the owner cannot review their own product" do
+ perform_login(seller)
+ get new_product_review_path(spaghetti.id)
+
+ must_redirect_to product_path(spaghetti.id)
+ end
+
+ it "responds with not_found with a bad id" do
+ get new_product_review_path(-1)
+
+ must_respond_with :not_found
+ end
+ end
+
+ describe "create" do
+ it "creates a review if valid data is provided" do
+ expect {
+ post create_review_path(spaghetti.id), params: review_hash
+ }.must_change 'Review.count', 1
+
+ must_redirect_to product_path(spaghetti.id)
+ end
+
+ it "renders not_found when invalid data is provided" do
+
+ # Arranges
+ review_hash[:review][:rating] = nil
+
+ # Act-Assert
+ expect {
+ post create_review_path(spaghetti.id), params: review_hash
+ }.wont_change 'Review.count'
+
+ get product_path(-1)
+
+ must_respond_with :not_found
+ end
+ it "checks the owner cannot review their own product" do
+ perform_login(seller)
+ expect {
+ post create_review_path(spaghetti.id), params: review_hash
+ }.wont_change 'Review.count'
+
+ must_redirect_to product_path(spaghetti.id)
+ 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..a8b44cfa4c
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,50 @@
+ require "test_helper"
+
+describe SessionsController do
+ describe "auth_callback" do
+ let(:grace) {users(:grace)}
+ it "logs in an existing user and redirects to the root route" do
+ expect{perform_login(grace)}.wont_change('User.count')
+ # start_count = User.count
+ # user = users(:grace)
+ #
+ # perform_login(user)
+ must_redirect_to root_path
+ expect(session[:user_id]).must_equal grace.id
+ #
+ # # Should *not* have created a new user
+ # User.count.must_equal start_count
+ end
+ end
+
+ it "creates an account for a new user and redirects to the root route" do
+ start_count = User.count
+ user = User.new(provider: "github", uid: 99999, full_name: "test_user", email: "test@user.com")
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+
+ # Should have created a new user
+ User.count.must_equal start_count + 1
+
+ # The new user's ID should be set in the session
+ session[:user_id].must_equal User.last.id
+ end
+
+ it "redirects to the login route if given invalid user data" do
+
+ user = User.new(provider: "github", uid: 99999 , full_name: "test_user", email: "")
+
+ expect{ perform_login(user)}.wont_change('User.count')
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+
+ end
+
+
+end
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
new file mode 100644
index 0000000000..c5dfff6f37
--- /dev/null
+++ b/test/controllers/users_controller_test.rb
@@ -0,0 +1,206 @@
+require "test_helper"
+
+describe UsersController do
+
+ describe "creating users" do
+
+ it "creates an account for a new user and redirects to the root route" do
+ start_count = User.count
+ #i think this is a session test
+ end
+
+ it "creates a new user" do
+ start_count = User.count
+ user = User.new(provider: "github", uid: 99999, full_name: "test_user", email: "test@user.com")
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+
+ # Should have created a new user
+ User.count.must_equal start_count + 1
+
+ # The new user's ID should be set in the session
+ session[:user_id].must_equal User.last.id
+ end
+
+ end
+
+ describe 'logging in' do
+ it "logs in an existing user" do
+ start_count = User.count
+ grace = users(:grace)
+ perform_login(grace)
+ must_redirect_to root_path
+ session[:user_id].must_equal grace.id
+
+ User.count.must_equal start_count
+ end
+
+ it "logs out a user, clearing the session user id" do
+ grace = users(:grace)
+ perform_login(grace)
+
+ expect(session[:user_id]).must_equal grace.id
+
+ delete logout_path
+
+ expect(session[:user_id]).must_equal nil
+ end
+
+ end
+
+ describe 'user account page' do
+
+ it 'redirects a guest from trying to access the account page' do
+ @login_user = nil
+ id = 1
+ get user_path(id)
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal "Oops, you must create an account to view this page!"
+
+ end
+
+ it 'shows an account page for a user' do
+ seller = users(:seller)
+ perform_login(seller)
+ get user_path(seller.id)
+ must_respond_with :success
+ end
+
+ it 'allows a user to become a seller/merchant' do
+ buyer = users(:buyer)
+ perform_login(buyer)
+ patch update_user_path(buyer.id), params: {
+ user: {
+ is_a_seller: true
+ }
+ }
+ must_redirect_to account_path
+ expect(flash[:success]).must_equal"Account settings updated!"
+
+ end
+
+ end
+
+ describe 'merchant user settings' do
+
+ it 'shows a dashbboard of a merchants store' do
+ seller = users(:seller)
+ perform_login(seller)
+ get dashboard_path
+ must_respond_with :success
+ end
+
+ it 'redirects a guest user from seeing a dashboard' do
+ get dashboard_path
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal"You don't have permission to view that page"
+
+ end
+
+ it 'redirects a non-seller user from seeing a dashboard' do
+ buyer = users(:buyer)
+ perform_login(buyer)
+ get dashboard_path
+ must_redirect_to root_path
+ expect(flash[:warning]).must_equal"You don't have permission to view that page"
+ end
+
+ end
+
+ describe 'merchant dashboard' do
+ it 'shows all the merchants products' do
+ seller = users(:seller)
+ perform_login(seller)
+ get merchant_my_products_path
+ must_respond_with :success
+ end
+ end
+ # it 'shows all the merchants products by status' do
+ # # active. count
+ # # instance of
+ # # produt .name
+ # #
+ # # inactive
+ # # instance of
+ # # product.name
+ # end
+ #
+ it 'renders not found for orders that havent been placed/are in shopping cart' do
+ perform_login(users(:buyer))
+ get merchant_order_path(orders(:order_one).id)
+
+ must_respond_with :not_found
+ end
+
+ it 'renders not found for orders that do not exist' do
+ perform_login(users(:buyer))
+
+ get merchant_order_path(-1)
+
+ must_respond_with :not_found
+ end
+ #
+ # it 'shows the order_product row specific to the merhcnat for an order' do
+ #
+ # end
+ #
+ # it 'shows their subtotal for the row of their order for an order' do
+ #
+ # end
+ #
+ # end
+
+ describe "it can update user status as seller" do
+
+ it 'can turn off seller status and deactive their products accordingly' do
+ seller = users(:seller)
+ perform_login(seller)
+ patch update_user_path(seller.id), params: {
+ user: {
+ is_a_seller: false
+ }
+ }
+ expect(seller.products[1].is_active).must_equal false
+
+ must_redirect_to account_path
+ expect(flash[:success]).must_equal "Account settings updated!"
+ end
+
+ it 'can turn on a users selling status and reactivate products' do
+ seller = users(:seller)
+ perform_login(seller)
+ patch update_user_path(seller.id), params: {
+ user: {
+ is_a_seller: true
+ }
+ }
+ expect(seller.products[0].is_active).must_equal true
+
+ must_redirect_to account_path
+ expect(flash[:success]).must_equal "Account settings updated!"
+ end
+
+ end
+
+ describe "it shows orders that merchants need to fulfill" do
+
+ it 'finds an order a merchant needs to fulfill' do
+ seller = users(:seller)
+ order = orders(:order_two)
+ perform_login(seller)
+ get merchant_order_path(order.id)
+ must_respond_with :success
+ end
+
+ # it 'renders not found for a merchants products that are still in the shopping ' do
+ # seller = users(:seller)
+ # order = orders(:order_one)
+ # perform_login(seller)
+ # get merchant_order_path(order.id)
+ # must_respond_with :not_found
+ # 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/addresses.yml b/test/fixtures/addresses.yml
new file mode 100644
index 0000000000..7eef91c862
--- /dev/null
+++ b/test/fixtures/addresses.yml
@@ -0,0 +1,35 @@
+# 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
+#
+home:
+ user: buyer
+ first_name: Pasta
+ last_name: Eater
+ street: 123 Macaroni Lane
+ street_2: Apt 4A
+ city: Bellevue
+ state: WA
+ zip: 98004
+
+school:
+ user: buyer
+ first_name: Ada
+ last_name: Lovelace
+ street: 1215 4th Ave
+ street_2: Suite 1050
+ city: Seattle
+ state: WA
+ zip: 98161
+
+work:
+ user: seller
+ first_name: Francesco
+ last_name: Rinaldi
+ street: 1215 4th Ave
+ street_2: Suite 1050
+ city: Seattle
+ state: WA
+ zip: 98161
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/order_products.yml b/test/fixtures/order_products.yml
new file mode 100644
index 0000000000..232d8a7654
--- /dev/null
+++ b/test/fixtures/order_products.yml
@@ -0,0 +1,29 @@
+# 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
+#
+order_one_spaghetti:
+ order: order_one
+ product: spaghetti
+ quantity: 5
+
+# column: value
+#
+order_one_lasagne:
+ order: order_one
+ product: lasagne
+ quantity: 2
+
+
+order_two_spaghetti:
+ order: order_two
+ product: spaghetti
+ quantity: 1
+
+order_four_fusili:
+ order: order_four
+ product: fusilli
+ quantity: 1
+# column: value
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..5431ff0f47
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,32 @@
+# 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
+#
+order_one:
+ user: buyer
+ status: pending
+ payment: amex
+ address: school
+
+# column: value
+#
+order_two:
+ user: buyer
+ status: paid
+ payment: visa
+ address: home
+# column: value
+
+order_three:
+ user: seller
+ status: paid
+ payment: discover
+ address: work
+
+order_four:
+ user: buyer
+ status: complete
+ payment: discover
+ address: work
diff --git a/test/fixtures/payments.yml b/test/fixtures/payments.yml
new file mode 100644
index 0000000000..400959ceb9
--- /dev/null
+++ b/test/fixtures/payments.yml
@@ -0,0 +1,31 @@
+# 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
+#
+amex:
+ user: buyer
+ address: home
+ card_number: 378282246310005
+ expiration_date: Date.parse(January 2, 2050)
+ cvv: 1234
+ card_type: AMEX
+# column: value
+#
+visa:
+ user: buyer
+ address: home
+ card_number: 4012888888881881
+ expiration_date: Date.parse(January 2, 2050)
+ cvv: 123
+ card_type: VISA
+# column: value
+
+discover:
+ user: seller
+ address: work
+ card_number: 378282246310005
+ expiration_date: Date.parse(January 2, 2050)
+ cvv: 1234
+ card_type: Discover
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
new file mode 100644
index 0000000000..5e19eab832
--- /dev/null
+++ b/test/fixtures/products.yml
@@ -0,0 +1,44 @@
+# 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
+#
+spaghetti:
+ name: spaghetti
+ user: seller
+ price_in_cents: 299
+ quantity: 50
+ category: long
+ description: this is a box of spaghetti
+ is_active: true
+ image_url: http
+
+lasagne:
+ name: lasagne
+ user: seller
+ price_in_cents: 499
+ quantity: 25
+ category: sheet
+ description: these are lasagne noodles
+ image_url: http
+
+
+fusilli:
+ name: fusilli
+ user: seller
+ price_in_cents: 400
+ quantity: 20
+ category: short
+ description: fusilli jerry, because you're silly
+ image_url: http
+
+inactive_ravioli:
+ name: ravioli
+ user: seller
+ price_in_cents: 399
+ quantity: 34
+ category: filled
+ description: roly poly ravioli
+ is_active: false
+ image_url: http
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..7087fbf793
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,35 @@
+# 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:
+ user: buyer
+ product: spaghetti
+ review: This spaghetti was not as long as I expected.
+ rating: 3
+
+two:
+ user: buyer
+ product: lasagne
+ review: It was pretty sheety lasagne.
+ rating: 5
+
+three:
+ user: buyer
+ product: spaghetti
+ review: It was pretty sheety lasagne.
+ rating: 4
+
+four:
+ user: buyer
+ product: spaghetti
+ review: It was pretty sheety lasagne.
+ rating: 3
+
+five:
+ user: buyer
+ product: spaghetti
+ review: It was pretty sheety lasagne.
+ rating: 2
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000000..d69582d531
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,35 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+seller:
+ full_name: Francesco Rinaldi
+ email: francesco@rinaldi.com
+ is_a_seller: true
+ uid: 12345678
+ provider: github
+
+buyer:
+ full_name: Pasta Eater
+ email: pasta@eater.com
+ is_a_seller: false
+ uid: 23456789
+ provider: github
+
+ada:
+ provider: github
+ uid: 12345
+ email: ada@adadevelopersacademy.org
+ full_name: countess_ada
+ is_a_seller: true
+
+grace:
+ provider: github
+ uid: 13371337
+ email: grace@hooper.net
+ full_name: graceful_hopps
+
+guest:
+ is_a_seller: false
+ provider: guest_login
+ uid: 98765432
+ email: example@example.com
+ full_name: Guest user
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/helpers/test_helper.rb b/test/helpers/test_helper.rb
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/address_test.rb b/test/models/address_test.rb
new file mode 100644
index 0000000000..c1f7c8b262
--- /dev/null
+++ b/test/models/address_test.rb
@@ -0,0 +1,123 @@
+require "test_helper"
+
+describe Address do
+ let(:address) { addresses(:home) }
+
+ it "must be valid" do
+ value(address).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:user_id, :first_name, :last_name, :street, :city, :state, :zip]
+
+ fields.each do |field|
+ expect(address).must_respond_to field
+ end
+ end
+
+
+ describe 'Relationships' do
+
+ it 'belongs to a user' do
+ user = address.user
+ expect(user).must_be_instance_of User
+ expect(user.id).must_equal address.user_id
+ end
+
+
+ it 'has one user' do
+ user = address.user
+ expect(user).must_be_instance_of User
+ end
+
+
+ end
+
+ describe 'validations' do
+ it 'must have a user' do
+ address = addresses(:home)
+ address.user = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:user]).must_equal ["must exist"]
+ end
+
+ it 'must have a first_name' do
+ address = addresses(:home)
+ address.first_name = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:first_name]).must_equal ["can't be blank"]
+ end
+
+ it 'must have a last_name' do
+ address = addresses(:home)
+ address.last_name = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:last_name]).must_equal ["can't be blank"]
+ end
+ it 'must have a street' do
+ address = addresses(:home)
+ address.street = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:street]).must_equal ["can't be blank"]
+ end
+ it 'must have a city' do
+ address = addresses(:home)
+ address.city = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:city]).must_equal ["can't be blank"]
+ end
+
+ it 'must have a state' do
+ address = addresses(:home)
+ address.state = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:state]).must_equal ["can't be blank"]
+ end
+
+ it 'must have a zip' do
+ address = addresses(:home)
+ address.zip = nil
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:zip]).must_equal ["can't be blank", "is not a number", "is too short (minimum is 5 characters)"]
+ end
+
+ it 'must have a zip that is numerical' do
+ address = addresses(:home)
+ address.zip = 'abced'
+ address.save
+
+ valid = address.valid?
+
+ expect(valid).must_equal false
+ expect(address.errors.messages[:zip]).must_equal ["is not a number", "is too short (minimum is 5 characters)"]
+ end
+ end
+end
diff --git a/test/models/order_product_test.rb b/test/models/order_product_test.rb
new file mode 100644
index 0000000000..b114826fcd
--- /dev/null
+++ b/test/models/order_product_test.rb
@@ -0,0 +1,63 @@
+require "test_helper"
+
+describe OrderProduct do
+ let(:order_product) { order_products(:order_one_spaghetti) }
+ it "must be valid" do
+ value(order_product).must_be :valid?
+ end
+ it 'has required fields' do
+ fields = [:order, :product, :quantity]
+ fields.each do |field|
+ expect(order_product).must_respond_to field
+ end
+ end
+ describe 'Relationships' do
+ it 'belongs to an order' do
+ order = order_product.order
+ expect(order).must_be_instance_of Order
+ expect(order.id).must_equal order_product.order_id
+ end
+ it 'belongs to a product' do
+ product = order_product.product
+ expect(product).must_be_instance_of Product
+ expect(product.id).must_equal order_product.product_id
+ end
+ end
+ describe 'validations' do
+ it 'must have an order' do
+ order_product = order_products(:order_one_spaghetti)
+ order_product.order = nil
+ order_product.save
+ valid = order_product.valid?
+ expect(valid).must_equal false
+ expect(order_product.errors.messages[:order]).must_equal ["must exist", "can't be blank"]
+ end
+ it 'must have aa product' do
+ order_product = order_products(:order_one_spaghetti)
+ order_product.product = nil
+ order_product.save
+ valid = order_product.valid?
+ expect(valid).must_equal false
+ expect(order_product.errors.messages[:product]).must_equal ["must exist", "can't be blank"]
+ end
+ it 'must have an quantity' do
+ order_product = order_products(:order_one_spaghetti)
+ order_product.quantity = nil
+ order_product.save
+ valid = order_product.valid?
+ expect(valid).must_equal false
+ expect(order_product.errors.messages[:quantity]).must_equal ["can't be blank", "Must add atleast a quantity of one.", "Can't order that quantity."]
+ end
+ end
+
+ describe 'item_subtotal method' do
+ it 'returns the price of the item times the quantity in the cart' do
+ order_product = order_products(:order_one_spaghetti)
+ item = products(:spaghetti)
+
+ expect(order_product.item_subtotal).must_equal (5 * 299)
+
+ end
+
+ end
+end
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..4d31a753a4
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,123 @@
+require "test_helper"
+
+describe Order do
+ let(:order) { orders(:order_one) }
+
+ describe 'validates' do
+
+ it "must be valid" do
+ value(order).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:user_id, :status]
+ fields.each do |field|
+ expect(order).must_respond_to field
+ end
+ end
+
+ end
+
+
+ describe 'Relationships' do
+ it 'can have many products' do
+
+ products = order.products
+ expect(products.length).must_be :>=, 1
+ products.each do |product|
+ expect(product).must_be_instance_of Product
+ end
+ end
+
+ it 'can have many order_products' do
+ OrderProduct.create(order: order, product: products(:lasagne), quantity: 5)
+
+ order_products = order.order_products
+ expect(order_products.length).must_be :>=, 2
+ order_products.each do |order_product|
+ expect(order_product).must_be_instance_of OrderProduct
+ end
+ end
+
+ it 'can have one payment' do
+ payment = order.payment
+ expect(payment).must_be_instance_of Payment
+ end
+
+ it 'can have one address' do
+ address = order.address
+ expect(address).must_be_instance_of Address
+ end
+
+ it 'belongs to a user' do
+ user = order.user
+ expect(user).must_be_instance_of User
+ expect(user.id).must_equal order.user_id
+ end
+
+ end
+
+
+ describe 'validations' do
+
+ it 'must have a user' do
+ order = orders(:order_one)
+ order.user = nil
+ order.save
+
+ valid = order.valid?
+
+ expect(valid).must_equal false
+ expect(order.errors.messages[:user]).must_equal ["must exist"]
+ end
+
+
+ it 'must have a status' do
+ order = orders(:order_one)
+ order.status = nil
+ order.save
+
+ valid = order.valid?
+
+ expect(valid).must_equal false
+ expect(order.errors.messages[:status]).must_equal ["can't be blank"]
+ end
+
+ end
+
+
+ describe "custom validations" do
+ let(:placed_order) { orders(:order_two) }
+
+ describe "validations for a :placed_order" do
+ it "placed_order will work if it has a payment and address'" do
+
+ placed_order.save
+
+ valid = placed_order.valid?
+
+ expect(valid).must_equal true
+ end
+
+ it 'will not work if it does not have a payment' do
+ placed_order.payment = nil
+ placed_order.save
+
+ valid = placed_order.valid?
+ expect(valid).must_equal false
+
+ end
+
+ it 'will not work if it does not have an address' do
+ placed_order.address = nil
+ placed_order.save
+
+ valid = placed_order.valid?
+ expect(valid).must_equal false
+ end
+
+ end
+
+ end
+
+end
diff --git a/test/models/payment_test.rb b/test/models/payment_test.rb
new file mode 100644
index 0000000000..6041806316
--- /dev/null
+++ b/test/models/payment_test.rb
@@ -0,0 +1,156 @@
+require "test_helper"
+
+describe Payment do
+ let(:payment) { payments(:visa) }
+
+ it "must be valid" do
+ value(payment).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:user_id, :address_id, :card_type, :card_number, :expiration_date, :cvv]
+
+ fields.each do |field|
+ expect(payment).must_respond_to field
+ end
+ end
+
+
+ describe 'Relationships' do
+
+ it 'belongs to a user' do
+ user = payment.user
+ expect(user).must_be_instance_of User
+ expect(user.id).must_equal payment.user_id
+ end
+
+ # it 'belongs to an order' do
+ # order = payment.order
+ # expect(order).must_be_instance_of Order
+ # expect(order.id).must_equal payment.order_id
+ # end
+
+ it 'belongs to an address' do
+ address = payment.address
+ expect(address).must_be_instance_of Address
+ expect(address.id).must_equal payment.address_id
+ end
+
+
+ end
+
+ describe 'validations' do
+ it 'must have a user' do
+ payment = payments(:amex)
+ payment.user = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:user]).must_equal ["must exist"]
+ end
+
+ it 'must have an address' do
+ payment = payments(:amex)
+ payment.address = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:address]).must_equal ["must exist"]
+ end
+
+ it 'must have a card_number' do
+ payment = payments(:amex)
+ payment.card_number = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:card_number]).must_equal ["can't be blank", "is not a number", "is too short (minimum is 14 characters)"]
+ end
+
+ it 'must have a card_number that is between 14 and 17 integers' do
+ payment = payments(:amex)
+ payment.card_number = 12309845
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:card_number]).must_equal ["is too short (minimum is 14 characters)"]
+
+ payment.card_number = 12309845123454321233
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:card_number]).must_equal ["is too long (maximum is 17 characters)"]
+ end
+
+ it 'must have an expiration date' do
+ payment = payments(:amex)
+ payment.expiration_date = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:expiration_date]).must_equal ["can't be blank"]
+ end
+
+ it 'must have a cvv' do
+ payment = payments(:amex)
+ payment.cvv = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:cvv]).must_equal ["can't be blank", "is not a number","is too short (minimum is 3 characters)"]
+ end
+
+ it 'must have a cvv between 3-6 numbers long' do
+ payment = payments(:amex)
+ payment.cvv = 12
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:cvv]).must_equal ["is too short (minimum is 3 characters)"]
+
+ payment.cvv = 1234567
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:cvv]).must_equal ["is too long (maximum is 6 characters)"]
+
+ payment.cvv = 'abc'
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:cvv]).must_equal ["is not a number","is too short (minimum is 3 characters)"]
+
+ end
+
+ it 'must have a card_type' do
+ payment = payments(:amex)
+ payment.card_type = nil
+ payment.save
+
+ valid = payment.valid?
+
+ expect(valid).must_equal false
+ expect(payment.errors.messages[:card_type]).must_equal ["can't be blank"]
+ end
+ end
+end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
new file mode 100644
index 0000000000..24d9188bd7
--- /dev/null
+++ b/test/models/product_test.rb
@@ -0,0 +1,151 @@
+require "test_helper"
+
+describe Product do
+ let(:product) { products(:spaghetti) }
+
+ it "knows its own categories" do
+ expect(Product.categories).must_equal ['long', 'short', 'shell', 'sheet', 'filled', 'soup']
+ end
+
+ it "can filter only active products" do
+ expect(Product.active_products.count).must_equal 3
+ expect(Product.active_products).wont_include products(:inactive_ravioli)
+ end
+
+ it "returns an empty set with no active products" do
+ Product.all.each do |product|
+ product.is_active = false
+ product.save
+ end
+
+ expect(Product.active_products.count).must_equal 0
+ end
+
+ it "knows its average_rating " do
+ expect(product.average_rating).must_equal 3
+ end
+
+ it "returns not yet rated if there are no ratings" do
+ expect(products(:fusilli).average_rating).must_equal 'Not yet rated'
+ end
+
+ it "must be valid" do
+ value(product).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:user_id, :name, :price_in_cents, :quantity, :category, :description]
+
+ fields.each do |field|
+ expect(product).must_respond_to field
+ end
+ end
+
+
+ describe 'Relationships' do
+
+ it 'can have many reviews' do
+ reviews = product.reviews
+
+
+ expect(reviews.length).must_be :>=, 1
+ reviews.each do |review|
+ expect(review).must_be_instance_of Review
+ end
+ end
+
+ it 'can have many orders' do
+ orders = product.orders
+
+ expect(orders.length).must_be :>=, 1
+ orders.each do |order|
+ expect(order).must_be_instance_of Order
+ end
+ end
+
+ it 'can have many order_products' do
+ OrderProduct.create(order: orders(:order_one), product: products(:spaghetti), quantity: 5)
+ order_products = product.order_products
+
+ expect(order_products.length).must_be :>=, 2
+ order_products.each do |order_product|
+ expect(order_product).must_be_instance_of OrderProduct
+ end
+ end
+
+ it 'belongs to a user' do
+ user = product.user
+ expect(user).must_be_instance_of User
+ expect(user.id).must_equal product.user_id
+ end
+
+ end
+
+ describe 'validations' do
+ it 'must have a user' do
+ product = products(:lasagne)
+ product.user = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:user]).must_equal ["must exist"]
+ end
+
+ it 'must have a name' do
+ product = products(:lasagne)
+ product.name = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:name]).must_equal ["can't be blank"]
+ end
+
+ it 'must have an price_in_cents' do
+ product = products(:lasagne)
+ product.price_in_cents = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:price_in_cents]).must_equal ["can't be blank", "Price must be greater than 0"]
+ end
+
+ it 'must have a quantity' do
+ product = products(:lasagne)
+ product.quantity = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:quantity]).must_equal ["can't be blank", "Stock cannot go below 0"]
+ end
+
+ it 'must have a category' do
+ product = products(:lasagne)
+ product.category = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:category]).must_equal ["can't be blank"]
+ end
+
+ it 'must have an description' do
+ product = products(:lasagne)
+ product.description = nil
+ product.save
+
+ valid = product.valid?
+
+ expect(valid).must_equal false
+ expect(product.errors.messages[:description]).must_equal ["can't be blank"]
+ end
+ end
+end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..98849e24b4
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,71 @@
+require "test_helper"
+
+describe Review do
+ let(:review) { reviews(:one) }
+
+ describe "validates" do
+
+ it "must be valid" do
+ value(review).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:user_id, :product_id, :rating]
+
+ fields.each do |field|
+ expect(review).must_respond_to field
+ end
+ end
+ end
+
+ describe 'Relationships' do
+
+ it 'can have one product' do
+ product = review.product
+ expect(product).must_be_instance_of Product
+ end
+
+
+ it 'can have one user' do
+ user = review.user
+ expect(user).must_be_instance_of User
+ end
+ end
+
+ describe 'validations' do
+ it 'does not reqire a user' do
+ review = reviews(:one)
+ review.user = nil
+ review.save
+
+ valid = review.valid?
+
+ expect(valid).must_equal true
+
+ end
+
+ it 'must have a product' do
+ review = reviews(:one)
+ review.product = nil
+ review.save
+
+ valid = review.valid?
+
+ expect(valid).must_equal false
+ expect(review.errors.messages[:product]).must_equal ["must exist"]
+
+ end
+
+ it 'must have an rating' do
+ review = reviews(:one)
+ review.rating = nil
+ review.save
+
+ valid = review.valid?
+
+ expect(valid).must_equal false
+ expect(review.errors.messages[:rating]).must_equal "can't be blank", "Rating must be greater than 0", "We're flattered but this product can
+ only be rated out of 5."
+ end
+ end
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 0000000000..3cf17f5e69
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,204 @@
+require "test_helper"
+
+class UserTest < ActiveSupport::TestCase
+ describe User do
+ let(:user) { User.new(full_name: 'Chris McNally', email: 'chris@ada.com', uid:'12345', provider: 'github') }
+
+ it "must be valid" do
+ value(user).must_be :valid?
+ end
+
+ it 'has required fields' do
+ fields = [:full_name, :email, :uid, :provider]
+
+ fields.each do |field|
+ expect(user).must_respond_to field
+ end
+ end
+ end
+
+ describe 'Relationships' do
+ let(:user) { users(:buyer)}
+
+ it 'can have many products' do
+
+ user.products << Product.first
+ products = user.products
+
+ expect(products.length).must_be :>=, 1
+ products.each do |product|
+ expect(product).must_be_instance_of Product
+ end
+ end
+
+ it 'can have many orders' do
+
+ user.orders << Order.first
+ orders = user.orders
+
+ expect(orders.length).must_be :>=, 1
+ orders.each do |order|
+ expect(order).must_be_instance_of Order
+ end
+ end
+
+ it 'can have many addresses' do
+
+ user.addresses << Address.first
+ addresses = user.addresses
+
+ expect(addresses.length).must_be :>=, 1
+ addresses.each do |address|
+ expect(address).must_be_instance_of Address
+ end
+ end
+
+ it 'can have many payments' do
+
+ user.payments << Payment.first
+ payments = user.payments
+
+ expect(payments.length).must_be :>=, 1
+ payments.each do |payment|
+ expect(payment).must_be_instance_of Payment
+ end
+ end
+
+ it 'can have many reviews' do
+
+ user.reviews << Review.first
+ reviews = user.reviews
+
+ expect(reviews.length).must_be :>=, 1
+ reviews.each do |review|
+ expect(review).must_be_instance_of Review
+ end
+ end
+ end
+
+ describe 'validations' do
+ it 'must have a full_name' do
+ user = users(:seller)
+ user.full_name = nil
+ user.save
+
+ valid = user.valid?
+
+ expect(valid).must_equal false
+ expect(user.errors.messages).must_include :full_name
+ end
+
+ it 'must have an email' do
+ user = users(:seller)
+ user.email = nil
+ user.save
+
+ valid = user.valid?
+
+ expect(valid).must_equal false
+ expect(user.errors.messages).must_include :email
+ end
+
+ it 'must have a uid' do
+ user = users(:seller)
+ user.uid = nil
+ user.save
+
+ valid = user.valid?
+
+ expect(valid).must_equal false
+ expect(user.errors.messages).must_include :uid
+ end
+
+ it 'must have a provider' do
+ user = users(:seller)
+ user.provider = nil
+ user.save
+
+ valid = user.valid?
+
+ expect(valid).must_equal false
+ expect(user.errors.messages).must_include :provider
+ end
+ end
+
+ describe 'becoming a seller' do
+ let(:guest) {users(:guest)}
+ let(:buyer) {users(:buyer)}
+
+ it 'allows a user with an account to become a seller' do
+ expect(buyer.is_a_seller).must_equal false
+
+ buyer.is_a_seller = true
+ buyer.save
+ expect(buyer.is_a_seller).must_equal true
+ end
+
+ it 'does not allow a guest user to become a seller' do
+ expect(guest.is_a_seller).must_equal false
+ guest.is_a_seller = true
+ guest.save
+
+ valid = guest.valid?
+
+ expect(valid).must_equal false
+ expect(guest.errors.messages).must_include :is_a_seller
+ expect(guest.errors.messages[:is_a_seller]).must_equal ["Must be a registered user to become a seller"]
+ end
+
+ end
+
+ describe "custom methods" do
+ let(:seller) {users(:seller)}
+ let(:buyer) {users(:buyer)}
+
+ describe 'self.merchants' do
+ it 'returns a list of all active merchants' do
+ merchant_list = User.merchants
+
+ expect(merchant_list).must_include seller
+ expect(merchant_list).wont_include buyer
+ end
+ end
+
+ describe ' total_revenue' do
+ it 'should return the total revenue for all products sold by a given merchant' do
+ expect(seller.total_revenue).must_equal 699
+ end
+
+ it 'should return the total revenue by order status for all products sold by a given merchant' do
+ expect(seller.total_revenue_by_status('paid')).must_equal 299
+
+ expect(seller.total_revenue_by_status('complete')).must_equal 400
+ end
+ end
+
+ describe 'product status' do
+ it 'sorts a merchants prodcuts by their status'do
+
+ expect(seller.product_status(true)[0]).must_be_instance_of Product
+ expect(seller.product_status(true)[0].name).must_equal 'spaghetti'
+
+ end
+ end
+
+ describe "Create user using oauth" do
+ it 'creates an instance of a user using github auth_hash' do
+ mock_hash = {
+ provider: 'github',
+ uid: 12345,
+ info: {
+ email: 'test@test.com',
+ name: 'Please pass this test'
+ }
+ }
+
+ expect(User.build_from_github(mock_hash)).must_be_instance_of User
+
+ end
+
+ 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..1c94547e3e
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,53 @@
+ENV["RAILS_ENV"] = "test"
+require 'simplecov'
+SimpleCov.start
+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"
+require 'active_support/testing/assertions'
+include ActiveSupport::Testing::Assertions
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ def setup
+ # Once you have enabled test mode, all requests
+ # to OmniAuth will be short circuited to use the mock authentication hash.
+ # A request to /auth/provider will redirect immediately to /auth/provider/callback.
+ OmniAuth.config.test_mode = true
+ end
+
+ def mock_auth_hash(user)
+ return {
+ provider: user.provider,
+ uid: user.uid,
+ info: {
+ email: user.email,
+ name: user.full_name
+ }
+ }
+ end
+
+ def perform_login(user)
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+ 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