Complete Order Items    Count: <%= "#{@merchant.complete_order_items.length}" %>     Total Revenue for Completed Order Items: $<%= "#{@merchant.completed_orders_subtotal}" %>
+
+
+
+
Order ID
+
Product ID
+
Description
+
Quantity
+
Subtotal
+
Ordered On
+
Status
+
+
+
+ <% @merchant.complete_order_items.each do |item| %>
+
diff --git a/app/views/merchants/_header.html.erb b/app/views/merchants/_header.html.erb
new file mode 100644
index 0000000000..fec0afa64a
--- /dev/null
+++ b/app/views/merchants/_header.html.erb
@@ -0,0 +1,4 @@
+
+
<%=@merchant.username%>
+
<%=@merchant.created_at.strftime("Joined Petsy in %B %Y")%>
+
diff --git a/app/views/merchants/_orders.html.erb b/app/views/merchants/_orders.html.erb
new file mode 100644
index 0000000000..88dcb96eca
--- /dev/null
+++ b/app/views/merchants/_orders.html.erb
@@ -0,0 +1,29 @@
+
+
All Order Items    Count: <%= "#{@merchant.order_items.size}" %>     Total Revenue for All Order Items: $<%= "#{@merchant.all_order_items_subtotal}" %>
+
+
+
+
Order ID
+
Product ID
+
Description
+
Quantity
+
Subtotal
+
Ordered On
+
Status
+
+
+
+ <% @merchant.order_items.each do |item| %>
+
diff --git a/app/views/merchants/_paid_orders.html.erb b/app/views/merchants/_paid_orders.html.erb
new file mode 100644
index 0000000000..d8b696e180
--- /dev/null
+++ b/app/views/merchants/_paid_orders.html.erb
@@ -0,0 +1,31 @@
+
+
Paid Order Items   Count: <%= "#{@merchant.paid_order_items.length}" %>    Total Revenue for Paid Order Items: $<%= "#{@merchant.paid_orders_subtotal}" %>
+
+
+
+
Order ID
+
Product ID
+
Description
+
Quantity
+
Subtotal
+
Ordered On
+
Status
+
+
+
+
+ <% @merchant.paid_order_items.each do |item| %>
+
+ All of our domestic adoptions are sourced from animal shelters and rescue centers from around the country. Please browse and help us provide these animals with the loving forever homes they deserve!
+
+
+
+<% end %>
+<%= link_to products_path do %>
+
+
+
+ Your contribution to our "exotic" adoptions allow us to support conservation and habitat preservation for many animals in the wild, and support sanctuaries for those animals who are unable to return to the wild.
+
+
+
+<% end %>
+<%= link_to products_path do %>
+
+
+
+ Need a new collar? Booties for your pup? We've got it all, from sweaters to swimwear! And a portion of your purchase goes to support the American Humane Society.
+
+
+
+<% end %>
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
new file mode 100644
index 0000000000..256f1ff2a8
--- /dev/null
+++ b/app/views/products/show.html.erb
@@ -0,0 +1,74 @@
+
+ <% end %>
+
+
+<%= link_to "Add Review", new_product_review_path, class: "btn btn-primary" %>
+
+
diff --git a/app/views/reviews/new.html.erb b/app/views/reviews/new.html.erb
new file mode 100644
index 0000000000..92aaec50aa
--- /dev/null
+++ b/app/views/reviews/new.html.erb
@@ -0,0 +1,17 @@
+
+ <%= form_with model: [@product, @review] do |f| %>
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+ <%= f.label :rating %>
+ <%= f.select :rating, Review::RATINGS %>
+
+ <%= f.label :description %>
+ <%= f.text_area :description %>
+
+ <%= f.hidden_field :product_id, value: @product.id %>
+
+ <%= f.submit class: "btn btn-primary" %>
+
+ <% 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..6b169e821b
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+/MzRPeazUWZZIFKyxQGagt5ecLbxDZpO19R7uanF8E5sHrUE/6ypZKnH/ZDleWcewYZ65pIg/cc8ADMys5Drt8Ea59PDo9r9QLOzj4L4nwByhMVHyyLcezx6SGJ+CdDbq2JB0bt+kUa1De/niqg5dF4hOVqRubMCLPGuif1Z13/qSNZC9hC8lAtHifUNB1ugQY0v0HkH9O79NFVrfAh8mv05J4xa6sQlNjjCiREpTlAX6QPVF7QGZpRvPqjtDOoIujPgeuZ1aXTEpzEHOWNo9PZiZbVKGLY0aoYNN8G6kWii7kRzGOpu/RhcYCsm+XbEoarvvZVUguTtTiPg8FfOurTNODxiJ+qWPhrMiVANED9irE4c2wOZQkkT7OUWFaEF7dRItChlF5BGCTYDigN7GJIyeTMwTEL/0lvr--eZLILJm0c6kkzYLF--8Rc6/Fzq3tv12+01/IGNlw==
\ 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..dcf129464e
--- /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 = true
+
+ # `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..9ebe3f90f9
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,26 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ root 'products#root'
+
+ resources :merchants, except: [:new, :create]
+ resources :products do
+ resources :reviews, only: [:new, :create]
+ end
+
+ resources :order_items, except: [:new]
+ resources :orders, except: [:new]
+
+ resources :sessions, only: [:new, :create]
+
+ resources :categories, only: [:new, :create]
+
+ get '/auth/:provider/callback', to: "sessions#create", as: 'auth_callback'
+ delete '/logout', to: 'sessions#destroy', as: 'logout'
+
+ get '/merchants/:id/dashboard', to: 'merchants#dashboard', as: 'dashboard'
+
+ post '/order_items/:id/status', to: 'order_items#status', as: 'order_items_status'
+
+ get '/orders/:id/customerinfo', to: 'orders#customerinfo', as: 'customer_info'
+
+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/category_seeds.csv b/db/category_seeds.csv
new file mode 100644
index 0000000000..a41458ed36
--- /dev/null
+++ b/db/category_seeds.csv
@@ -0,0 +1,13 @@
+name
+Sussex Spaniel
+Keeshond
+Bull Mastiff
+English Hound
+Coonhound
+Clumber
+English Setter
+Chesapeake Retriever
+Curly Retriever
+Stbernard
+Kuvasz
+Pomeranian
diff --git a/db/generate_seeds.rb b/db/generate_seeds.rb
new file mode 100644
index 0000000000..9329ed2dbb
--- /dev/null
+++ b/db/generate_seeds.rb
@@ -0,0 +1,74 @@
+require 'faker'
+require 'date'
+require 'csv'
+
+# Merchant seed script
+CSV.open('db/merchant_seeds.csv', "w", :write_headers=> true,
+ :headers => ["username", "email", "uid", "provider"]) do |csv|
+
+ 5.times do
+ username = Faker::HarryPotter.character
+ email = Faker::Internet.email
+ uid = Faker::Number.number(3)
+ provider = "github"
+
+ csv << [username, email, uid, provider]
+ end
+end
+
+# Product seed script
+CSV.open('db/product_seeds.csv', "w", :write_headers=> true,
+ :headers => ["name", "price", "photo", "stock", "active", "description"]) do |csv|
+
+ 50.times do
+ name = Faker::Cat.name
+ price = Faker::Commerce.price
+ photo = 'http://placekitten.com/200/300'
+ stock = Faker::Number.number(2)
+ active = Faker::Boolean.boolean(0.8)
+ description = Faker::Lorem.sentence
+
+ csv << [name, price, photo, stock, active, description]
+ end
+end
+
+# Order item seed script
+CSV.open('db/order_item_seeds.csv', "w", :write_headers=> true,
+ :headers => ["quantity", "status"]) do |csv|
+
+ 50.times do
+ quantity = Faker::Number.number(2)
+ status = %w(pending paid complete cancelled).sample
+
+ csv << [quantity, status]
+ end
+end
+
+# Order seed screipt
+CSV.open('db/order_seeds.csv', "w", :write_headers=> true,
+ :headers => ["status", "name", "email", "address", "cc_num", "cc_cvv", "cc_expiration"]) do |csv|
+
+ 20.times do
+ status = %w(paid complete cancelled).sample
+ name = Faker::RickAndMorty.character
+ email = Faker::Internet.email
+ address = Faker::Address.full_address
+ cc_num = Faker::Number.number(16)
+ cc_cvv = Faker::Number.number(3)
+ cc_expiration = Faker::Date.backward(21)
+
+
+ csv << [status, name, email, address, cc_num, cc_cvv, cc_expiration]
+ end
+end
+
+# Category seed script
+CSV.open('db/category_seeds.csv', "w", :write_headers=> true,
+ :headers => ["name"]) do |csv|
+
+ 12.times do
+ name = Faker::Dog.breed
+
+ csv << [name]
+ end
+end
diff --git a/db/merchant_seeds.csv b/db/merchant_seeds.csv
new file mode 100644
index 0000000000..49e4c63695
--- /dev/null
+++ b/db/merchant_seeds.csv
@@ -0,0 +1,6 @@
+username,email,uid,provider
+Magorian,glenn@dare.name,820,github
+Tom Marvolo Riddle,macknader@steuber.net,364,github
+Mr. Roberts,ezequiel@ernser.co,232,github
+Rolf Scamander,antoniocorkery@shanahanernser.io,353,github
+Winky,dirk@murphy.name,145,github
diff --git a/db/migrate/20181017222943_create_merchants.rb b/db/migrate/20181017222943_create_merchants.rb
new file mode 100644
index 0000000000..846cedd125
--- /dev/null
+++ b/db/migrate/20181017222943_create_merchants.rb
@@ -0,0 +1,11 @@
+class CreateMerchants < ActiveRecord::Migration[5.2]
+ def change
+ create_table :merchants do |t|
+ t.string :username
+ t.string :email
+ t.integer :uid
+ t.string :provider
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017222948_create_products.rb b/db/migrate/20181017222948_create_products.rb
new file mode 100644
index 0000000000..f5ece18922
--- /dev/null
+++ b/db/migrate/20181017222948_create_products.rb
@@ -0,0 +1,15 @@
+class CreateProducts < ActiveRecord::Migration[5.2]
+ def change
+ create_table :products do |t|
+ t.string :name
+ t.decimal :price
+ t.string :photo
+ t.integer :stock
+ t.boolean :active
+ t.string :category
+ t.decimal :rating
+ t.belongs_to :merchant, index: true
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017222952_create_orders.rb b/db/migrate/20181017222952_create_orders.rb
new file mode 100644
index 0000000000..5396ce84dd
--- /dev/null
+++ b/db/migrate/20181017222952_create_orders.rb
@@ -0,0 +1,14 @@
+class CreateOrders < ActiveRecord::Migration[5.2]
+ def change
+ create_table :orders do |t|
+ t.string :status
+ t.string :name
+ t.string :email
+ t.string :address
+ t.integer :cc_num
+ t.integer :cc_cvv
+ t.date :cc_expiration
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017222957_create_order_items.rb b/db/migrate/20181017222957_create_order_items.rb
new file mode 100644
index 0000000000..55800924ca
--- /dev/null
+++ b/db/migrate/20181017222957_create_order_items.rb
@@ -0,0 +1,11 @@
+class CreateOrderItems < ActiveRecord::Migration[5.2]
+ def change
+ create_table :order_items do |t|
+ t.integer :quantity
+ t.string :status
+ t.belongs_to :product, index: true
+ t.belongs_to :order, index: true
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181017223000_create_reviews.rb b/db/migrate/20181017223000_create_reviews.rb
new file mode 100644
index 0000000000..b3151c6ac6
--- /dev/null
+++ b/db/migrate/20181017223000_create_reviews.rb
@@ -0,0 +1,11 @@
+class CreateReviews < ActiveRecord::Migration[5.2]
+ def change
+ create_table :reviews do |t|
+ t.string :name
+ t.integer :rating
+ t.string :description
+ t.belongs_to :product, index: true
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181018180824_reformat_order_cc_num.rb b/db/migrate/20181018180824_reformat_order_cc_num.rb
new file mode 100644
index 0000000000..fc0dc77270
--- /dev/null
+++ b/db/migrate/20181018180824_reformat_order_cc_num.rb
@@ -0,0 +1,5 @@
+class ReformatOrderCcNum < ActiveRecord::Migration[5.2]
+ def change
+ change_column :orders, :cc_num, :bigint
+ end
+end
diff --git a/db/migrate/20181021171911_add_description_column_to_products.rb b/db/migrate/20181021171911_add_description_column_to_products.rb
new file mode 100644
index 0000000000..11ec697c03
--- /dev/null
+++ b/db/migrate/20181021171911_add_description_column_to_products.rb
@@ -0,0 +1,5 @@
+class AddDescriptionColumnToProducts < ActiveRecord::Migration[5.2]
+ def change
+ add_column :products, :description, :string
+ end
+end
diff --git a/db/migrate/20181024173739_remove_rating_products.rb b/db/migrate/20181024173739_remove_rating_products.rb
new file mode 100644
index 0000000000..d545688c56
--- /dev/null
+++ b/db/migrate/20181024173739_remove_rating_products.rb
@@ -0,0 +1,5 @@
+class RemoveRatingProducts < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :products, :rating
+ end
+end
diff --git a/db/migrate/20181024224302_create_categories.rb b/db/migrate/20181024224302_create_categories.rb
new file mode 100644
index 0000000000..6ccc3914a0
--- /dev/null
+++ b/db/migrate/20181024224302_create_categories.rb
@@ -0,0 +1,9 @@
+class CreateCategories < ActiveRecord::Migration[5.2]
+ def change
+ create_table :categories do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181024224430_create_categories_products_join.rb b/db/migrate/20181024224430_create_categories_products_join.rb
new file mode 100644
index 0000000000..7bcfaadab5
--- /dev/null
+++ b/db/migrate/20181024224430_create_categories_products_join.rb
@@ -0,0 +1,8 @@
+class CreateCategoriesProductsJoin < ActiveRecord::Migration[5.2]
+ def change
+ create_table :categories_products do |t|
+ t.belongs_to :category, index: true
+ t.belongs_to :product, index: true
+ end
+ end
+end
diff --git a/db/migrate/20181024224809_remove_category_from_products.rb b/db/migrate/20181024224809_remove_category_from_products.rb
new file mode 100644
index 0000000000..4a5939d3d9
--- /dev/null
+++ b/db/migrate/20181024224809_remove_category_from_products.rb
@@ -0,0 +1,5 @@
+class RemoveCategoryFromProducts < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :products, :category
+ end
+end
diff --git a/db/order_item_seeds.csv b/db/order_item_seeds.csv
new file mode 100644
index 0000000000..e41351f041
--- /dev/null
+++ b/db/order_item_seeds.csv
@@ -0,0 +1,51 @@
+quantity,status
+85,paid
+80,pending
+28,paid
+10,cancelled
+75,complete
+14,complete
+95,pending
+18,paid
+35,paid
+62,pending
+33,cancelled
+87,cancelled
+50,complete
+78,complete
+46,paid
+65,complete
+90,paid
+21,paid
+97,complete
+19,pending
+59,cancelled
+59,paid
+25,paid
+91,pending
+76,cancelled
+65,complete
+34,complete
+49,paid
+49,cancelled
+79,cancelled
+74,cancelled
+83,paid
+81,complete
+43,complete
+49,paid
+18,pending
+21,paid
+35,paid
+80,paid
+85,complete
+16,paid
+32,pending
+38,paid
+66,paid
+46,pending
+82,cancelled
+40,pending
+26,cancelled
+19,cancelled
+74,complete
diff --git a/db/order_seeds.csv b/db/order_seeds.csv
new file mode 100644
index 0000000000..6008f2fcd1
--- /dev/null
+++ b/db/order_seeds.csv
@@ -0,0 +1,21 @@
+status,name,email,address,cc_num,cc_cvv,cc_expiration
+complete,Unity,joanesatterfield@abernathy.net,"Suite 409 845 Mills Green, Lake Genaroshire, MS 44970",4486883872396845,555,2018-10-23
+paid,Beth's Mytholog,berryfeil@dibbertlang.co,"Apt. 365 7230 Natosha Freeway, Farrellshire, ID 50567-5016",2176389478716835,154,2018-10-04
+cancelled,Unity,catarinaschroeder@steubermitchell.name,"Suite 769 7678 Von Tunnel, Port Reginald, OH 72355",9407052645553807,906,2018-10-13
+complete,Abradolf Lincler,lanellturcotte@haag.biz,"Apt. 890 26637 Rosalina Hill, Paucekhaven, MN 50199-3481",8083496813074413,712,2018-10-04
+paid,Snowball,nigelstokes@bergeheathcote.biz,"Apt. 279 91179 Petrina Plaza, Johnsonmouth, FL 37419-0453",1425929142216586,775,2018-10-04
+complete,Cousin Nicky,irinahoeger@kuhlmansawayn.co,"590 Alva Union, Kozeyfurt, ID 02820-7540",8616399893664530,651,2018-10-21
+complete,"Revolio 'Gearhead' Clockberg, Jr.",marckilback@nolan.name,"4009 Little Motorway, East Denis, MI 46736",6341894708669961,706,2018-10-22
+paid,Jessica,fideliaryan@pfannerstill.biz,"Suite 128 2597 Miquel Street, Lake Danita, NJ 46521",8584190810966913,957,2018-10-16
+cancelled,Fart,donnelltromp@westzulauf.name,"Suite 997 4165 Katina Rapid, Brendanmouth, ND 47070",3966391398253288,335,2018-10-14
+paid,Mr. Poopybutthole,demetrice@johns.com,"749 Pedro Freeway, Honeymouth, WY 93386-2460",8813010477919242,565,2018-10-18
+cancelled,Krombopulos Michael,cleolehner@joneswatsica.biz,"53369 Santiago Divide, Damionfurt, WY 25181-3050",2169398197736081,191,2018-10-06
+paid,Arthricia,melanienikolaus@prohaska.info,"Suite 519 90840 Stacey Lock, East Maynard, MS 63672",6070400071834991,125,2018-10-24
+cancelled,"Revolio 'Gearhead' Clockberg, Jr.",carrielemke@reichel.name,"43426 Luke Rue, Abrahamhaven, CA 14404-4088",1846236753265187,767,2018-10-15
+complete,Beth Smith,alvinjohnston@oreilly.net,"Apt. 934 8303 Adams Mall, South Felicia, WA 45786",5322792478635279,659,2018-10-11
+cancelled,Jerry's Mytholog,averyrice@berge.co,"Suite 657 85544 Noe Ports, South Precious, HI 72983-4991",2664550272640410,366,2018-10-16
+complete,Krombopulos Michael,jasminrau@macejkovicpaucek.name,"Apt. 234 21632 Schroeder Garden, New Tobiasville, IA 02526",1483700269514539,222,2018-10-24
+cancelled,King Jellybean,tisa@towne.org,"Apt. 272 2038 Conroy Radial, Dedraview, NH 55849",5964637614914130,722,2018-10-04
+complete,Scary Terry,mitch@blickstamm.io,"Apt. 234 4164 Emmerich Via, Port Isaias, IL 77152",8101522667209264,920,2018-10-19
+paid,Baby Legs,bunny@blanda.org,"Apt. 524 322 Argentina Road, Greenholtmouth, HI 55167-6284",5058172511519348,332,2018-10-07
+paid,Arthricia,markusmante@towne.co,"749 Osinski Bridge, Klingburgh, MO 35098",5446813160763276,406,2018-10-04
diff --git a/db/product_seeds.csv b/db/product_seeds.csv
new file mode 100644
index 0000000000..cca0e2654b
--- /dev/null
+++ b/db/product_seeds.csv
@@ -0,0 +1,51 @@
+name,price,photo,stock,active,description
+Millie,29.37,http://placekitten.com/200/300,37,false,Eius praesentium aperiam placeat.
+Lily,1.76,http://placekitten.com/200/300,94,true,Sed aut et magni.
+Misty,72.65,http://placekitten.com/200/300,48,true,Excepturi quia quaerat placeat.
+Bella,88.16,http://placekitten.com/200/300,60,true,Et et a id.
+Lily,25.69,http://placekitten.com/200/300,50,true,Autem qui provident vel.
+Max,3.1,http://placekitten.com/200/300,26,true,Ad saepe earum at.
+Millie,29.65,http://placekitten.com/200/300,10,true,Quidem sequi quis nihil.
+Daisy,49.14,http://placekitten.com/200/300,35,true,Voluptatem laboriosam dolore placeat.
+Shadow,99.86,http://placekitten.com/200/300,22,true,Blanditiis dolorem vel omnis.
+Smudge,29.28,http://placekitten.com/200/300,84,true,Et mollitia quam quia.
+Max,89.38,http://placekitten.com/200/300,27,true,Nihil non repellendus error.
+Lily,29.96,http://placekitten.com/200/300,76,false,Distinctio et quaerat quod.
+Tiger,49.06,http://placekitten.com/200/300,14,true,Quam quaerat tempora eveniet.
+Lucy,37.0,http://placekitten.com/200/300,20,false,Odit alias dolores perferendis.
+Milo,10.86,http://placekitten.com/200/300,90,false,Amet quia et corrupti.
+Simba,46.65,http://placekitten.com/200/300,43,true,Ab corrupti aut inventore.
+Sam,54.46,http://placekitten.com/200/300,47,false,Rerum quia qui vitae.
+Max,68.73,http://placekitten.com/200/300,14,true,Asperiores eum ea cum.
+Sooty,80.0,http://placekitten.com/200/300,86,true,At ut est iste.
+Bella,76.75,http://placekitten.com/200/300,36,true,Dolorem et enim sint.
+Lucky,40.63,http://placekitten.com/200/300,15,false,Ut aut omnis quidem.
+Felix,68.86,http://placekitten.com/200/300,38,false,Qui quas quis illum.
+Felix,57.72,http://placekitten.com/200/300,76,false,Aut vel minus ipsum.
+Simba,51.79,http://placekitten.com/200/300,12,true,Nihil blanditiis asperiores perspiciatis.
+Charlie,59.53,http://placekitten.com/200/300,35,true,Reiciendis fugit eum et.
+Tiger,32.61,http://placekitten.com/200/300,18,false,Aut repudiandae quidem molestiae.
+Chloe,44.84,http://placekitten.com/200/300,63,true,Eaque error saepe voluptatem.
+Max,84.36,http://placekitten.com/200/300,24,true,Quaerat ut quo voluptatem.
+Angel,0.73,http://placekitten.com/200/300,70,true,Explicabo neque quidem autem.
+Misty,23.02,http://placekitten.com/200/300,48,true,Sapiente ut non eos.
+Jasper,33.39,http://placekitten.com/200/300,28,true,Consectetur quos porro fugit.
+Coco,35.39,http://placekitten.com/200/300,62,true,Hic odit cum soluta.
+Molly,53.18,http://placekitten.com/200/300,54,true,Quae et et autem.
+Smokey,36.76,http://placekitten.com/200/300,25,true,Harum exercitationem ex ipsa.
+Simba,72.53,http://placekitten.com/200/300,41,true,Laborum blanditiis iusto velit.
+Lucy,78.55,http://placekitten.com/200/300,22,true,In eos et vero.
+Alfie,48.35,http://placekitten.com/200/300,49,true,Accusantium voluptas similique quia.
+Oliver,40.33,http://placekitten.com/200/300,54,true,At repellat error sint.
+Simba,95.27,http://placekitten.com/200/300,51,true,Esse amet assumenda et.
+Coco,80.22,http://placekitten.com/200/300,24,false,Alias perspiciatis iusto molestias.
+Coco,64.54,http://placekitten.com/200/300,96,false,Voluptas vitae nihil quidem.
+Alfie,60.28,http://placekitten.com/200/300,69,true,Totam quaerat consequuntur quia.
+Millie,68.28,http://placekitten.com/200/300,72,true,Et perferendis quia expedita.
+Smokey,90.27,http://placekitten.com/200/300,49,true,Laudantium optio temporibus qui.
+Misty,56.26,http://placekitten.com/200/300,76,true,Accusantium sapiente et non.
+Coco,5.06,http://placekitten.com/200/300,95,true,Natus quae perspiciatis in.
+Smudge,31.64,http://placekitten.com/200/300,77,false,Iusto ipsam repellat expedita.
+Sam,35.53,http://placekitten.com/200/300,24,true,Incidunt ratione aut repellendus.
+Bella,75.51,http://placekitten.com/200/300,37,true,Quis placeat cum architecto.
+Jasper,68.77,http://placekitten.com/200/300,46,false,Sed voluptatibus voluptate minus.
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..f81eb80593
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,86 @@
+# 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_24_224809) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "categories", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "categories_products", force: :cascade do |t|
+ t.bigint "category_id"
+ t.bigint "product_id"
+ t.index ["category_id"], name: "index_categories_products_on_category_id"
+ t.index ["product_id"], name: "index_categories_products_on_product_id"
+ end
+
+ create_table "merchants", force: :cascade do |t|
+ t.string "username"
+ t.string "email"
+ t.integer "uid"
+ t.string "provider"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "order_items", force: :cascade do |t|
+ t.integer "quantity"
+ t.string "status"
+ t.bigint "product_id"
+ t.bigint "order_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["order_id"], name: "index_order_items_on_order_id"
+ t.index ["product_id"], name: "index_order_items_on_product_id"
+ end
+
+ create_table "orders", force: :cascade do |t|
+ t.string "status"
+ t.string "name"
+ t.string "email"
+ t.string "address"
+ t.bigint "cc_num"
+ t.integer "cc_cvv"
+ t.date "cc_expiration"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "name"
+ t.decimal "price"
+ t.string "photo"
+ t.integer "stock"
+ t.boolean "active"
+ t.bigint "merchant_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "description"
+ t.index ["merchant_id"], name: "index_products_on_merchant_id"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.string "name"
+ t.integer "rating"
+ t.string "description"
+ t.bigint "product_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_reviews_on_product_id"
+ end
+
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..506c7b50cd
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,55 @@
+require 'csv'
+
+
+merchant_file = Rails.root.join('db', 'merchant_seeds.csv')
+order_item_file = Rails.root.join('db', 'order_item_seeds.csv')
+order_file = Rails.root.join('db', 'order_seeds.csv')
+product_file = Rails.root.join('db', 'product_seeds.csv')
+category_file = Rails.root.join('db', 'category_seeds.csv')
+
+CSV.foreach(merchant_file, headers: true, header_converters: :symbol, converters: :all) do |row|
+ data = Hash[row.headers.zip(row.fields)]
+ puts data
+ Merchant.create!(data)
+end
+
+CSV.foreach(order_file, headers: true, header_converters: :symbol, converters: :all) do |row|
+ data = Hash[row.headers.zip(row.fields)]
+ puts data
+ Order.create!(data)
+end
+
+CSV.foreach(category_file, headers: true, header_converters: :symbol, converters: :all) do |row|
+ data = Hash[row.headers.zip(row.fields)]
+ puts data
+ category = Category.new(data)
+ category.save!
+end
+
+CSV.foreach(product_file, headers: true, header_converters: :symbol, converters: :all) do |row|
+ data = Hash[row.headers.zip(row.fields)]
+ puts data
+ merchant = Merchant.all.shuffle.first
+ product = Product.new(data)
+ product.update_attributes(merchant: merchant)
+
+ num_categories = rand(4) + 1
+ list_categories = Category.all.shuffle[0..num_categories]
+
+ list_categories.each do |category|
+ product.categories << category
+ end
+
+
+ product.save!
+end
+
+CSV.foreach(order_item_file, headers: true, header_converters: :symbol, converters: :all) do |row|
+ data = Hash[row.headers.zip(row.fields)]
+ puts data
+ product = Product.all.shuffle.first
+ order = Order.all.shuffle.first
+ orderitem = OrderItem.new(data)
+ orderitem.update_attributes(order: order, product: product)
+ orderitem.save!
+end
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/petsy-emporium b/petsy-emporium
new file mode 160000
index 0000000000..f9eb18aad2
--- /dev/null
+++ b/petsy-emporium
@@ -0,0 +1 @@
+Subproject commit f9eb18aad20d87c5711a75004a9a278dfe8b1b61
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/categories_controller_test.rb b/test/controllers/categories_controller_test.rb
new file mode 100644
index 0000000000..9c423b7eda
--- /dev/null
+++ b/test/controllers/categories_controller_test.rb
@@ -0,0 +1,54 @@
+require "test_helper"
+
+describe CategoriesController do
+
+ before do
+ @merchant = merchants(:dogdays)
+ perform_login(@merchant)
+ end
+
+ describe "new" do
+ it 'should get new' do
+ get new_category_path
+
+ must_respond_with :success
+ end
+ end
+
+ describe "create" do
+ before do
+ @category_data = {
+ category: {
+ name: 'test category'
+ }
+ }
+ end
+ it 'can create a new category with valid data' do
+
+ test_category = Category.new(@category_data[:category])
+ test_category.must_be :valid?, "Category is invalid. Please fix."
+
+ expect{
+ post categories_path, params: @category_data
+ }.must_change('Category.count', +1)
+
+ must_redirect_to dashboard_path(@merchant.id)
+
+ end
+
+ it 'does not create a new category with invalid data' do
+
+ @category_data[:category][:name] = Category.first.name
+
+ test_category = Category.new(@category_data[:category])
+ test_category.wont_be :valid?, "Category is not invalid. Please fix."
+
+ expect{
+ post categories_path, params: @category_data
+ }.wont_change('Category.count')
+
+ must_respond_with :bad_request
+
+ end
+ end
+end
diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb
new file mode 100644
index 0000000000..e44b09ed41
--- /dev/null
+++ b/test/controllers/merchants_controller_test.rb
@@ -0,0 +1,81 @@
+require "test_helper"
+require 'pry'
+describe MerchantsController do
+
+ let(:merchant_data) {
+ {
+ merchant:
+ {
+ username: 'testername',
+ email: 'testername@gmail.com',
+ uid: 7,
+ provider: 'github'
+ }
+ }
+ }
+
+ let (:merchant) {
+ merchants(:dogdays)
+ }
+
+ describe "index" do
+ it "should get index" do
+
+ get merchants_path
+
+ must_respond_with :success
+ end
+ end
+
+ describe "show" do
+
+
+ it "should respond with success for showing an existing merchant" do
+
+ get merchant_path(merchant.id)
+ must_respond_with :success
+ end
+
+ it "should respond with not found for showing a non-existant merchant" do
+
+ merchant.destroy
+
+ expect{
+ get merchant_path(merchant.id)
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "dashboard" do
+ it "should respond with success for showing an existing merchant" do
+
+ get dashboard_path(merchant)
+
+ must_respond_with :success
+ end
+
+ it "raise error for showing a non existant merchant" do
+ merchant.destroy
+
+ expect{
+ get merchant_path(merchant.id)
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "dashboard" do
+ it "should respond with success for connecting to an existing merchant" do
+ existing_merchant = merchants(:dogdays)
+ get dashboard_path(existing_merchant.id)
+ must_respond_with :success
+ end
+
+ it "should respond with not found when trying to link to a non-existant merchant" do
+ get dashboard_path(bad_merchant_id)
+ must_respond_with :not_found
+ 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..a287e6bd31
--- /dev/null
+++ b/test/controllers/order_items_controller_test.rb
@@ -0,0 +1,112 @@
+require "test_helper"
+require 'pry'
+describe OrderItemsController do
+
+ describe "guest user" do
+ describe "index" do
+
+
+ it "can access cart" do
+
+ get order_items_path
+
+ must_respond_with :success
+ end
+ end
+
+
+ describe 'create' do
+ it "creates new order for first item added to cart" do
+
+ order_item_data = {
+ order_item: {
+ quantity: 1,
+ status: 'pending',
+ product_id: Product.first.id
+ }
+ }
+
+ before = OrderItem.count
+
+ expect {
+ post order_items_path, params: order_item_data
+ }.must_change('Order.count', +1)
+
+ expect(OrderItem.count).must_equal before + 1
+
+ expect(flash[:status]).must_equal :success
+ expect(flash[:result_text]).must_equal "Item successfully added to cart. "
+
+ expect(session[:order_id]).must_equal OrderItem.last.order_id
+
+ must_respond_with :redirect
+ end
+
+ it "successfully adds order item to existing order" do
+
+ merchant = merchants(:dogdays)
+ perform_login(merchant)
+
+ order_item_data = {
+ order_item: {
+ quantity: 3,
+ status: 'pending',
+ product_id: products(:product_two).id,
+ order_id: orders(:merchant).id
+ }
+ }
+
+ test_item = OrderItem.new(order_item_data[:order_item])
+ test_item.must_be :valid?, "OrderItem data was invalid. Please fix this test."
+
+ session[:order_id] = orders(:merchant).id
+
+ before = OrderItem.count
+
+ post order_items_path(order_item_data)
+
+ expect {
+ post order_items_path, params: order_item_data
+ }.wont_change('Order.count')
+
+ expect(OrderItem.count).must_equal before + 1
+
+ expect(flash[:status]).must_equal :success
+ expect(flash[:result_text]).must_include "Cart successfully updated"
+
+ must_respond_with :redirect
+
+ end
+
+ it "shows an error if the quantity is greater than the product's stock" do
+
+ order_item_data = {
+ order_item: {
+ quantity: 20,
+ status: 'pending',
+ product_id: products(:product_two).id,
+ order_id: orders(:merchant).id
+ }
+ }
+
+ test_item = OrderItem.new(order_item_data[:order_item])
+ before_stock = test_item.product.stock
+ # before_order = test_item.quantity
+ test_item.must_be :valid?, "OrderItem data was invalid. Please fix this test."
+
+ post order_items_path(order_item_data)
+
+ expect {
+ post order_items_path, params: order_item_data
+ }.wont_change('Order.count')
+
+ expect(test_item.product.stock).must_equal before_stock
+ order_item = OrderItem.find_by(
+ product_id: products(:product_two).id,
+ order_id: orders(:merchant).id
+ )
+ expect(order_item.quantity).must_equal 15
+ end
+ 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..80c1f8c623
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,124 @@
+require "test_helper"
+
+describe OrdersController do
+
+ let (:delete_all) {
+ Order.all.each do |order|
+ order.destroy
+ end
+ }
+
+ let (:order_data) {
+ {
+ order: {
+ status: 'paid',
+ name: 'Ada',
+ email: 'ada@adacademy.com',
+ address: '123 Street Dr. Seattle, WA',
+ cc_num: 1123384229389283,
+ cc_cvv: 280,
+ cc_expiration: '2020-09-01'
+ }
+ }
+ }
+
+ let (:existing_order) {
+ orders(:bob)
+ }
+
+ describe "index" do
+ it "succeeds with orders present" do
+ get orders_path
+
+ must_respond_with :success
+ end
+
+ it "succeeds with no orders present" do
+ delete_all
+
+ get orders_path
+
+ must_respond_with :success
+ end
+ end
+
+ describe "create" do
+ it "can create an order" do
+ test_order = Order.new(order_data[:order])
+ expect(test_order).must_be :valid?, "Order data was invalid. Please fix."
+
+ expect{
+ post orders_path, params: order_data
+ }.must_change('Order.count', +1 )
+
+ must_redirect_to order_path(Order.last)
+ must_respond_with :redirect
+ end
+ end
+
+ describe "edit" do
+ it "succeeds with an extant order ID" do
+ get edit_order_path(existing_order.id)
+
+ must_respond_with :success
+ end
+
+ it "renders 404 not_found for a bogus order ID" do
+ existing_order.destroy
+
+ expect{
+ get edit_order_path(existing_order.id)
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "update" do
+ it "succeeds for valid data and an extant work ID" do
+ test_order = Order.new(order_data[:order])
+ expect(test_order).must_be :valid?, "Order data was invalid. Please fix."
+
+ expect {
+ patch order_path(existing_order.id), params: order_data
+ }.wont_change('Order.count')
+
+ existing_order.reload
+ (existing_order.email).must_equal test_order.email
+ (existing_order.name).must_equal test_order.name
+ (existing_order.address).must_equal test_order.address
+
+ must_redirect_to order_path(existing_order.id)
+ end
+
+ it "renders 404 not_found for a bogus order ID" do
+ existing_order.destroy
+
+ expect{
+ patch order_path(existing_order.id), params: order_data
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "destroy" do
+ it "succeeds for an extant order ID with status not cancelled" do
+ expect {
+ delete order_path(existing_order.id)
+ }.must_change('Order.count', -1)
+
+ must_respond_with :redirect
+ must_redirect_to root_path
+ end
+
+ it "renders 404 not_found and does not update the DB for a bogus order ID" do
+ existing_order.destroy
+
+ expect{
+ delete order_path(existing_order.id)
+ }.must_raise(ActionController::RoutingError)
+
+ 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..e1afbb818b
--- /dev/null
+++ b/test/controllers/products_controller_test.rb
@@ -0,0 +1,151 @@
+require "test_helper"
+require 'pry'
+
+describe ProductsController do
+ let (:product_data) {
+ {
+ product: {
+ name: "Test product",
+ price: 3.50,
+ merchant: merchants(:dogdays),
+ stock: 5,
+ active: true
+ }
+ }
+ }
+
+ let (:product) {
+ products(:product_one)
+ }
+
+ describe "guest user" do
+ describe "index" do
+ it "successfully gets index" do
+ get products_path
+
+ must_respond_with :success
+ end
+ end
+
+ describe "show" do
+ it "should respond with success for showing an existing product" do
+
+ get product_path(product.id)
+
+ must_respond_with :success
+ end
+
+ it "should respond with not found for showing a non-existing product" do
+
+ product.destroy
+
+ expect{
+ get product_path(product.id)
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "create" do
+ it 'should not allow guest user to create a new product' do
+ test_product = Product.new(product_data[:product])
+ test_product.must_be :valid?, "Product data was invalid. Please come fix this test."
+
+ expect {
+ post products_path, params: product_data
+ }.wont_change('Product.count')
+
+ must_respond_with :bad_request
+ end
+ end
+
+ describe "update" do
+ it "should not allow guest user to update a new product" do
+
+ end
+ end
+ end
+
+ describe "merchant user" do
+ before do
+ perform_login(merchants(:dogdays))
+ end
+
+ describe "new" do
+ it "successfully retrieves new page" do
+
+ get new_product_path
+
+ must_respond_with :success
+
+ end
+ end
+
+ describe "create" do
+ it "creates new product when logged in and given valid data" do
+
+
+ test_product = Product.new(product_data[:product])
+ test_product.must_be :valid?, "Product data was invalid. Please come fix this test."
+
+ expect {
+ post products_path, params: product_data
+ }.must_change('Product.count', 1)
+
+ must_redirect_to products_path
+
+ expect(Product.last.name).must_equal product_data[:product][:name]
+ end
+ end
+
+ describe "edit" do
+ it "responds with success for an existing product" do
+ get edit_product_path(product)
+
+ must_respond_with :success
+ end
+
+ it "responds with not_found for a product that doesn't exist" do
+ product.destroy
+
+ expect{
+ get edit_product_path(product)
+
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "update" do
+ it "should show success when showing an existing product" do
+
+ get product_path(product.id)
+
+ must_respond_with :success
+ end
+
+ it "should return error message if product doesn't exist" do
+
+ product.destroy
+
+ expect{
+ get product_path(product.id)
+ }.must_raise(ActionController::RoutingError)
+
+ end
+ end
+
+ describe "destroy" do
+ it "can destroy an existing product" do
+
+
+ expect {
+ delete product_path(product)
+ }.must_change('Product.count', -1)
+
+
+ must_redirect_to products_path
+ 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..be9c6fbd45
--- /dev/null
+++ b/test/controllers/reviews_controller_test.rb
@@ -0,0 +1,35 @@
+require "test_helper"
+
+describe ReviewsController do
+ let (:product) {Product.first}
+ describe "new" do
+ it "can get new page" do
+ get new_product_review_path(product)
+ must_respond_with :success
+ end
+ end
+ describe "create" do
+ it "can create a review with valid data" do
+ review_data = {
+ review: {
+ name: "Aurea",
+ rating: 5,
+ product: product
+ }
+ }
+ test_review = Review.new(review_data[:review])
+ test_review.must_be :valid?, "Review data was invalid. Please come fix this test."
+
+ # expect {
+ # post product_reviews_path(product), params: review_data
+ # }.must_change('Review.count', +1)
+ # VNG: In the console, Review.count returns 0, so I think there's a problem with our yml files/test database.
+ post product_reviews_path(product), params: review_data
+ must_respond_with :success
+ # must_redirect_to product_path(product)
+ # VNG: Redirect causes error - response is 200 ok, not redirect.
+ end
+ it "doesn't create a review with invalid data" do
+ 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..8be9258f12
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,60 @@
+require "test_helper"
+
+describe SessionsController do
+ describe 'create' do
+ it 'can sucessfully log in with github as an existing user' do
+ merchant = merchants(:dogdays)
+
+ perform_login(merchant)
+
+ must_redirect_to root_path
+
+ expect(session[:user_id]).must_equal merchant.id
+ # expect(flash[:success]).must_equal "Logged in as merchant #{merchant.username}"
+ # VNG - We need to fix flash.
+ end
+
+ it 'creates a new user sucessfully when logging in with a new valid user' do
+
+ start_count = Merchant.count
+
+ new_user = Merchant.new(username: "new user", email: "email@email.com", uid: 10, provider: "github")
+
+ expect(new_user.valid?).must_equal true
+
+ perform_login(new_user)
+
+ must_redirect_to root_path
+
+ expect(Merchant.count).must_equal start_count + 1
+
+ expect( session[:user_id] ).must_equal Merchant.last.id
+
+ end
+
+ it 'does not create a new user when logging in with a new invalid user' do
+ start_count = Merchant.count
+
+ invalid_new_user = Merchant.new(username: nil, email: nil)
+
+ expect(invalid_new_user.valid?).must_equal false
+
+ perform_login(invalid_new_user)
+
+ must_redirect_to root_path
+ expect( session[:user_id] ).must_equal nil
+ expect( Merchant.count ).must_equal start_count
+ end
+ end
+
+ describe 'destroy' do
+ it 'can log out a logged in user' do
+ merchant = merchants(:dogdays)
+
+ perform_login(merchant)
+
+ delete logout_path(merchant)
+ must_redirect_to root_path
+ 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..ea917c3146
--- /dev/null
+++ b/test/fixtures/categories.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+dog:
+ name: dogs
+ products: [product_one, product_two]
+cat:
+ name: cats
+ products: [product_three]
+val:
+ name: silly val
+ products: [product_one, product_two, product_six]
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml
new file mode 100644
index 0000000000..443c5d08dc
--- /dev/null
+++ b/test/fixtures/merchants.yml
@@ -0,0 +1,26 @@
+# 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
+#
+dogdays:
+ username: dogsdays
+ email: dogsdays@over.com
+ uid: 12345
+ provider: github
+palomino:
+ username: palomino
+ email: horsesgalore@some.com
+ uid: 31234
+ provider: github
+larry:
+ username: lizardlarry
+ email: larry54@over.com
+ uid: 7124
+ provider: github
+cuteclothes:
+ username: cuteclothes
+ email: cuteclothes@shop.com
+ uid: 1123
+ provider: github
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
new file mode 100644
index 0000000000..7daf33b778
--- /dev/null
+++ b/test/fixtures/order_items.yml
@@ -0,0 +1,36 @@
+# 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:
+ quantity: 1
+ status: paid
+ product: product_one
+ order: bob
+two:
+ quantity: 1
+ status: paid
+ product: product_two
+ order: bob
+three:
+ quantity: 1
+ status: paid
+ product: product_three
+ order: bob
+four:
+ quantity: 1
+ status: paid
+ product: product_four
+ order: bob
+five:
+ quantity: 3
+ status: pending
+ product: product_one
+ order: bob
+six:
+ quantity: 2
+ status: pending
+ product: product_one
+ order: merchant
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..500051f840
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,24 @@
+# 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
+#
+bob:
+ status: paid
+ name: Bob Li
+ email: bobli@adacademy.com
+ address: 100 6th Avenue, Seattle WA
+ cc_num: 1232837292749182
+ cc_cvv: 293
+ cc_expiration: '01-09-2018'
+incomplete_order:
+ status: pending
+merchant:
+ status: pending
+ name: Dog Days
+ email: dog@days.com
+ address: 100 10th Avenue, Seattle WA
+ cc_num: 1232837292749182
+ cc_cvv: 293
+ cc_expiration: 01-09-2018
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
new file mode 100644
index 0000000000..3832b58675
--- /dev/null
+++ b/test/fixtures/products.yml
@@ -0,0 +1,46 @@
+product_one:
+ name: test product 1
+ price: 1.99
+ photo: http://placekitten.com/200/300
+ stock: 10
+ active: true
+ merchant: dogdays
+ description: blah blah blah cats
+product_two:
+ name: test product 2
+ price: 10.99
+ photo: http://placekitten.com/200/300
+ stock: 15
+ active: true
+ merchant: palomino
+ description: blah blah blah cats
+product_three:
+ name: test product 3
+ price: 18.99
+ photo: http://placekitten.com/200/300
+ stock: 5
+ active: true
+ merchant: larry
+ description: blah blah blah cats
+product_four:
+ name: test product 4
+ price: 1.99
+ photo: http://placekitten.com/200/300
+ stock: 8
+ active: true
+ merchant: cuteclothes
+ description: blah blah blah cats
+product_five:
+ name: test product 5
+ price: 11.99
+ photo: http://placekitten.com/200/300
+ stock: 10
+ active: true
+ merchant: dogdays
+ description: blah blah blah cats
+product_six:
+ name: test product 6
+ price: 11.99
+ stock: 10
+ active: true
+ merchant: dogdays
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..7c758d2f62
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,22 @@
+# 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
+#
+review_one:
+ name: Val
+ rating: 2
+ product: product_one
+review_two:
+ name: Ada
+ rating: 5
+ product: product_one
+review_three:
+ name: Val
+ rating: 4
+ product: product_five
+review_four:
+ name: Val
+ rating: 5
+ product: product_six
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/helpers/merchants_helper.rb b/test/helpers/merchants_helper.rb
new file mode 100644
index 0000000000..1b3433be36
--- /dev/null
+++ b/test/helpers/merchants_helper.rb
@@ -0,0 +1,17 @@
+require "test_helper"
+require 'pry'
+
+describe MerchantsHelper do
+
+describe "render_date" do
+ it "should correctly format dates to string format" do
+ order = order_items.first
+ expect(order.valid?).must_equal true
+
+ date = order.created_at
+
+ expect(render_date(order.created_at)).must_be_kind_of String
+ end
+ end
+
+end
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..a4bfe01b0d
--- /dev/null
+++ b/test/models/category_test.rb
@@ -0,0 +1,38 @@
+require "test_helper"
+
+describe Category do
+ before do
+ @c = categories(:dog)
+ end
+
+ describe 'relations' do
+ it 'has some products' do
+
+ expect( @c.products ).must_respond_to :each
+
+ @c.products.each do |product|
+ expect( product ).must_be_instance_of Product
+ end
+ end
+ end
+
+ describe 'validations' do
+ it 'is valid with a unique name' do
+
+ expect( @c ).must_be :valid?
+ end
+ it 'is invalid without a name' do
+
+ @c.name = nil
+
+ expect( @c ).wont_be :valid?
+ end
+
+ it 'is invalid with a duplicate name' do
+
+ dup_category = Category.new(name: @c.name )
+
+ expect( dup_category ).wont_be :valid?
+ end
+ end
+end
diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb
new file mode 100644
index 0000000000..de13a18fee
--- /dev/null
+++ b/test/models/merchant_test.rb
@@ -0,0 +1,82 @@
+require "test_helper"
+
+describe Merchant do
+ before do
+ @m = merchants(:dogdays)
+ end
+ describe 'relations' do
+ it 'has some products' do
+
+ expect( @m.products ).must_respond_to :each
+
+ @m.products.each do |product|
+
+ expect( product ).must_be_instance_of Product
+ end
+ end
+ end
+
+ describe 'validations' do
+ let (:new_merchant) {
+ Merchant.new(
+ username: 'testusername',
+ email: 'testemail@ada.com',
+ uid: 9999,
+ provider: 'github'
+ )
+ }
+
+
+ it 'is valid when username and email is unique and present' do
+
+ expect( @m ).must_be :valid?
+
+ end
+
+ it 'is invalid without a username' do
+ @m.username = nil
+
+ expect ( @m ).wont_be :valid?
+ end
+
+ it 'is invalid when username is non unique' do
+
+ expect( new_merchant ).must_be :valid?
+
+ new_merchant.username = @m.username
+
+ expect( new_merchant ).wont_be :valid?
+ end
+
+ it 'is invalid without an email' do
+ @m.email = nil
+
+ expect( @m ).wont_be :valid?
+ end
+
+ it 'is invalid when email is non unique' do
+ expect( new_merchant).must_be :valid?
+
+ new_merchant.email = @m.email
+
+ expect( new_merchant ).wont_be :valid?
+ end
+
+ end
+
+ describe 'rating' do
+ it 'returns average of all product ratings' do
+ expect( @m.rating ).must_be_close_to 4.17, 0.01
+ end
+
+ it 'returns nil if no products' do
+ @m.products.each do |product|
+ product.destroy
+ end
+
+ @m.reload
+
+ expect( @m.rating ).must_be_nil
+ 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..1af6126d11
--- /dev/null
+++ b/test/models/order_item_test.rb
@@ -0,0 +1,73 @@
+require "test_helper"
+
+describe OrderItem do
+ before do
+ @o = order_items(:one)
+ end
+ describe 'relations' do
+ it 'has a product' do
+
+ expect( @o.product ).must_be_instance_of Product
+
+ end
+
+ it 'has an order' do
+
+ expect( @o.order ).must_be_instance_of Order
+
+ end
+ end
+
+ describe 'validations' do
+ it 'is valid when quantity and status are present with valid values' do
+
+ expect( @o ).must_be :valid?
+
+ end
+
+ it 'is invalid without a quantity' do
+
+ @o.quantity = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid with a quantity of 0 or less' do
+
+ @o.quantity = 0
+
+ expect( @o ).wont_be :valid?
+
+ @o.quantity = -1
+
+ expect( @o ).wont_be :valid?
+ end
+
+ it 'is invalid without a status' do
+
+ @o.status = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid when the status is not one of the valid status values' do
+
+ @o.status = 'foo'
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ end
+
+ describe 'price' do
+ it 'correctly calculates price based on product price and quantity' do
+ o = order_items(:five)
+
+ expect( o.price).must_be_close_to 5.97, 0.01
+ end
+ end
+
+end
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..cf05ced97b
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,192 @@
+require "test_helper"
+
+describe Order do
+ before do
+ @o = orders(:bob)
+ end
+ describe 'relations' do
+
+
+ it 'has some order items' do
+ expect( @o.order_items ).must_respond_to :each
+
+ @o.order_items.each do |order_item|
+ expect(order_item).must_be_instance_of OrderItem
+ end
+ end
+
+
+ end
+
+ describe 'validations' do
+ describe 'conditional validation: order is not pending' do
+
+ it 'is valid when all required fields are present' do
+ expect( @o ).must_be :valid?
+
+ end
+
+ it 'is invalid without a name' do
+
+ @o.name = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid without an email' do
+
+ @o.email = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid without an address' do
+
+ @o.address = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid without a cc_num' do
+
+ @o.cc_num = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid without a cc_cvv' do
+
+ @o.cc_cvv = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+
+ it 'is invalid without a cc_expiration' do
+
+ @o.cc_expiration = nil
+
+ expect( @o ).wont_be :valid?
+
+ end
+ end
+
+ describe 'unconditional validation' do
+
+ before do
+ @o = orders(:incomplete_order)
+ end
+
+ it 'is valid if status is present and true' do
+ expect( @o ).must_be :valid?
+ end
+
+ it 'is invalid if status is not a valid status' do
+ @o.status = 'foo'
+
+ expect( @o ).wont_be :valid?
+ end
+ end
+
+ end
+
+ describe 'is_not_pending' do
+ it 'returns false if pending' do
+ @o.status = 'pending'
+
+ expect( @o.is_not_pending ).must_equal false
+ end
+
+ it 'returns true if not pending' do
+
+ Order::STATUS.each do |status|
+ if status != 'pending'
+ @o.status = status
+
+ expect( @o.is_not_pending ).must_equal true
+ end
+ end
+
+ end
+ end
+
+ describe 'total' do
+ it 'returns total price of all order items' do
+
+ expect( @o.total ).must_be_close_to 39.93, 0.01
+ end
+
+ it 'returns 0 if no order items' do
+
+ @o.order_items.each do |order_item|
+ order_item.destroy
+ end
+
+ @o.reload
+
+ expect( @o.total ).must_equal 0
+
+ end
+
+ end
+ describe 'CC_num_last_four' do
+ it 'correctly returns last four digits of cc_num' do
+ @o.cc_num = '1239082378923'
+
+ expect( @o.CC_num_last_four ).must_equal '8923'
+ end
+
+ it 'returns total string if cc_num length is less than 4' do
+ @o.cc_num = '13'
+
+ expect( @o.CC_num_last_four ).must_equal '13'
+ end
+
+ it 'returns nil if cc_num is nil' do
+ @o.cc_num = nil
+
+ expect( @o.CC_num_last_four ).must_be_nil
+ end
+ end
+
+ describe 'total_quantity' do
+ it 'returns total quantity of all order items' do
+
+ expect( @o.total_quantity ).must_equal 7
+ end
+
+ it 'returns 0 if no order items' do
+
+ @o.order_items.each do |order_item|
+ order_item.destroy
+ end
+
+ @o.reload
+
+ expect( @o.total_quantity ).must_equal 0
+
+ end
+ end
+
+ describe 'paid' do
+ it 'successfully sets own status and all order items status to paid' do
+ @o.status = 'pending'
+
+ @o.order_items.each do |order_item|
+ order_item.status = 'pending'
+ end
+
+ @o.set_paid
+
+ expect( @o.status ).must_equal 'paid'
+
+ @o.order_items.each do |order_item|
+ expect( order_item.status ).must_equal 'paid'
+ end
+ end
+ end
+end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
new file mode 100644
index 0000000000..53f5992923
--- /dev/null
+++ b/test/models/product_test.rb
@@ -0,0 +1,98 @@
+require "test_helper"
+
+describe Product do
+
+ before do
+ @p = Product.first
+ end
+
+ describe 'relations' do
+
+ it 'has a merchant' do
+
+ expect( @p.merchant ).must_be_instance_of Merchant
+
+ end
+ it 'has some reviews' do
+
+ expect( @p.reviews ).must_respond_to :each
+ expect( @p.reviews.first ).must_be_instance_of Review
+
+ end
+
+ it 'has some order items' do
+
+ expect( @p.order_items ).must_respond_to :each
+ expect( @p.order_items.first ).must_be_instance_of OrderItem
+
+ end
+
+ it 'has some categories' do
+ expect( @p.categories).must_respond_to :each
+ expect( @p.categories.first ).must_be_instance_of Category
+ end
+ end
+
+ describe 'validations' do
+ it 'is valid when required fields are present and price and stock are valid inputs' do
+
+ expect( @p ).must_be :valid?
+
+ end
+
+ it 'is invalid without a name' do
+
+ @p.name = nil
+
+ expect( @p ).wont_be :valid?
+ end
+
+ it 'is invalid without a price' do
+
+ @p.price = nil
+
+ expect( @p ).wont_be :valid?
+
+ end
+
+ it 'is invalid with a price less than or equal to zero' do
+
+ @p.price = 0
+
+ expect( @p ).wont_be :valid?
+
+ @p.price = -1
+
+ expect( @p ).wont_be :valid?
+ end
+
+ it 'is invalid without a stock' do
+
+ @p.stock = nil
+
+ expect( @p ).wont_be :valid?
+ end
+
+ it 'is invalid with a negative stock' do
+
+ @p.stock = -1
+
+ expect( @p ).wont_be :valid?
+
+ end
+
+ end
+
+ describe 'rating' do
+ it 'returns average of the reviews rating' do
+
+ expect( @p.rating ).must_be_close_to 3.5, 0.01
+ end
+
+ it 'returns nil for a product with no reviews' do
+ no_reviews = products(:product_two)
+
+ expect( no_reviews.rating ).must_be_nil
+ end
+ end
+end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..91a642b40d
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,41 @@
+require "test_helper"
+
+describe Review do
+ before do
+ @r = reviews(:review_one)
+ end
+ describe 'relations' do
+ it 'has a product' do
+ expect ( @r.product ).must_be_instance_of Product
+ end
+ end
+
+ describe 'validations' do
+ it 'is valid when name and rating is present, and rating is int between 1 and 5' do
+
+ expect( @r ).must_be :valid?
+
+ end
+
+ it 'is invalid when name is missing' do
+
+ @r.name = nil
+ expect ( @r ).wont_be :valid?
+ end
+
+ it 'is invalid when rating is missing' do
+ @r.rating = nil
+ expect ( @r ).wont_be :valid?
+ end
+
+ it 'is invalid when rating is not an int between 1 through 5' do
+ invalid_rating = 0
+
+ expect( Review::RATINGS.include?(invalid_rating)).must_equal false
+
+ @r.rating = invalid_rating
+
+ expect( @r ).wont_be :valid?
+ 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..728b40e6af
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,48 @@
+require 'simplecov'
+SimpleCov.start 'rails'
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters" # for Colorized output
+require "pry"
+# For colorful output!
+Minitest::Reporters.use!(
+ Minitest::Reporters::SpecReporter.new,
+ ENV,
+ Minitest.backtrace_filter
+)
+
+
+# To add Capybara feature tests add `gem "minitest-rails-capybara"`
+# to the test group in the Gemfile and uncomment the following:
+# require "minitest/rails/capybara"
+
+# Uncomment for awesome colorful output
+# require "minitest/pride"
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+ # Add more helper methods to be used by all tests here...
+ def setup
+ OmniAuth.config.test_mode = true
+ end
+
+ def mock_merchant_hash(user)
+ return {
+ uid: user.uid,
+ provider: user.provider,
+ info: {
+ nickname: user.username,
+ email: user.email
+ }
+ }
+ end
+
+ def perform_login(user)
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new( mock_merchant_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