<%= count %>. For sale: <%=item.name%><%= link_to "(details)", item_path(item)%><%= link_to "(edit)", edit_item_path(item)%><%= link_to "(delete)", item_path(item), method: :delete, data: { confirm: "Are you sure you want to delete this product: #{item.name}? You have #{item.quantity_available} of them"} %>
+
Stock: <%=item.quantity_available%>
+
Price: $<%= '%.2f' % item.price%>
+
Category: <%=item.category_id%>
+
---------------------------------------
+ <% count +=1 %>
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
<% @current_merchant_unfulfilled_order_items.each do |order_item| %>
+
For sale: <%=item.name%><%= link_to "(view)", item_path(item)%>
+ <% end %>
+
+
+
+
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..5c09a3eefc
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,25 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Betsy
+ class Application < Rails::Application
+ config.generators do |g|
+ # Force new test files to be generated in the minitest-spec style
+ g.test_framework :minitest, spec: true
+ # Always use .js files, never .coffee
+ g.javascript_engine :js
+ end
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.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..dd2a324c68
--- /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: betsy_production
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
new file mode 100644
index 0000000000..f5c513e0a3
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+EZewcexkKXzfxCJnxJ42QJHtPtFIr6ttF3k/Dn2tBxMuhH+11uugdWZi45l18hSXqJEi6Xx5d8+kB1OlQbUf8+jetufAO6tZge5jQalqgZAqsgaL4YEvrKV/bSD/EOplqq//m9IIjPceD3BR7j43Vts8T90lyMpQohM9LowJ+dfAwYg3zpTodYisKLz1NwWYYC8X3Vuc3MV+WVQqRAYV9mfXE9X/+oomu9svAq0Zx66+GGMqXnfS+WbJA+z9yLZQyZ7vW+eRNOcdW92rQaSEqvTkx1O5akTYXWEdzAmE75QmbvrqUGBM3brOAsZMzlZy3VTLoeXJQBGhw3RGWORq/0Fp3p/CAX7WPUwCzmUp3X2bFzDgembJaopXobAFNgYpm2IET68pazL53U2eC2KYf8IQaV2mLGJ2G6rT--5Nz0OdRHNlc7y/Pw--H65G7tvuiWtt3wbZkM0Rzg==
\ No newline at end of file
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000000..6903bb6083
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,85 @@
+# PostgreSQL. Versions 9.1 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On OS X with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On OS X with MacPorts:
+# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem 'pg'
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see Rails configuration guide
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: betsy_development
+
+ # The specified database role being used to connect to postgres.
+ # To create additional roles in postgres see `$ createuser --help`.
+ # When left blank, postgres will use the default role. This is
+ # the same name as the operating system user that initialized the database.
+ #username: betsy
+
+ # The password associated with the postgres role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: betsy_test
+
+# As with config/secrets.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password as a unix environment variable when you boot
+# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full rundown on how to provide these environment variables in a
+# production deployment.
+#
+# On Heroku and other platform providers, you may have a full connection URL
+# available as an environment variable. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# You can use this database configuration with:
+#
+# production:
+# url: <%= ENV['DATABASE_URL'] %>
+#
+production:
+ <<: *default
+ database: betsy_production
+ username: betsy
+ password: <%= ENV['BETSY_DATABASE_PASSWORD'] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 0000000000..426333bb46
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 0000000000..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..5f6f3058c6
--- /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 = "betsy_#{Rails.env}"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 0000000000..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..fd4416122a
--- /dev/null
+++ b/config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email"
+end
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000000..bbfc3961bf
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000000..decc5a8573
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000000..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..9802be21c4
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,29 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ root 'homepage#index'
+ get "/status/findform", to: 'status#findform'
+ get "/status/:id", to: 'status#show', as: 'status'
+ post "/status/detail", to: 'status#detail', as: 'detail'
+
+ get "users/pending", to: 'users#merchant_pending_orders', as: 'pending'
+ post "/users/:item_id/paid", to: 'users#paid', as: 'paid'
+
+ # resources :status
+ resources :users, only: [:show, :shop, :orders]
+ resources :orders, :items, :reviews, :category
+
+ resources :order_items, only: [:update, :destroy]
+
+
+ resources :items do
+ post '/order_items', to: 'order_items#create'
+ patch 'order_items', to: 'order_items#increment_quantity', as: 'increment_quantity'
+
+ resources :reviews
+ end
+
+get "/auth/:provider/callback", to: "sessions#create", as: 'auth_callback'
+post '/logout', to: 'sessions#logout', as: 'logout'
+
+get '/shop', to: 'users#shop', as: 'shop'
+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/item_seeds.csv b/db/item_seeds.csv
new file mode 100644
index 0000000000..d7d2f42bda
--- /dev/null
+++ b/db/item_seeds.csv
@@ -0,0 +1,20 @@
+price,image,quantity_available,name,description,avg_rating,user_id,active,category_id
+70,https://i.pinimg.com/236x/c3/62/9b/c3629b93a61797063ac2372ac7e63f29--liz-lisa-carry-bag.jpg,3,Sakura,20-inch hardside spinner luggage for weekend getaways or as international carry-on,4,2,true,5
+140,http://inhonorofdesign.com/wp-content/uploads/2015/01/Mint-Steamline-Luggage1.jpg,5,Steamline,Fully lined interior with divider; compression pad helps free up space; 150D-polyester interior organizer with 3 zippered pockets for securing smaller items,3,2,true,5
+100,https://rlv.zcache.com/custom_kawaii_cute_summer_tropical_pineapples_luggage-r086ff13689a94b06807ab730fe879e7e_64fbv_540.jpg?rlvnet=1,2,Globe Trotter,SMOOTH-ROLLING airflow multi-directional spinner wheels for easy movement,4,2,true,5
+30,https://i.ebayimg.com/images/g/wD0AAOSw5UVbaZD0/s-l640.jpg,5,Lets Go Pikachu Suitcase Cover,Now any boring suitcase can look amazing and bright thanks to this suitcase cover. The cover is stretchy so that it fits snug around your suitcase and it will keep your handles and wheels available for use so it just makes you suitcase look so much more fun,4,2,true,5
+40,https://i.etsystatic.com/14018434/r/il/874991/1231114367/il_570xN.1231114367_rn04.jpg,2,Travel Buddy Babadook,Cause if it's in a word or if it's in a book you can't get rid of the Babadook...Never travel alone,4,2,true,4
+25,https://www.icing.com/dw/image/v2/BBTK_PRD/on/demandware.static/-/Sites-master-catalog/default/dwbffc1c23/images/icing/hi-res/72623_1.jpg?sw=734&sh=734&sm=fit,3,Black Cat Sleep Mask,Get some rest while you travel,3,2,true,4
+60,https://cdn.shopify.com/s/files/1/0758/2735/products/TB1slR3JVXXXXbsXVXXXXXXXXXX__0-item_pic.jpg?v=1534937389,10,Bowsii MJ,Delightfully dressy Mary Janes for your next tea paaarrrtte,0,1,true,6
+50,https://d1nr5wevwcuzuv.cloudfront.net/product_photos/32510889/T2Gs20XaFaXXXXXXXX_!!12789126_original.jpg,10,Playful Rabbit,Cute and retro for your next kawaii adventure,0,1,true,6
+45,https://cdn.shopify.com/s/files/1/2420/5055/products/product-image-240638197_800x.jpg?v=1530833053,10,Mint Ice Dreamy,Carry summer with you everywhere you go with these ice cream cone patterned casual sneaks,0,1,true,6
+60,http://a2.fanbread.com/uploads/image/file/15212/extra_large_shoes_9.jpg?5a2ae58d6f9a919141d9ab57cc9d7de8,10,Pony Chops,Chantal over at Pony-Chops hand painted these cosplay shoes for a kawaii obsessed friend,0,2,true,6
+40,https://d3u67r7pp2lrq5.cloudfront.net/product_photos/25592829/181_original.jpg,10,Lolita Lace,Time to play dress up with your besties,0,2,true,6
+15,https://d2h1pu99sxkfvn.cloudfront.net/b0/4472065/369738546_TKOLSyoflE/P0.jpg,20,Little Twin Stars lanyard,Let the Twin Stars keep your travel pass safe,0,2,true,8
+20,https://www.picclickimg.com/d/l400/pict/271995172532_/JETOY-Choo-Choo-Cat-Petit-Transparent-Passport-Cover.jpg,20,Choo Choo Cat Passport,Let Choo Choo Cat lead your next adventure and keep your passport,0,3,true,8
+15,https://images-na.ssl-images-amazon.com/images/I/51FEWy6IpeL.jpg,10,Critter Luggage Tag,Kawaii Critter Tags to identify your luggage,0,4,true,8
+20,http://g01.a.alicdn.com/kf/HTB1hMJRMXXXXXXFXXXXq6xXFXXXC/Creative-kawaii-rhinestone-monchichi-keychain-doll-pendant-car-key-ring-women-handbag-bag-charm-key-chains.jpg,10,Monchichi ChiChain,Monchichi is sweet to hold in your hands with your keys,0,4,true,8
+40,https://78.media.tumblr.com/d003d0b62268bc4007d25eb14836c6f2/tumblr_mr529nSuCQ1s9dgawo1_500.jpg,10,Sparkly Pepper,Protect yourself during your travels with this stylin pepper spray,0,4,true,8
+20,http://poesprints.com/wp-content/uploads/2018/08/raven_blanket.jpg,4,Raven Travel Blanket,Quoth the raven...sleep some more!,4,3,true,4
+15,https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcT5ifb7wyonvmIXNSB1uoX5kzP1py_LPgP-hbDqVHilZ5JD52Tj1CyplU00aKiv6-NZ7FSpv3MJfuCNwNihuokXFtGM9_SVFIcefJmf2lHzo1v6z9L9A4G4&usqp=CAE,2,Home For the Holidays Krampus Luggage Tag,Kick off the holiday season early with this festive luggage tag.,4,2,true,4
+5,https://images-na.ssl-images-amazon.com/images/I/41LZf3WrtBL.jpg,2,Spooky Ghosty Stress Relief Squishy,This friendly little ghost is super soft and squeezeable. The perfect fiddle toy for easing some take off and landing jitters.,4,2,true,4
diff --git a/db/migrate/20181018212109_create_users.rb b/db/migrate/20181018212109_create_users.rb
new file mode 100644
index 0000000000..3a8f4217f1
--- /dev/null
+++ b/db/migrate/20181018212109_create_users.rb
@@ -0,0 +1,14 @@
+class CreateUsers < ActiveRecord::Migration[5.2]
+ def change
+ create_table :users do |t|
+ t.integer :uid
+ t.string :name
+ t.string :nickname
+ t.string :email
+ t.string :image_url
+ t.string :provider
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018212627_create_orders.rb b/db/migrate/20181018212627_create_orders.rb
new file mode 100644
index 0000000000..d273f0c0fa
--- /dev/null
+++ b/db/migrate/20181018212627_create_orders.rb
@@ -0,0 +1,18 @@
+class CreateOrders < ActiveRecord::Migration[5.2]
+ def change
+ create_table :orders do |t|
+ t.string :name
+ t.string :email
+ t.string :mailing_address
+ t.string :name_on_card
+ t.integer :credit_card_num
+ t.integer :credit_card_exp_month
+ t.integer :credit_card_exp_year
+ t.integer :cvv_num
+ t.integer :zipcode
+
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018213306_create_items.rb b/db/migrate/20181018213306_create_items.rb
new file mode 100644
index 0000000000..c729acf1c4
--- /dev/null
+++ b/db/migrate/20181018213306_create_items.rb
@@ -0,0 +1,15 @@
+class CreateItems < ActiveRecord::Migration[5.2]
+ def change
+ create_table :items do |t|
+ t.string :category
+ t.integer :price
+ t.string :image
+ t.integer :quantity_available
+ t.string :name
+ t.string :description
+ t.integer :avg_rating
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018213354_create_reviews.rb b/db/migrate/20181018213354_create_reviews.rb
new file mode 100644
index 0000000000..4c50e6ab91
--- /dev/null
+++ b/db/migrate/20181018213354_create_reviews.rb
@@ -0,0 +1,10 @@
+class CreateReviews < ActiveRecord::Migration[5.2]
+ def change
+ create_table :reviews do |t|
+ t.string :description
+ t.integer :rating
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018214111_delete_uid.rb b/db/migrate/20181018214111_delete_uid.rb
new file mode 100644
index 0000000000..d52b82ecf6
--- /dev/null
+++ b/db/migrate/20181018214111_delete_uid.rb
@@ -0,0 +1,5 @@
+class DeleteUid < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :users, :uid
+ end
+end
diff --git a/db/migrate/20181018214131_add_uid_to_users.rb b/db/migrate/20181018214131_add_uid_to_users.rb
new file mode 100644
index 0000000000..f36704e564
--- /dev/null
+++ b/db/migrate/20181018214131_add_uid_to_users.rb
@@ -0,0 +1,5 @@
+class AddUidToUsers < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :uid, :integer, null:false
+ end
+end
diff --git a/db/migrate/20181018214412_delete_provider_from_users.rb b/db/migrate/20181018214412_delete_provider_from_users.rb
new file mode 100644
index 0000000000..875862d5de
--- /dev/null
+++ b/db/migrate/20181018214412_delete_provider_from_users.rb
@@ -0,0 +1,5 @@
+class DeleteProviderFromUsers < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :users, :provider
+ end
+end
diff --git a/db/migrate/20181018214431_add_provider_to_users.rb b/db/migrate/20181018214431_add_provider_to_users.rb
new file mode 100644
index 0000000000..3f58d0f1a1
--- /dev/null
+++ b/db/migrate/20181018214431_add_provider_to_users.rb
@@ -0,0 +1,5 @@
+class AddProviderToUsers < ActiveRecord::Migration[5.2]
+ def change
+ add_column :users, :provider, :string, null:false
+ end
+end
diff --git a/db/migrate/20181018214642_add_status_shipped_to_order.rb b/db/migrate/20181018214642_add_status_shipped_to_order.rb
new file mode 100644
index 0000000000..22b11c61ff
--- /dev/null
+++ b/db/migrate/20181018214642_add_status_shipped_to_order.rb
@@ -0,0 +1,6 @@
+class AddStatusShippedToOrder < ActiveRecord::Migration[5.2]
+ def change
+ add_column :orders, :status, :string, default: "pending"
+ add_column :orders, :shipped, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20181018215000_create_order_items.rb b/db/migrate/20181018215000_create_order_items.rb
new file mode 100644
index 0000000000..0e744b51f7
--- /dev/null
+++ b/db/migrate/20181018215000_create_order_items.rb
@@ -0,0 +1,8 @@
+class CreateOrderItems < ActiveRecord::Migration[5.2]
+ def change
+ create_table :order_items do |t|
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018215031_delete_shipped_orders.rb b/db/migrate/20181018215031_delete_shipped_orders.rb
new file mode 100644
index 0000000000..fc818b7024
--- /dev/null
+++ b/db/migrate/20181018215031_delete_shipped_orders.rb
@@ -0,0 +1,5 @@
+class DeleteShippedOrders < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :orders, :shipped
+ end
+end
diff --git a/db/migrate/20181018215159_add_customer_to_order.rb b/db/migrate/20181018215159_add_customer_to_order.rb
new file mode 100644
index 0000000000..833fdfe640
--- /dev/null
+++ b/db/migrate/20181018215159_add_customer_to_order.rb
@@ -0,0 +1,5 @@
+class AddCustomerToOrder < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :orders, :user, foreign_key: true
+ end
+end
diff --git a/db/migrate/20181018215421_add_shipped_to_orderitem.rb b/db/migrate/20181018215421_add_shipped_to_orderitem.rb
new file mode 100644
index 0000000000..8493fb60fa
--- /dev/null
+++ b/db/migrate/20181018215421_add_shipped_to_orderitem.rb
@@ -0,0 +1,5 @@
+class AddShippedToOrderitem < ActiveRecord::Migration[5.2]
+ def change
+ add_column :order_items, :shipped, :boolean, default:false
+ end
+end
diff --git a/db/migrate/20181018215601_add_order_and_item_orderitem.rb b/db/migrate/20181018215601_add_order_and_item_orderitem.rb
new file mode 100644
index 0000000000..a6f2fa1b05
--- /dev/null
+++ b/db/migrate/20181018215601_add_order_and_item_orderitem.rb
@@ -0,0 +1,6 @@
+class AddOrderAndItemOrderitem < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :order_items, :order, foreign_key: true
+ add_reference :order_items, :item, foreign_key: true
+ end
+end
diff --git a/db/migrate/20181018215915_add_user_to_item.rb b/db/migrate/20181018215915_add_user_to_item.rb
new file mode 100644
index 0000000000..fb8251f1dd
--- /dev/null
+++ b/db/migrate/20181018215915_add_user_to_item.rb
@@ -0,0 +1,5 @@
+class AddUserToItem < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :items, :user, foreign_key: true
+ end
+end
diff --git a/db/migrate/20181018220049_add_active_to_item.rb b/db/migrate/20181018220049_add_active_to_item.rb
new file mode 100644
index 0000000000..24f53330ee
--- /dev/null
+++ b/db/migrate/20181018220049_add_active_to_item.rb
@@ -0,0 +1,5 @@
+class AddActiveToItem < ActiveRecord::Migration[5.2]
+ def change
+ add_column :items, :active, :boolean, default: true
+ end
+end
diff --git a/db/migrate/20181018220256_add_user_and_item_to_reviews.rb b/db/migrate/20181018220256_add_user_and_item_to_reviews.rb
new file mode 100644
index 0000000000..e126811966
--- /dev/null
+++ b/db/migrate/20181018220256_add_user_and_item_to_reviews.rb
@@ -0,0 +1,6 @@
+class AddUserAndItemToReviews < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :reviews, :user, foreign_key: true
+ add_reference :reviews, :item, foreign_key: true
+ end
+end
diff --git a/db/migrate/20181019232117_add_quantity_to_orderitems.rb b/db/migrate/20181019232117_add_quantity_to_orderitems.rb
new file mode 100644
index 0000000000..76dce75ade
--- /dev/null
+++ b/db/migrate/20181019232117_add_quantity_to_orderitems.rb
@@ -0,0 +1,5 @@
+class AddQuantityToOrderitems < ActiveRecord::Migration[5.2]
+ def change
+ add_column :order_items, :quantity_per_item, :integer
+ end
+end
diff --git a/db/migrate/20181020154501_create_categories.rb b/db/migrate/20181020154501_create_categories.rb
new file mode 100644
index 0000000000..c489422c78
--- /dev/null
+++ b/db/migrate/20181020154501_create_categories.rb
@@ -0,0 +1,9 @@
+class CreateCategories < ActiveRecord::Migration[5.2]
+ def change
+ create_table :categories do |t|
+ t.string :type
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181020155307_change_type_column_for_category.rb b/db/migrate/20181020155307_change_type_column_for_category.rb
new file mode 100644
index 0000000000..a86b3bfb26
--- /dev/null
+++ b/db/migrate/20181020155307_change_type_column_for_category.rb
@@ -0,0 +1,5 @@
+class ChangeTypeColumnForCategory < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :categories, :type
+ end
+end
diff --git a/db/migrate/20181020155504_add_item_type_to_category.rb b/db/migrate/20181020155504_add_item_type_to_category.rb
new file mode 100644
index 0000000000..872a551bbe
--- /dev/null
+++ b/db/migrate/20181020155504_add_item_type_to_category.rb
@@ -0,0 +1,5 @@
+class AddItemTypeToCategory < ActiveRecord::Migration[5.2]
+ def change
+ add_column :categories, :category_type, :string
+ end
+end
diff --git a/db/migrate/20181020161333_delete_category_from_items.rb b/db/migrate/20181020161333_delete_category_from_items.rb
new file mode 100644
index 0000000000..8399d40182
--- /dev/null
+++ b/db/migrate/20181020161333_delete_category_from_items.rb
@@ -0,0 +1,5 @@
+class DeleteCategoryFromItems < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :items, :category
+ end
+end
diff --git a/db/migrate/20181020161500_add_category_foreign_key_items.rb b/db/migrate/20181020161500_add_category_foreign_key_items.rb
new file mode 100644
index 0000000000..ae4ff19456
--- /dev/null
+++ b/db/migrate/20181020161500_add_category_foreign_key_items.rb
@@ -0,0 +1,5 @@
+class AddCategoryForeignKeyItems < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :items, :category, foreign_key: true
+ end
+end
diff --git a/db/migrate/20181021014223_delete_user_id_from_order.rb b/db/migrate/20181021014223_delete_user_id_from_order.rb
new file mode 100644
index 0000000000..6b9fd6ba96
--- /dev/null
+++ b/db/migrate/20181021014223_delete_user_id_from_order.rb
@@ -0,0 +1,5 @@
+class DeleteUserIdFromOrder < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :orders, :user_id
+ end
+end
diff --git a/db/migrate/20181023214234_delete_shipped_from_order_item.rb b/db/migrate/20181023214234_delete_shipped_from_order_item.rb
new file mode 100644
index 0000000000..b30190b92f
--- /dev/null
+++ b/db/migrate/20181023214234_delete_shipped_from_order_item.rb
@@ -0,0 +1,5 @@
+class DeleteShippedFromOrderItem < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :order_items, :shipped
+ end
+end
diff --git a/db/migrate/20181023214436_add_status_to_orderitem.rb b/db/migrate/20181023214436_add_status_to_orderitem.rb
new file mode 100644
index 0000000000..cf640c41ae
--- /dev/null
+++ b/db/migrate/20181023214436_add_status_to_orderitem.rb
@@ -0,0 +1,5 @@
+class AddStatusToOrderitem < ActiveRecord::Migration[5.2]
+ def change
+ add_column :order_items, :status, :string, default: "pending"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..014836aaeb
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,94 @@
+# 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_214436) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "categories", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "category_type"
+ end
+
+ create_table "items", force: :cascade do |t|
+ t.integer "price"
+ t.string "image"
+ t.integer "quantity_available"
+ t.string "name"
+ t.string "description"
+ t.integer "avg_rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.bigint "user_id"
+ t.boolean "active", default: true
+ t.bigint "category_id"
+ t.index ["category_id"], name: "index_items_on_category_id"
+ t.index ["user_id"], name: "index_items_on_user_id"
+ end
+
+ create_table "order_items", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.bigint "order_id"
+ t.bigint "item_id"
+ t.integer "quantity_per_item"
+ t.string "status", default: "pending"
+ t.index ["item_id"], name: "index_order_items_on_item_id"
+ t.index ["order_id"], name: "index_order_items_on_order_id"
+ end
+
+ create_table "orders", force: :cascade do |t|
+ t.string "name"
+ t.string "email"
+ t.string "mailing_address"
+ t.string "name_on_card"
+ t.integer "credit_card_num"
+ t.integer "credit_card_exp_month"
+ t.integer "credit_card_exp_year"
+ t.integer "cvv_num"
+ t.integer "zipcode"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "status", default: "pending"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.string "description"
+ t.integer "rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.bigint "user_id"
+ t.bigint "item_id"
+ t.index ["item_id"], name: "index_reviews_on_item_id"
+ t.index ["user_id"], name: "index_reviews_on_user_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.string "nickname"
+ t.string "email"
+ t.string "image_url"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "uid", null: false
+ t.string "provider", null: false
+ end
+
+ add_foreign_key "items", "categories"
+ add_foreign_key "items", "users"
+ add_foreign_key "order_items", "items"
+ add_foreign_key "order_items", "orders"
+ add_foreign_key "reviews", "items"
+ add_foreign_key "reviews", "users"
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..a2821178ab
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,79 @@
+# 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'
+
+#loading constants
+USER_FILE = Rails.root.join('db', 'user_seeds.csv')
+puts "Loading raw data from #{USER_FILE}"
+
+
+ITEM_FILE = Rails.root.join('db', 'item_seeds.csv')
+puts "Loading raw data from #{ITEM_FILE}"
+
+
+#############################################################
+#seeding categories
+x = ["accessories", "books", "clothing", "seasonal", "luggage", "shoes", "tech", "miscellaneous"]
+x.each do |category|
+ Category.create(category_type: category)
+end
+##############################################################
+
+##############################################################
+#seeding users
+user_failures = []
+CSV.foreach(USER_FILE, :headers => true) do |row|
+
+ user = User.new
+ user.name = row['name']
+ user.nickname = row['nickname']
+ user.email = row['email']
+ user.image_url = row['image_url']
+ user.uid = row['uid']
+ user.provider = row['provider']
+ successful = user.save
+ if !successful
+ user_failures << user
+ puts "Failed to save user: #{user.inspect}"
+ else
+ puts "Created user: #{user.inspect}"
+ end
+end
+##############################################################
+
+
+#Seeding items
+
+item_failures = []
+CSV.foreach(ITEM_FILE, :headers => true) do |row|
+
+ item = Item.new
+ item.price = row['price']
+ item.image = row['image']
+ item.quantity_available = row['quantity_available']
+ item.name = row['name']
+ item.description = row['description']
+ item.avg_rating = row['provider']
+ item.user_id = row['user_id']
+ item.active = row['active']
+ item.category_id = row['category_id']
+
+ successful = item.save
+ if !successful
+ item_failures << item
+ puts "Failed to save item: #{item.inspect}"
+ else
+ puts "Created item: #{item.inspect}"
+ end
+end
diff --git a/db/user_seeds.csv b/db/user_seeds.csv
new file mode 100644
index 0000000000..d127654ae7
--- /dev/null
+++ b/db/user_seeds.csv
@@ -0,0 +1,5 @@
+name,nickname,email,image_url,uid,provider
+jen,jen_is_cool,jen@gmail.com,https://goo.gl/4usQGd,991,aim
+doug,doug-donut,doug@gmail.com,https://goo.gl/DBLsc9,992,aim
+jazz,jazzed,jazz@gmail.com,https://bit.ly/2R5zhBa,993,aim
+layla,layayala,laya@gmail.com,https://plbz.it/2pZTSeB,994,aim
diff --git a/lib/assets/.keep b/lib/assets/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000..f874acf437
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "betsy",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/public/404.html b/public/404.html
new file mode 100644
index 0000000000..2be3af26fc
--- /dev/null
+++ b/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/422.html b/public/422.html
new file mode 100644
index 0000000000..c08eac0d1d
--- /dev/null
+++ b/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/500.html b/public/500.html
new file mode 100644
index 0000000000..78a030af22
--- /dev/null
+++ b/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000000..37b576a4a0
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/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/category_controller_test.rb b/test/controllers/category_controller_test.rb
new file mode 100644
index 0000000000..c93b7df14e
--- /dev/null
+++ b/test/controllers/category_controller_test.rb
@@ -0,0 +1,14 @@
+require "test_helper"
+
+describe CategoryController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+ it 'responds with success if the category exists' do
+ luggage_category = categories(:luggage)
+
+ get category_path(luggage_category.id)
+
+ must_respond_with :success
+ end
+end
diff --git a/test/controllers/homepage_controller_test.rb b/test/controllers/homepage_controller_test.rb
new file mode 100644
index 0000000000..7f76c0fe4d
--- /dev/null
+++ b/test/controllers/homepage_controller_test.rb
@@ -0,0 +1,8 @@
+require "test_helper"
+
+describe HomepageController do
+ it 'should get index' do
+ get root_path
+ must_respond_with :success
+ end
+end
diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb
new file mode 100644
index 0000000000..5b071bd925
--- /dev/null
+++ b/test/controllers/items_controller_test.rb
@@ -0,0 +1,158 @@
+require "test_helper"
+
+describe ItemsController do
+
+ before do
+ @linda = users(:one)
+ end
+
+ describe 'index' do
+
+ it "succeeds when there are items" do
+ get items_path
+ must_respond_with :success
+ end
+
+ end
+
+ describe "show" do
+
+ it "responds with success for showing an existing product" do
+
+ test_item = items.first
+ id = test_item.id
+
+ get item_path(id)
+
+ must_respond_with :success
+ end
+
+ end
+
+ describe "new" do
+
+ it "successful new page" do
+
+ get new_item_path
+
+ must_respond_with :success
+ end
+
+ end
+
+ let (:logged_in_linda) {
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(@linda))
+
+ get auth_callback_path(:github)
+ }
+
+ describe "create" do
+
+ it "creates an item with valid data for a real logged in user and real category" do
+
+ logged_in_linda
+ # @current_user = @linda
+
+ item_data = {
+ item:
+ {
+ name: "A BRAND NEW THING",
+ category_id: Category.first.id,
+ price: 100,
+ quantity_available: 100
+ }
+ }
+ test_item = Item.new(item_data[:item])
+
+ expect {
+ post items_path, params: item_data
+
+ }.must_change('Item.count', +1)
+
+ must_redirect_to shop_path
+ end
+
+ it "renders bad_request and does not update the DB for bogus data" do
+
+ logged_in_linda
+ # @current_user = @linda
+
+ item_data = {
+ item:
+ {
+ name: "A BRAND NEW THING",
+ category_id: Category.first.id
+ }
+ }
+
+ test_item = Item.new(item_data[:item])
+
+ expect {
+ post items_path, params: item_data
+ }.wont_change 'Item.count'
+
+ must_respond_with :bad_request
+ assert_equal "Item was not saved.", flash[:error]
+ end
+
+ end
+
+
+ describe "edit" do
+
+ it "responds with success for an existing item" do
+ get edit_item_path(Item.first)
+
+ must_respond_with :success
+ end
+
+
+ # Can't figure this one out :(
+ # describe "update" do
+ #
+ # it "successful update displays flash and redirects" do
+ # test_item = Item.create(name: "name",
+ # category: Category.first,
+ # user: User.first,
+ # price: 10,
+ # quantity_available: 10)
+ #
+ # expect {test_item.update(name: "changed name")}.must_route_to shop_path
+ # # expect flash[:success].must_equal "Item successfully updated."
+ # end
+
+end
+
+describe 'destroy' do
+
+ it 'destroy an existing item' do
+ item = Item.create(name: "SOOO Unique", category: Category.first, user: User.first, price: 10, quantity_available: 10)
+ # testing the database change
+ expect {
+ delete item_path(item)
+ }.must_change('Item.count', -1)
+ # testing the flash message
+ expect flash[:success].must_equal "Item successfully deleted."
+ # testing the path
+ must_redirect_to root_path
+ end
+
+ it 'will not destroy an item that is part of an OrderItem' do
+ @item = items(:shoes)
+ @order = orders(:one)
+ @new_order_item = OrderItem.create(order_id: @order.id, item_id: @item.id)
+
+ item_count = Item.count
+
+ delete item_path(@item)
+ # database not changed
+ expect(Item.count).must_equal item_count
+ # flash error appears
+ flash[:error].must_equal "Item cannot be deleted. There is a pending order with this item"
+ # redirect back
+ must_redirect_to root_path
+ end
+
+end
+
+end
diff --git a/test/controllers/order_items_controller_test.rb b/test/controllers/order_items_controller_test.rb
new file mode 100644
index 0000000000..94a795a70a
--- /dev/null
+++ b/test/controllers/order_items_controller_test.rb
@@ -0,0 +1,84 @@
+require "test_helper"
+require "pry"
+
+describe OrderItemsController do
+
+ describe "create" do
+
+ it "can create an order item with good data" do
+
+ order_item_data = {
+ item_id: Item.first.id,
+ order_id: Order.first.id,
+ quantity_per_item: 1
+ }
+
+ new_order_item = OrderItem.new(order_item_data)
+
+ new_order_item.must_be :valid?, "Data was invalid. Please come fix this test."
+
+ expect {
+ post item_order_items_path(Item.first.id),
+ params: order_item_data
+ }.must_change('OrderItem.count', +1)
+
+ end
+
+ it "does not create a new order item with bad data" do
+
+ order_item_data = {
+ item_id: Item.first.id,
+ order_id: Order.first.id,
+ quantity_per_item: nil
+ }
+
+ OrderItem.new(order_item_data).wont_be :valid?, "Data wasn't invalid. Please come fix this test."
+
+ expect {
+ post item_order_items_path(Item.first.id),
+ params: order_item_data
+ }.wont_change('OrderItem.count')
+
+ end
+ end
+
+ # describe "update" do
+ #
+ # it "can update an item's quantity" do
+ #
+ # @order = Order.first
+ # @order_item = OrderItem.first
+ #
+ # start_count = @order_item.quantity_per_item
+ #
+ # order_item_data = {
+ # quantity_per_item: @order_item.quantity_per_item + 1
+ # }
+ #
+ # expect {
+ # patch order_item_path(@order_item.id),
+ # params: order_item_data
+ # }.must_change('start_count')
+ #
+ # end
+ # end
+
+ # describe "destroy" do
+ #
+ # it "can destroy an existing order item" do
+ # start_count = OrderItem.count
+ #
+ # orderitem = OrderItem.create(
+ # item_id: Item.first.id,
+ # order_id: Order.first.id,
+ # quantity_per_item: 1
+ # )
+ #
+ # delete order_item_path(orderitem.id)
+ #
+ # expect(OrderItem.count).must_equal start_count
+ #
+ # 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..21d162e99a
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,121 @@
+require "test_helper"
+
+describe OrdersController do
+
+ before do
+ @pending = orders(:one)
+ @pending.credit_card_exp_month = Date.today.month
+ @pending.credit_card_exp_year = Date.today.year % 1000
+
+ @empty = Order.new
+
+ @paid = orders(:two)
+
+ @shipped = orders(:three)
+ @shipped.credit_card_exp_month = Date.today.month
+ @shipped.credit_card_exp_year = Date.today.year % 1000
+
+ @linda = users(:one)
+ end
+
+ describe 'show' do
+ it "succeeds for an exisiting order" do
+ get order_path(@pending)
+ must_respond_with :success
+ end
+ end
+
+ # def edit
+ #
+ # @order = Order.find_by(id: params[:id])
+ # end
+
+ let (:logged_in_linda) {
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(@linda))
+
+ get auth_callback_path(:github)
+ }
+
+ describe 'edit' do
+
+ it "will allow a guest user to access/edit their own order" do
+ current_order = Order.create
+ # controller.session[:order_id] = new_order.id
+ # session[:order_id] = new_order.id
+ # session.update
+ # binding.pry
+ # Session.new(order_id: 1)
+
+ get order_path(current_order)
+
+ expect(current_order.order_items.empty?).must_equal true
+ must_respond_with :success
+ end
+
+ it "will allow a logged in user to access/edit their own order" do
+ logged_in_linda
+
+ get order_path(session[:order_id])
+ must_respond_with :success
+ end
+ end
+
+ describe 'update' do
+ it 'will redirect to status_path and save valid order info' do
+ skip
+ logged_in_linda
+
+ starting_session = session[:order_id]
+ order = Order.find_by(id: session[:order_id].to_i)
+ order.credit_card_exp_year = (Date.today.year % 1000) + 1
+ order.credit_card_exp_month = Date.today.month
+
+ order_item = order_items(:orderitem3)
+ order_item.order_id = order.id
+ order_item.save
+
+ updated_year = (Date.today.year % 1000) + 7
+
+ order_data = {
+ order: {
+ credit_card_exp_year: updated_year
+ }
+ }
+
+ put order_path(session[:order_id]), params: order_data
+
+ ending_session = session[:order_id]
+
+ updated_order = Order.find_by(id: order.id)
+
+ # expect(starting_session).wont_equal ending_session
+
+ # assert_equal flash[:success], "Thank you for your order. Order confirmation number: #{this_order.id}. Please save this number to view your order status. Disclaimer: This site is for demonstration purposes only."
+
+ must_redirect_to status_path(order.id)
+ #
+ # assert_equal updated_year, order.credit_card_exp_year
+ # assert_equal updated_month, order.credit_card_exp_month
+ end
+
+ it 'will render the page again status for bad request' do
+ skip
+ end
+
+ it 'will change the status of the order to paid' do
+ skip
+ end
+
+ it 'will change the status of all orderitems to paid' do
+ skip
+ end
+
+ it 'will decrement the items according to quantity_per_item ' do
+ skip
+ end
+
+ it 'will clear out session[:order_id]' do
+ skip
+ 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..386065239a
--- /dev/null
+++ b/test/controllers/reviews_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+describe ReviewsController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 0000000000..3dcf0dedb1
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,44 @@
+require 'test_helper'
+
+describe SessionsController do
+ describe 'auth_callback' do
+ it 'logs in an existing user and redirects to root route' do
+ start_count = User.count
+
+ person = users(:june)
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(person))
+
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+ session[:user_id].must_equal person.id
+ User.count.must_equal start_count
+ end
+
+ it "creates an account for a new user and redirects to the root route" do
+ start_count = User.count
+ new_user = User.new(provider: "github", uid: 99999, name: "test_user", nickname: "test_user_nickname", email: "test@user.com")
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(new_user))
+
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+ User.count.must_equal start_count + 1
+ session[:user_id].must_equal User.last.id
+ end
+
+ # it 'invalid user data cannot log in' do
+ # start_count = User.count
+ #
+ # invalid_new_user = User.new(provider: "github", uid: 1, name: "test_user", nickname: "test_user_nickname", email: "test@user.com")
+ #
+ # OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(invalid_new_user))
+ #
+ # get auth_callback_path(:github)
+ #
+ # User.count.must_equal start_count
+ # flash[:error].must_equal "Unable to log in"
+ # end
+ end
+end
diff --git a/test/controllers/status_controller_test.rb b/test/controllers/status_controller_test.rb
new file mode 100644
index 0000000000..5b2f3a9bbe
--- /dev/null
+++ b/test/controllers/status_controller_test.rb
@@ -0,0 +1,27 @@
+require "test_helper"
+
+describe StatusController do
+ before do
+ @item = items(:shoes)
+ @order = orders(:one)
+ @new_order_item = OrderItem.create(order_id: @order.id, item_id: @item.id)
+ end
+
+ it 'will load a form to find an order' do
+ get status_findform_path
+
+ must_respond_with :success
+ end
+
+ it 'responds with success if the order exists' do
+ post detail_path
+
+ must_respond_with :success
+ end
+
+ it 'responds with success if the order exists' do
+ get status_path(@order.id)
+
+ must_respond_with :success
+ end
+end
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
new file mode 100644
index 0000000000..af6768ac0d
--- /dev/null
+++ b/test/controllers/users_controller_test.rb
@@ -0,0 +1,103 @@
+require "test_helper"
+
+describe UsersController do
+ # it "must be a real test" do
+ # flunk "Need real tests"
+ # end
+
+ before do
+ @linda = users(:one)
+ @john = users(:two)
+ @june = users(:june)
+ end
+
+ describe "show" do
+ it "succeeds for an exisiting user / merchant with items" do
+
+ get user_path(@linda)
+ must_respond_with :success
+ end
+
+ it "succeeds for an exisiting user / merchant without items" do
+
+ get user_path(@june)
+ must_respond_with :success
+ end
+
+ it "renders 404 not_found for a non exiting user" do
+
+ get user_path(0)
+ must_respond_with :not_found
+ end
+ end
+
+ let (:logged_in_merchant) {
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(@linda))
+
+ get auth_callback_path(:github)
+ }
+
+ let (:logged_in_user) {
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(@june))
+
+ get auth_callback_path(:github)
+ }
+
+ describe "shop" do
+ it "succeeds for a logged in user / merchant with items" do
+ # skip
+
+ logged_in_merchant
+
+ expect(session[:user_id]).must_equal @linda.id
+
+ get shop_path(@linda)
+ must_respond_with :success
+ end
+
+ it "succeeds for an exisiting user / merchant without items" do
+
+ logged_in_user
+
+ expect(session[:user_id]).must_equal @june.id
+
+ get shop_path(@june)
+ must_respond_with :success
+ end
+
+ it "redirects with flash error message for a non exiting user" do
+
+ get shop_path(0)
+ must_redirect_to root_path
+ assert_equal 'You need to sign up to create a shop.', flash[:error]
+ end
+ end
+
+ describe 'User#merchant pending orders and User#paid' do
+
+ let (:logged_in_user) {
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(@linda))
+
+ get auth_callback_path(:github)
+ }
+
+ it 'succeeds if a merchant has a pending order' do
+ logged_in_user
+
+ get pending_path
+ must_respond_with :success
+ end
+
+ it 'changes the status of an order to shipped'do
+ @item = items(:shoes)
+ @order = orders(:one)
+ @new_order_item = OrderItem.create(order_id: @order.id, item_id: @item.id, quantity_per_item: 3)
+
+ post paid_path(@new_order_item.id)
+ find_shipped_order_item = OrderItem.find_by(status: "shipped")
+
+ expect(find_shipped_order_item.id).must_equal @new_order_item.id
+ must_respond_with :redirect
+ end
+ end
+end
diff --git a/test/fixtures/.keep b/test/fixtures/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml
new file mode 100644
index 0000000000..2164e77cdb
--- /dev/null
+++ b/test/fixtures/categories.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+luggage:
+ category_type: luggage
+
+shoes:
+ category_type: shoes
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/items.yml b/test/fixtures/items.yml
new file mode 100644
index 0000000000..cbe000492f
--- /dev/null
+++ b/test/fixtures/items.yml
@@ -0,0 +1,22 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+suitcase:
+ category: luggage
+ price: 150
+ image: https://i03.hsncdn.com/is/image/HomeShoppingNetwork/prodgrid230/joy-lightweight-nylon-tufftech-luxury-pinstripe-3-piece-d-20180208141055963~590535_2L0.jpg
+ quantity_available: 4
+ name: Maroon Case
+ description: A bunch of suitcases
+ avg_rating: 3
+ user: two
+
+
+shoes:
+ category: shoes
+ price: 40
+ image: https://cdn.shopify.com/s/files/1/0758/2735/products/TB2FjLqdmFmpuFjSZFrXXayOXXa__40028512_1024x1024_88870111-fda4-4eb0-9fef-963934c180e6.jpg?v=1510932598
+ quantity_available: 2
+ name: Bunny Shoes
+ description: Cute bunny shoes
+ avg_rating: 4
+ user: one
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
new file mode 100644
index 0000000000..5f3dc8dcd2
--- /dev/null
+++ b/test/fixtures/order_items.yml
@@ -0,0 +1,24 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+orderitem1:
+ order: one
+ item: shoes
+ quantity_per_item: 1
+ status: pending
+
+orderitem2:
+ order: one
+ item: suitcase
+ quantity_per_item: 1
+ status: pending
+
+orderitem3:
+ order: two
+ item: suitcase
+ quantity_per_item: 2
+ status: pending
+
+orderitem3:
+ order: one
+ item: suitcase
+ quantity_per_item: 3
+ status: pending
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..f0fede9adc
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,37 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+ email: MyString
+ mailing_address: MyString
+ name_on_card: MyString
+ credit_card_num: 1
+ credit_card_exp_month: 0
+ credit_card_exp_year: 0
+ cvv_num: 1
+ zipcode: 1
+ status: pending
+
+two:
+ name: MyString
+ email: MyString
+ mailing_address: MyString
+ name_on_card: MyString
+ credit_card_num: 1
+ credit_card_exp_month: 0
+ credit_card_exp_year: 0
+ cvv_num: 1
+ zipcode: 1
+ status: paid
+
+three:
+ name: MyString
+ email: MyString
+ mailing_address: MyString
+ name_on_card: MyString
+ credit_card_num: 1
+ credit_card_exp_month: 0
+ credit_card_exp_year: 0
+ cvv_num: 1
+ zipcode: 1
+ status: shipped
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..cc113aebf0
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+good:
+ description: It's great
+ rating: 5
+ user: one
+ item: luggage
+
+bad:
+ description: Terrible, just terrible
+ rating: 1
+ user: two
+ item: shoes
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000000..b328aa8f96
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,25 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ uid: 1
+ name: Linda
+ nickname: linda-lucy
+ email: linda-lucy@gmail.com
+ image_url: https://www.gstatic.com/webp/gallery3/2.sm.png
+ provider: github
+
+two:
+ uid: 2
+ name: John
+ nickname: john-johnny
+ email: john-johnny@gmail.com
+ image_url: https://www.gstatic.com/webp/gallery/4.sm.jpg
+ provider: Gmail
+
+june:
+ uid: 3
+ name: june
+ nickname: june-juny
+ email: june-juny@gmail.com
+ image_url: https://www.gstatic.com/webp/gallery3/1.sm.png
+ provider: Gmail
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/models/category_test.rb b/test/models/category_test.rb
new file mode 100644
index 0000000000..781320ad8e
--- /dev/null
+++ b/test/models/category_test.rb
@@ -0,0 +1,9 @@
+require "test_helper"
+
+describe Category do
+ let(:category) { Category.new }
+
+ it "must be valid" do
+ value(category).must_be :valid?
+ end
+end
diff --git a/test/models/item_test.rb b/test/models/item_test.rb
new file mode 100644
index 0000000000..4c3f639039
--- /dev/null
+++ b/test/models/item_test.rb
@@ -0,0 +1,159 @@
+require "test_helper"
+
+describe Item do
+
+
+ #relation tests: an order has many items, a category has many items
+
+ describe 'relations' do
+
+ it 'an item belongs to a category' do
+
+ category = Item.first.category
+
+ expect category.must_be_kind_of Category
+ end
+
+ it 'an item belongs to a user' do
+
+ user = Item.first.user
+ expect user.must_be_kind_of User
+ end
+
+ end
+
+ describe 'validations' do
+
+ before do
+ @user_one = Item.first.user
+ @category_one = Category.first
+ @category_two = Category.first
+
+ # no name
+ @nameless_item = Item.new(
+ name: nil,
+ category: @category_one,
+ price: 40,
+ quantity_available: 2,
+ user: @user_one
+
+ )
+ # no price
+ @priceless_item = Item.new(
+ name: 'no price',
+ category: @category_one,
+ price: nil,
+ quantity_available: 3,
+ user: @user_one
+
+ )
+ # no quantitiy
+ @quantityless_item = Item.new(
+ name: 'no quantitiy',
+ category: @category_one,
+ price: 30,
+ quantity_available: nil,
+ user: @user_one
+ )
+ # same name, same qty, same category (duplicate)
+
+ @thing_one = Item.new(
+ name: 'twin',
+ category: @category_one,
+ price: 30,
+ quantity_available: 2,
+ user: @user_one
+ )
+
+ @thing_two = Item.new(
+ name: 'twin',
+ category: @category_one,
+ price: 30,
+ quantity_available: 2,
+ user: @user_one
+ )
+
+ # same everything diff category is valid
+
+ @same_name_diff_cat = Item.new(
+ name: 'cat',
+ category: Category.first,
+ price: 30,
+ quantity_available: 3,
+ user: @user_one
+ )
+
+ @diff_cat = Item.new(
+ name: 'cat',
+ category: Category.first,
+ price: 30,
+ quantity_available: 3,
+ user: @user_one
+ )
+ end
+
+ it 'is valid when title, category, and price is present' do
+ @valid_item = Item.first
+ is_valid = @valid_item.valid?
+ expect( is_valid ).must_equal true
+
+ end
+
+ it 'is not valid without a name' do
+ is_valid = @nameless_item.valid?
+ expect( is_valid ).must_equal false
+
+ end
+
+ it 'is not valid without a price' do
+ is_valid = @priceless_item.valid?
+ expect( is_valid ).must_equal false
+ end
+
+ it 'is not valid without a quantitiy' do
+ is_valid = @quantityless_item.valid?
+ expect( is_valid ).must_equal false
+ end
+
+ # it 'is not valid with same name, quantity, and price' do
+ # is_valid = @thing_two.valid?
+ # expect( is_valid ).must_equal false
+ # end
+
+ it 'is valid with same name, diff category' do
+ is_valid = @same_name_diff_cat.valid?
+ expect ( is_valid ).must_equal true
+
+ end
+ end
+
+ describe 'decrement_quantity_available(num)' do
+
+ it 'will decrement quantity in instance of item by num' do
+ valid_item = Item.first
+
+ starting_quant = valid_item.quantity_available
+ num = 1
+
+ valid_item.decrement_quantity_available(num)
+ ending_quant = valid_item.quantity_available
+
+ expect(ending_quant).must_equal starting_quant - num
+ end
+
+ it 'will not decrement quantity in instance of item if num is nil' do
+
+ valid_item = Item.first
+
+ starting_quant = valid_item.quantity_available
+ num = nil
+
+ valid_item.decrement_quantity_available(num)
+ ending_quant = valid_item.quantity_available
+
+ expect(ending_quant).must_equal starting_quant
+ end
+
+
+ end
+end
diff --git a/test/models/order_item_test.rb b/test/models/order_item_test.rb
new file mode 100644
index 0000000000..574d8dcc50
--- /dev/null
+++ b/test/models/order_item_test.rb
@@ -0,0 +1,148 @@
+require "test_helper"
+
+describe OrderItem do
+
+ before do
+ @orderitem1 = order_items(:orderitem1)
+ @orderitem2 = order_items(:orderitem2)
+ @orderitem3 = order_items(:orderitem3)
+ end
+
+ let(:order_item_missing_item) {
+ OrderItem.create(item: nil,
+ order: Order.first)
+ }
+
+ let(:order_item_missing_order) {
+ OrderItem.create( item: Item.first,
+ order: nil)
+ }
+
+ let(:submit_full_order_item) {
+ @orderitem2.submit_order_item
+ item = @orderitem2.item
+ item.decrement_quantity_available(@orderitem2.quantity_per_item)
+ @orderitem2
+ }
+
+ describe 'relations' do
+ it "has an item" do
+ expect(@orderitem1).must_respond_to :item
+ expect(@orderitem1.item).must_be_kind_of Item
+ end
+
+ it "has an order" do
+ expect(@orderitem1).must_respond_to :order
+ expect(@orderitem1.order).must_be_kind_of Order
+ end
+ end
+
+ describe 'validations' do
+
+ it "will create a valid orderitem" do
+ value(@orderitem1).must_be :valid?
+ end
+
+ it 'wont create a valid order_item if the item is missing' do
+
+ starting_count = OrderItem.count
+ invalid_order_item = order_item_missing_item
+ ending_count = OrderItem.count
+
+ expect(ending_count).must_equal starting_count
+ expect(invalid_order_item.valid?).must_equal false
+ expect(invalid_order_item.errors.messages).must_include :item, :item_id
+ end
+
+ it 'wont create a valid order_item if the order is missing' do
+
+ starting_count = OrderItem.count
+ invalid_order_item = order_item_missing_order
+ ending_count = OrderItem.count
+
+ expect(ending_count).must_equal starting_count
+
+ expect(invalid_order_item.valid?).must_equal false
+ expect(invalid_order_item.errors.messages).must_include :order, :order_id
+ end
+ end
+
+ describe 'submit_order_item' do
+
+ it 'will change the status to paid if order_item is not nil' do
+
+ starting_item_quantity = @orderitem2.item.quantity_available
+ quant_to_be_subtracted = @orderitem2.quantity_per_item
+ expected_final_quant = starting_item_quantity - quant_to_be_subtracted
+ starting_status = @orderitem2.status
+
+ submitted_order = submit_full_order_item
+
+ ending_status = submitted_order.status
+ ending_quant = submitted_order.item.quantity_available
+
+ expect(ending_quant).must_equal expected_final_quant
+ expect(starting_status).must_equal "pending"
+ expect(ending_status).must_equal "paid"
+ end
+
+ it 'will not change status if order_items have no items' do
+
+ empty_order = order_item_missing_item
+ start_stat = empty_order.status
+
+ empty_order.submit_order_item
+
+ end_stat = empty_order.status
+
+ expect(end_stat).must_equal end_stat
+ end
+
+
+ it 'returns the name of an item given the OrderItem id' do
+ category = categories(:luggage)
+ user = users(:june)
+ new_order = Order.create()
+
+ new_item = Item.create(name: "PotatoHead", price: 15, quantity_available: 15, category_id: category.id, user_id: user.id)
+
+ new_orderitem = OrderItem.create(order_id: new_order.id, item_id: new_item.id, quantity_per_item: 1)
+
+ new_orderitem_item_id = new_orderitem.item_id
+
+ item_name = new_orderitem.find_item_name(new_orderitem_item_id)
+
+ expect(item_name).must_equal "PotatoHead"
+
+ end
+ end
+
+ describe 'find_item_name' do
+
+ it 'returns the name of an item given an item id' do
+
+ @item = items(:shoes)
+ @order = orders(:one)
+ @new_order_item = OrderItem.create(order_id: @order.id, item_id: @item.id)
+
+
+ item_name = @item.name
+ find_item_name = @new_order_item.find_item_name(@new_order_item.item_id)
+
+ expect(find_item_name).must_equal item_name
+ end
+
+ it 'returns the order instance linked to an order_item' do
+
+ @item = items(:shoes)
+ @order = orders(:one)
+ @new_order_item = OrderItem.create(order_id: @order.id, item_id: @item.id, quantity_per_item: 4)
+
+ find_order = Order.find_by(id: @new_order_item.order_id)
+
+ expect(find_order).must_equal @order
+
+ end
+ end
+ # end
+ end
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..735bb464af
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,101 @@
+require "test_helper"
+
+describe Order do
+ before do
+ @pending = orders(:one)
+ @pending.credit_card_exp_month = Date.today.month
+ @pending.credit_card_exp_year = Date.today.year % 1000
+
+ @empty = Order.new
+ end
+
+ describe 'relations' do
+ it "has a list of order_items" do
+ expect(@pending).must_respond_to :order_items
+ @pending.order_items.each do |order_item|
+ expect(order_item).must_be_kind_of OrderItem
+ end
+ end
+ end
+
+ describe 'validations' do
+ it "will be a valid pending order even if credit card info is missing" do
+
+ expect(@empty.status).must_equal "pending"
+ expect(@empty.valid?).must_equal true
+ end
+
+ it 'will not save a valid order when updating without valid month' do
+
+ @pending.update(credit_card_exp_month: 0)
+ expect(@pending.valid?).must_equal false
+ end
+
+ it 'will not save a valid order when updating without valid years' do
+
+ @pending.update(credit_card_exp_year: 0)
+ expect(@pending.valid?).must_equal false
+ end
+
+ it 'will create a valid order with any order_items' do
+
+ expect(@empty.order_items.length).must_equal 0
+ expect(@empty.valid?).must_equal true
+ end
+
+ it 'will not update an order with any order_items' do
+ expect(@empty.order_items.length).must_equal 0
+
+ @empty.update(status: "paid")
+ expect(@empty.valid?).must_equal false
+ end
+
+ it 'will update an order with one or more order_items' do
+ expect(@pending.order_items.length).must_be :>=, 1
+ @pending.update(status: "paid")
+ expect(@pending.valid?).must_equal true
+ end
+ end
+
+ describe 'submit_order' do
+ it 'will change order and order items to pending' do
+ expect(@pending.order_items.length).must_be :>=, 1
+ expect(@pending.status).must_equal "pending"
+
+ item_ids = @pending.order_items.map { |item| item.item_id }
+ statuses = @pending.order_items.map {|item| item.status}.uniq
+ expect(statuses.length).must_equal 1
+ expect(statuses[0]).must_equal "pending"
+
+ @pending.submit_order
+
+ expect(@pending.status).must_equal "paid"
+ new_statuses = @pending.order_items.map {|item| item.status}.uniq
+ expect(new_statuses.length).must_equal 1
+ expect(new_statuses[0]).must_equal "paid"
+
+ end
+ end
+
+ describe 'self.valid_years' do
+ it 'will an array of length 8 with years' do
+ valid_years = Order.valid_years
+ expect(valid_years.length).must_equal 9
+ end
+ it 'will include today\'s date until 8 years from today' do
+ valid_years = Order.valid_years
+ first = Date.today.year % 1000
+ last = first + 8
+ range = (first..last).to_a
+
+ expect(valid_years).must_equal range
+ end
+ end
+
+ describe 'self.valid_years' do
+ it 'will an array of length 8 with years' do
+ valid_years = Order.valid_years
+ expect(valid_years.length).must_equal 9
+ end
+ end
+end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..e5a3ff8385
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,18 @@
+require "test_helper"
+
+
+# describe Review do
+# let(:review) { Review.new }
+#
+# it "must be valid" do
+# value(review).must_be :valid?
+# end
+# end
+
+describe Review do
+ # let(:review) { Review.new }
+ #
+ # it "must be valid" do
+ # value(review).must_be :valid?
+ # end
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 0000000000..e44b517f0c
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,139 @@
+require "test_helper"
+
+describe User do
+
+ before do
+ @linda = users(:one)
+ @john = users(:two)
+ @june = users(:june)
+ end
+
+ describe 'relations' do
+ it "has a list of items" do
+ expect(@linda).must_respond_to :items
+ @linda.items.each do |item|
+ expect(item).must_be_kind_of Item
+ end
+ end
+
+ it "has a list of reviews" do
+ expect(@linda).must_respond_to :reviews
+ #NEED TO GIVE A YAML REVIEW
+ @linda.must_respond_to :reviews
+ @linda.reviews.each do |review|
+ expect(review).must_be_kind_of Review
+ end
+ end
+ end
+
+ let(:dup_user_name_and_provider) {
+ dup_user = User.create(nickname: "#{@linda.nickname}", provider: "#{@linda.provider}", email: "lisa@yahoo.com", uid: "000" )
+ dup_user
+ }
+
+ let(:dup_user_name_only) {
+ dup_user = User.create(nickname: "Liam", email: "liam@yahoo.com", uid: "001", provider: "whatever")
+ dup_user.nickname = @john.nickname
+ dup_user.provider = "not a dup provider"
+ dup_user
+ }
+
+ let(:dup_user_provider_only) {
+ dup_user = User.create(nickname: "Liam", email: "liam@yahoo.com", uid: "001", provider: "whatever")
+ dup_user.email = "not a dup email"
+ dup_user.provider = @john.provider
+ dup_user
+ }
+
+ let(:dup_user_email_only) {
+ dup_user = User.create(nickname: "bad email", email: "#{@john.email}", uid: "002", provider: "whatever1")
+ dup_user
+ }
+
+ describe 'validations' do
+ it 'will create a valid user' do
+ expect(@linda.valid?).must_equal true
+ end
+
+ it 'wont create user with duplicate email' do
+
+ starting_count = User.count
+
+ dup_user = dup_user_email_only
+
+ ending_count = User.count
+
+ expect(ending_count).must_equal starting_count
+
+ expect(@john.valid?).must_equal true
+ expect(dup_user.valid?).must_equal false
+ expect(dup_user.errors.messages).must_include :email
+ end
+
+ it 'will not create a user who has a duplicate username for the same provider as existing user' do
+
+ starting_count = User.count
+
+ dup_user = dup_user_name_and_provider
+
+ ending_count = User.count
+
+ expect(ending_count).must_equal starting_count
+
+ expect(@linda.valid?).must_equal true
+ expect(dup_user.valid?).must_equal false
+ expect(dup_user.errors.messages).must_include :nickname
+ end
+
+ it 'will create a user who has a duplicate username but a different provider than existing user' do
+
+ starting_count = User.count
+
+ dup_user = dup_user_provider_only
+
+ ending_count = User.count
+
+ expect(ending_count).must_equal starting_count + 1
+
+ expect(@john.valid?).must_equal true
+ expect(dup_user.valid?).must_equal true
+ end
+
+ it 'will create a user who has a duplicate provider but a different email than existing user' do
+
+ starting_count = User.count
+
+ dup_user = dup_user_provider_only
+
+ ending_count = User.count
+
+ expect(ending_count).must_equal starting_count + 1
+
+ expect(@john.valid?).must_equal true
+ expect(dup_user.valid?).must_equal true
+ end
+ end
+
+ let(:item_ids){
+ items = Item.all
+ item_ids = items.map { |item| item.user_id }
+ }
+
+ describe 'is_a_merchant?(given_ids)' do
+
+ it 'will return true if user has more than one or more items / is a merchant' do
+
+ #greater than or equal to 1
+ expect(@linda.items.length).must_be :>=, 1
+ expect(@linda.is_a_merchant?(item_ids)).must_equal true
+ end
+
+ it 'will return false if user has less than one item' do
+
+ #less than 1
+ expect(@june.items.length).must_be :<=, 1
+ expect(@june.is_a_merchant?(item_ids)).must_equal false
+ 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..c04801df70
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,49 @@
+require 'simplecov'
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters" # for Colorized output
+# For colorful output!
+Minitest::Reporters.use!(
+ Minitest::Reporters::SpecReporter.new,
+ ENV,
+ Minitest.backtrace_filter
+)
+
+
+SimpleCov.start 'rails' do
+ add_filter '/bin/'
+ add_filter '/db/'
+ add_filter '/test/' # for minitest
+end
+
+# To add Capybara feature tests add `gem "minitest-rails-capybara"`
+# to the test group in the Gemfile and uncomment the following:
+# require "minitest/rails/capybara"
+
+# Uncomment for awesome colorful output
+# require "minitest/pride"
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+ # Add more helper methods to be used by all tests here...
+
+ def setup
+ OmniAuth.config.test_mode = true
+ end
+
+ def mock_auth_hash(user)
+ return{
+ uid: user.uid,
+ provider: user.provider,
+ info: {
+ name: user.name,
+ nickname: user.nickname,
+ email: user.email,
+ image_url: user.image_url
+ }
+ }
+ 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