diff --git a/app/views/users/update.html.erb b/app/views/users/update.html.erb
new file mode 100644
index 0000000000..cabbde176a
--- /dev/null
+++ b/app/views/users/update.html.erb
@@ -0,0 +1,2 @@
+
Users#update
+
Find me in app/views/users/update.html.erb
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 0000000000..66e9889e8b
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 0000000000..5badb2fde0
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000000..d87d5f5781
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000000..78c4e861dc
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/spring b/bin/spring
new file mode 100755
index 0000000000..fb2ec2ebb4
--- /dev/null
+++ b/bin/spring
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+# This file loads spring without using Bundler, in order to be fast.
+# It gets overwritten when you run the `spring binstub` command.
+
+unless defined?(Spring)
+ require 'rubygems'
+ require 'bundler'
+
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
+ if spring
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
+ gem 'spring', spring.version
+ require 'spring/binstub'
+ end
+end
diff --git a/bin/update b/bin/update
new file mode 100755
index 0000000000..a8e4462f20
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/yarn b/bin/yarn
new file mode 100755
index 0000000000..c2bacef836
--- /dev/null
+++ b/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+VENDOR_PATH = File.expand_path('..', __dir__)
+Dir.chdir(VENDOR_PATH) do
+ begin
+ exec "yarnpkg #{ARGV.join(" ")}"
+ rescue Errno::ENOENT
+ $stderr.puts "Yarn executable was not detected in the system."
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
+ exit 1
+ end
+end
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000000..f7ba0b527b
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 0000000000..5f6ca0f9b2
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,25 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Betsy
+ class Application < Rails::Application
+ config.generators do |g|
+ # Force new test files to be generated in the minitest-spec style
+ g.test_framework :minitest, spec: true
+
+ # Always use .js files, never .coffee
+ g.javascript_engine :js
+ end
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.1
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 0000000000..30f5120df6
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000000..3cba994bb2
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: redis://localhost:6379/1
+ channel_prefix: betsy_production
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000000..6903bb6083
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,85 @@
+# PostgreSQL. Versions 9.1 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On OS X with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On OS X with MacPorts:
+# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem 'pg'
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see Rails configuration guide
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: betsy_development
+
+ # The specified database role being used to connect to postgres.
+ # To create additional roles in postgres see `$ createuser --help`.
+ # When left blank, postgres will use the default role. This is
+ # the same name as the operating system user that initialized the database.
+ #username: betsy
+
+ # The password associated with the postgres role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: betsy_test
+
+# As with config/secrets.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password as a unix environment variable when you boot
+# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full rundown on how to provide these environment variables in a
+# production deployment.
+#
+# On Heroku and other platform providers, you may have a full connection URL
+# available as an environment variable. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# You can use this database configuration with:
+#
+# production:
+# url: <%= ENV['DATABASE_URL'] %>
+#
+production:
+ <<: *default
+ database: betsy_production
+ username: betsy
+ password: <%= ENV['BETSY_DATABASE_PASSWORD'] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 0000000000..426333bb46
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 0000000000..5187e22186
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,54 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 0000000000..9284f84839
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,91 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
+ # `config/secrets.yml.key`.
+ config.read_encrypted_secrets = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "betsy_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 0000000000..8e5cbde533
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 0000000000..89d2efab2b
--- /dev/null
+++ b/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644
index 0000000000..4b828e80cb
--- /dev/null
+++ b/config/initializers/assets.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000000..59385cdf37
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000000..5a6a32d371
--- /dev/null
+++ b/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000000..4a994e1e7b
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 0000000000..ac033bf9dc
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
new file mode 100644
index 0000000000..dc1899682b
--- /dev/null
+++ b/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
new file mode 100644
index 0000000000..fd4416122a
--- /dev/null
+++ b/config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email"
+end
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000000..bbfc3961bf
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000000..decc5a8573
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000000..1e19380dcb
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,56 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# If you are preloading your application and using Active Record, it's
+# recommended that you close any connections to the database before workers
+# are forked to prevent connection leakage.
+#
+# before_fork do
+# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
+# end
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted, this block will be run. If you are using the `preload_app!`
+# option, you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, as Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+#
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000000..e850b8765a
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,34 @@
+Rails.application.routes.draw do
+
+ root 'products#root'
+
+ get "/auth/:provider/callback", to: "users#create", as: "auth_callback"
+ get '/auth/github', as: 'github_login'
+ delete '/logout', to: "users#destroy", as: "logout"
+
+ # this is a new route to limit view of order details for merchant
+ get '/sold_order/:id' , to: 'orders#merchant_order_show', as: 'sold_order'
+
+ get '/order' , to: 'sessions#index', as: 'order'
+ post '/order' , to: 'sessions#create', as: 'add_to_order'
+ patch '/order' , to: 'sessions#update', as: 'update_order'
+ delete '/order' , to: 'sessions#destroy', as: 'delete_order'
+
+ get '/order/:id' , to: 'orders#show', as: 'order_details'
+
+ resources :orders, only: [:index, :new, :create]
+
+ resources :products do
+ resources :reviews, only: [:create, :new]
+ end
+
+ resources :categories, only: [:index, :create, :new, :show]
+
+ resources :order_items, only: [:index, :create, :edit, :update]
+
+ resources :users do
+ resources :products, except: [:delete]
+ resources :order_items, only: [:index]
+ end
+
+end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 0000000000..179336ff23
--- /dev/null
+++ b/config/secrets.yml
@@ -0,0 +1,32 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rails secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+# Shared secrets are available across all environments.
+
+# shared:
+# api_key: a1B2c3D4e5F6
+
+# Environmental secrets are only available for that specific environment.
+
+development:
+ secret_key_base: 147a9afc71e9272434bf1a899380a22ada6e19f31e7bc72d6cdda2eb7e9314b4417149fa46cca133717cd89b5d08e878bed800356f4620eca00a40cde8e068fc
+
+test:
+ secret_key_base: 19331df2ba4566119aafe1d5afb6363fa4e4dbe04069bae28395062ee29eaaa72db42fae835a73d64876a0dfe3d46f31112410e57a2de01b3d8b0d57ddebc729
+
+# Do not keep production secrets in the unencrypted secrets file.
+# Instead, either read values from the environment.
+# Or, use `bin/rails secrets:setup` to configure encrypted secrets
+# and move the `production:` environment over there.
+
+production:
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 0000000000..c9119b40c0
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/db/Categoryseed.csv b/db/Categoryseed.csv
new file mode 100644
index 0000000000..4bff8612f4
--- /dev/null
+++ b/db/Categoryseed.csv
@@ -0,0 +1,6 @@
+Category
+Bunches
+Citrus
+Pome
+Pits
+Edible skin
\ No newline at end of file
diff --git a/db/MerchantSeed.csv b/db/MerchantSeed.csv
new file mode 100644
index 0000000000..4ede3bdd4a
--- /dev/null
+++ b/db/MerchantSeed.csv
@@ -0,0 +1,6 @@
+name,email,UID,provider
+Guest,guest@gmail.com
+Joe Schmo,Joe@Schmo.com,234134,github
+Margo Tenenbaum,margot@tenenbaum.com,34363838,github
+Tabitha Baker,tabitha@baker.com,24354325,github
+Lucy Sanders,lucy@sanders.com,2635467,github
diff --git a/db/OrderItemsSeed.csv b/db/OrderItemsSeed.csv
new file mode 100644
index 0000000000..3271430c7a
--- /dev/null
+++ b/db/OrderItemsSeed.csv
@@ -0,0 +1,10 @@
+order_id,product_id,quantity,status
+1,3,10,"paid"
+1,8,5,"paid"
+2,7,40,"shipped"
+2,11,15,"shipped"
+2,20,7,"paid"
+3,5,100,"shipped"
+3,12,1,"paid"
+3,13,1,"paid"
+3,18,2,"shipped"
diff --git a/db/OrdersSeed.csv b/db/OrdersSeed.csv
new file mode 100644
index 0000000000..0b40881406
--- /dev/null
+++ b/db/OrdersSeed.csv
@@ -0,0 +1,8 @@
+user_id,name,card_number,email,street,city,state,zip,date_year,date_month,date_day,cvv,status
+2,"Ben",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"pending"
+3,"Tim",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"paid"
+4,"Tyler",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"complete"
+2,"Ben",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"paid"
+3,"Tim",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"complete"
+4,"Tyler",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"pending"
+4,"Tyler",8888333344447777,"person@email.com","1500 West Easy St.","Seattle","WA",89123,2025,4,20,314,"complete"
diff --git a/db/ProductSeed.csv b/db/ProductSeed.csv
new file mode 100644
index 0000000000..735365afac
--- /dev/null
+++ b/db/ProductSeed.csv
@@ -0,0 +1,22 @@
+Product,price,description,user_id,quantity ,image
+Vimto,4.00,Vimto, the sugary purple fruit drink that gives an energy boost. It contains the juice of grapes, raspberries and blackcurrants (in a 3% concentration), flavoured with herbs and spices. Vimto is the best drink for all occasions,2,30,https://images-na.ssl-images-amazon.com/images/I/61kv2ukkbVL._SX679_.jpg
+Banana,0.25,Perfectly ripe,2,50,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Rainier Cherries,2.99,Sweet and juicy,2,30,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Green Grapes,2.00,"
+A great energy source because of their natural fruit sugar content",2,300,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Grapefruit,1.00,"One of the largest citrus fruit, grapefruits are a cross between the pomelo and the shaddock. High in vitamin C, grapefruits are best eaten raw, a traditional breakfast fruit. The best way to eat is to cut them in half and scoop out the flesh with a spoon.",2,10,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Kumquat,0.50,"The name means ""golden orange"" in Chinese. Kumquats are often preserved in sweet syrup and used for marmalade and garnishes, but fresh ones are delicious in fruit salads or for eating just as they are.",2,80,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Lemon,0.25,"Rarely eaten on its own, lemons are an indispensable ingredient in the kitchen. Lemon juice can be used instead of vinegar in sauces, for seasoning in vinaigrette and as instant dressing for fish and shellfish. The best way to store lemon is in the vegetable crisper in the fridge you can put lemons in fruit bowl for a shorter, check them often - if one starts to spoil, the rest will quickly follow.",2,15,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Pineapple,3.00,"Derived from the Spanish word 'pina' meaning pine cone. Pineapples have a juicy, sweet-but sometimes slightly tart-fragrant flavour. They are best eaten fresh, serve pineapple flesh in slices, wedges or chunks. It is also available in cans, dried and glace. A good source of vitamin C.",2,14,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Plums,1.25,"Plums contain more antioxidant than any other fruit. Plums are delicate so make sure that the one you buy are unblemished, and they should be plump and firm. The small sugar plum is dried to make prunes. Delicious stewed, plums are also ideal for making chutneys.",2,16,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Start Apple,1.15,"The star apple fruits are green to purple with a smooth skin. When sliced horizontally the flesh is translucent white with the seeds forming a star shape. It is best eaten ripe, scooped straight from the skin. It is ripe when soft and should be eaten immediately, but it is still alright to refrigerate for a few days.",2,45,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Strawberry,2.78,"A unique fruit, the seeds grow around the outside of the fruit rather than inside it. Comes in many different sizes, colours and shapes, ranging from cone-like, to oval, or heart-shaped. Best to eat on their own or with natural yoghurt. Use strawberries in desserts, fruit salads, preserves, or in milkshakes.",3,26,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Watermelon ,5.00,"The high water content of watermelons means that they are low in calories. They contain some vitamins B and C. Watermelon is excellent juiced, chopped up into a fruit salad, or just eaten in chunky slices.",3,43,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Tamarillo,1.65,"these are related to tomatoes and sometimes called ""tree tomatoes."" They are the size of an egg tomato, with dark red skin. The fruit has a strong, sweet flavour that makes it suitable for both sweet or savoury dishes. It can also be used in jams, chutneys, and sorbets.",3,12,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Rambutan,3.40,"The rambutan fruit grows in clusters, with a deep crimson outer skin. The flesh is translucent, and the pale seed is edible when young. Related to lychees and are sometimes known as ""hairy lychees"".(about 5cm / 2inches in diameter) and look quite different but have a similar texture. They can be added to salads, made into jams or jellies, but they are best eaten on their own.",3,4,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Peach,2.25,"Or pawpaw, a large tropical fruit whose ripe flesh can be juicy, creamy, orange-red, or yellow. In the centre is a mass of large peppery black seeds, which are edible and sometimes crushed and used as a spice. Ripe papaya is eaten as a breakfast fruit or as a dessert. It can also be pureed for ice cream, sorbets and iced drinks.",3,9,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Fig,0.50,"Figs are oval or pear-shaped and can be eaten fresh or dried. They are well known for their laxative and digestive properties. Their high, natural sugar content makes them the sweetest of all fruits. The flavour varies, depending on where they were grown and how ripe they are.",4,24,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Lime,0.25,"Limes are only green because they are picked unripe but if left to ripen they turn yellow. Limes can be used like lemons but as juice, it is more acidic, so usually less is needed. To make the juice flow more, you can microwave the limes for 2-3 seconds before squeezing. Mostly used in drinks (lime cordials) and cooking.",4,65,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Passionfruit,3.00,"The most popular variety is the purple passionfruit about the size of a chicken egg. It has a highly fragrant, sweet, but slightly tart, tasting fruit that can be spooned out and eaten fresh or added to fruit salad, pavlova, and it makes a very popular drink, ice cream and sorbets and a flavouring for all kinds of desserts.",4,43,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Nectarine,1.25,"The nectarine flesh is rich, sweet and juicy and is well suited for eating fresh and for using in ice cream, pies and fruit salads. Colour ranges from silvery white or yellowy orange to pinkish red. The white-fleshed varieties are considered the best and usually the most expensive. Nectarines are often described as a cross between a peach and a plum, but nectarines are actually a variety of smooth-skinned peach.",4,3,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
+Mangosteen,1.15,"Contrary to its name, the mangosteen doesn't resemble or taste like the mango. It resemble an apple, having a short stem and four thick leaf-like bracts which form a rosette encasing the brownish-purple fruit.",4,7,http://www.asuntospublicos.org/upload/2017/12/21/the-gallery-for-simple-fruit-bowl-painting-fruit-bowl-paintings-l-d1f74fb586adeb14.jpg
diff --git a/db/ProductSeed2.csv b/db/ProductSeed2.csv
new file mode 100644
index 0000000000..cb942a2e85
--- /dev/null
+++ b/db/ProductSeed2.csv
@@ -0,0 +1,21 @@
+Product,price,description,user_id,quantity ,category,image
+Vimto,1.00,"It contains the juice of grapes raspberries and blackcurrants (in a 3% concentration) flavoured with herbs and spices.",2,30,Pome,http://www.poukouwholesale.com/thumbnail.asp?file=assets/images/saudivimtosyrup.jpg&maxx=300&maxy=0
+Banana,0.25,"Bananas are a tropical fruit that grows on a plant that reaches a height of 10 to 25 feet. The bananas are supported on a large heavy stem and grow with the individual stems facing downward. Bananas are always picked green and ripen on the way to market. When ripe bananas lose their green color and begin to get small brown spots on their yellow skin.",2,50,-,https://images.unsplash.com/photo-1513098872174-2af8a3c9238a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c95c19aaa44d82f1aceaa501e6d529c2&auto=format&fit=crop&w=1650&q=80
+Rainier Cherries,2.99,"Rainier is a cultivar cherry or a plant selected for desirable characteristics that can be maintained by propagation. It was developed in 1952 at Washington State University by Harold Fogle, and named after Mount Rainier. It is a cross between the Bing and Van cultivars. Rainiers are sweet cherries with a thin skin and thick creamy-yellow flesh. The cherries are very sensitive to temperature, wind, and rain. About 1/3 of a Rainier cherry orchard's crop is eaten by birds, which accounts for their higher prices. Select only firm and unblemished rainier cherries.",2,30,Bunches,http://blog.thefruitcompany.com/blog2014/wp-content/uploads/2016/06/tfc_chocolate_covered_cherries_-3.jpg
+Green Grapes,2.00,"A great energy source because of their natural fruit sugar content",2,300,Bunches,https://images.unsplash.com/photo-1515779122185-2390ccdf060b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=4d9510f689e293cb68177431cacc57e4&auto=format&fit=crop&w=1650&q=80
+Grapefruit,1.00,"One of the largest citrus fruit, grapefruits are a cross between the pomelo and the shaddock. High in vitamin C, grapefruits are best eaten raw, a traditional breakfast fruit. The best way to eat is to cut them in half and scoop out the flesh with a spoon.",2,10,-,https://images.unsplash.com/photo-1512580344356-fd2f966fbeae?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=7045f4d90f98f03cf4f6e13cd97b3c3e&auto=format&fit=crop&w=800&q=60
+Kumquat,0.50,"The name means ""golden orange"" in Chinese. Kumquats are often preserved in sweet syrup and used for marmalade and garnishes, but fresh ones are delicious in fruit salads or for eating just as they are.",2,80,-,https://www.potagercity.fr/images/kumquat-58bd74c1857ff.png
+Lemon,0.25,"Rarely eaten on its own, lemons are an indispensable ingredient in the kitchen. Lemon juice can be used instead of vinegar in sauces, for seasoning in vinaigrette and as instant dressing for fish and shellfish. The best way to store lemon is in the vegetable crisper in the fridge you can put lemons in fruit bowl for a shorter, check them often - if one starts to spoil, the rest will quickly follow.",2,15,Citrus,https://images.unsplash.com/photo-1432457990754-c8b5f21448de?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=b011e9b1e7a4fcbcfd9aedff10807ac4&auto=format&fit=crop&w=800&q=60
+Pineapple,3.00,"Derived from the Spanish word 'pina' meaning pine cone. Pineapples have a juicy, sweet-but sometimes slightly tart-fragrant flavour. They are best eaten fresh, serve pineapple flesh in slices, wedges or chunks. It is also available in cans, dried and glace. A good source of vitamin C.",2,14,Pome,https://images.unsplash.com/photo-1459541708374-6fe9eea39a29?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=475e22522ecbb80d3abfa1ca7a37eaf7&auto=format&fit=crop&w=800&q=60
+Plums,1.25,"Plums contain more antioxidant than any other fruit. Plums are delicate so make sure that the one you buy are unblemished, and they should be plump and firm. The small sugar plum is dried to make prunes. Delicious stewed, plums are also ideal for making chutneys.",2,16,Pits,https://images.unsplash.com/photo-1447175025301-707b39e9146f?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e2c1cb369a8266bb5b8324c41662c57b&auto=format&fit=crop&w=800&q=60
+Star Apple,1.15,"The star apple fruits are green to purple with a smooth skin. When sliced horizontally the flesh is translucent white with the seeds forming a star shape. It is best eaten ripe, scooped straight from the skin. It is ripe when soft and should be eaten immediately, but it is still alright to refrigerate for a few days.",2,45,-,http://i19.photobucket.com/albums/b172/Bassgarden/Trinidad/starapple2.jpg
+Strawberry,2.78,"A unique fruit, the seeds grow around the outside of the fruit rather than inside it. Comes in many different sizes, colours and shapes, ranging from cone-like, to oval, or heart-shaped. Best to eat on their own or with natural yoghurt. Use strawberries in desserts, fruit salads, preserves, or in milkshakes.",3,26,Edible Skin,https://images.unsplash.com/photo-1495548054858-0e78bb72869e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c5e64ec548ca2eae10a301e3cc704153&auto=format&fit=crop&w=800&q=60
+Watermelon ,5.00,"The high water content of watermelons means that they are low in calories. They contain some vitamins B and C. Watermelon is excellent juiced, chopped up into a fruit salad, or just eaten in chunky slices.",3,43,-,https://images.unsplash.com/photo-1501648399952-70289b3a1b1d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c0508b75adf548daa69fbec8cbd0335c&auto=format&fit=crop&w=686&q=80
+Tamarillo,1.65,"these are related to tomatoes and sometimes called ""tree tomatoes."" They are the size of an egg tomato, with dark red skin. The fruit has a strong, sweet flavour that makes it suitable for both sweet or savoury dishes. It can also be used in jams, chutneys, and sorbets.",3,12,-,http://hatgiongnga.net/wp-content/uploads/2017/03/hat-giong-ca-chua-than-go-tamarillo-480x412.jpg
+Rambutan,3.40,"The rambutan fruit grows in clusters, with a deep crimson outer skin. The flesh is translucent, and the pale seed is edible when young. Related to lychees and are sometimes known as ""hairy lychees"".(about 5cm / 2inches in diameter) and look quite different but have a similar texture. They can be added to salads, made into jams or jellies, but they are best eaten on their own.",3,3,-,https://res.cloudinary.com/twenty20/private_images/t_watermark-criss-cross-10/v1449827258000/photosp/a5555e4a-c0f8-4103-9a45-379580ff31d9/stock-photo-flower-food-sweet-food-berry-fruit-freshness-red-strawberry-bowl-a5555e4a-c0f8-4103-9a45-379580ff31d9.jpg
+Peach,2.25,"Or pawpaw, a large tropical fruit whose ripe flesh can be juicy, creamy, orange-red, or yellow. In the centre is a mass of large peppery black seeds, which are edible and sometimes crushed and used as a spice. Ripe papaya is eaten as a breakfast fruit or as a dessert. It can also be pureed for ice cream, sorbets and iced drinks.",3,9,Pits,https://images.unsplash.com/photo-1518518886629-0b9000299b8b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=eb1910975e5c3eae69b31ea78a1828bc&auto=format&fit=crop&w=800&q=60
+Fig,0.50,"Figs are oval or pear-shaped and can be eaten fresh or dried. They are well known for their laxative and digestive properties. Their high, natural sugar content makes them the sweetest of all fruits. The flavour varies, depending on where they were grown and how ripe they are.",4,24,Edible Skin,https://images.unsplash.com/photo-1506851141243-46bb87f2576c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=31de7e8f4f3709fda8ea9ef46d9cdfa2&auto=format&fit=crop&w=800&q=60
+Lime,0.25,"Limes are only green because they are picked unripe but if left to ripen they turn yellow. Limes can be used like lemons but as juice, it is more acidic, so usually less is needed. To make the juice flow more, you can microwave the limes for 2-3 seconds before squeezing. Mostly used in drinks (lime cordials) and cooking.",4,65,Citrus,https://images.unsplash.com/photo-1519144892250-cd5cd895026b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6174fc5bfcfe0df7e56c2158a11a351c&auto=format&fit=crop&w=1650&q=80
+Passionfruit,3.00,"The most popular variety is the purple passionfruit about the size of a chicken egg. It has a highly fragrant, sweet, but slightly tart, tasting fruit that can be spooned out and eaten fresh or added to fruit salad, pavlova, and it makes a very popular drink, ice cream and sorbets and a flavouring for all kinds of desserts.",4,43,-,https://images.unsplash.com/photo-1502009285422-74e42ac2fd68?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3a2e9d5afe4225baf6216831378808bd&auto=format&fit=crop&w=800&q=60
+Nectarine,1.25,"The nectarine flesh is rich, sweet and juicy and is well suited for eating fresh and for using in ice cream, pies and fruit salads. Colour ranges from silvery white or yellowy orange to pinkish red. The white-fleshed varieties are considered the best and usually the most expensive. Nectarines are often described as a cross between a peach and a plum, but nectarines are actually a variety of smooth-skinned peach.",4,2,-,https://images.unsplash.com/photo-1504577089374-ed8ee92673bb?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=945226a39bab33580bdba05c4e172835&auto=format&fit=crop&w=800&q=60
+Mangosteen,1.15,"Contrary to its name, the mangosteen doesn't resemble or taste like the mango. It resemble an apple, having a short stem and four thick leaf-like bracts which form a rosette encasing the brownish-purple fruit.",4,7,-,https://res.cloudinary.com/twenty20/private_images/t_watermark-criss-cross-10/v1490628182000/photosp/aad591a8-10b4-499b-b4c5-c43b76e928b2/stock-photo-food-purple-delicious-fresh-overhead-fresh-fruits-mangosteen-flatlay-flat-lay-aad591a8-10b4-499b-b4c5-c43b76e928b2.jpg
diff --git a/db/ReviewsSeed.csv b/db/ReviewsSeed.csv
new file mode 100644
index 0000000000..b69170b1de
--- /dev/null
+++ b/db/ReviewsSeed.csv
@@ -0,0 +1,14 @@
+product_id,rating,text_review
+1,5,"I've heard that people put this on their fruit but I prefer to mix it as a drink"
+1,1,"Ehh... You really shouldn't pour this on your fruit."
+2,4,"Put these in banana bread, you should too!"
+3,5,"SOOO yummy"
+16,2,
+20,5,
+9,2,
+9,5,
+8,3,
+11,1,
+12,5,"The perfect ripeness"
+19,4,"I like fruit"
+15,5,
diff --git a/db/migrate/20180419010045_create_users.rb b/db/migrate/20180419010045_create_users.rb
new file mode 100644
index 0000000000..90a2bbdb9a
--- /dev/null
+++ b/db/migrate/20180419010045_create_users.rb
@@ -0,0 +1,12 @@
+class CreateUsers < ActiveRecord::Migration[5.1]
+ def change
+ create_table :users do |t|
+ t.string :name
+ t.string :email
+ t.integer :uid
+ t.string :provider
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419010108_create_products.rb b/db/migrate/20180419010108_create_products.rb
new file mode 100644
index 0000000000..ecaeb35719
--- /dev/null
+++ b/db/migrate/20180419010108_create_products.rb
@@ -0,0 +1,11 @@
+class CreateProducts < ActiveRecord::Migration[5.1]
+ def change
+ create_table :products do |t|
+ t.string :name
+ t.float :price
+ t.string :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419010200_create_carts.rb b/db/migrate/20180419010200_create_carts.rb
new file mode 100644
index 0000000000..5004883d30
--- /dev/null
+++ b/db/migrate/20180419010200_create_carts.rb
@@ -0,0 +1,10 @@
+class CreateCarts < ActiveRecord::Migration[5.1]
+ def change
+ create_table :carts do |t|
+ t.integer :user_id
+ t.string :status
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419010419_create_categories.rb b/db/migrate/20180419010419_create_categories.rb
new file mode 100644
index 0000000000..5bef4913b8
--- /dev/null
+++ b/db/migrate/20180419010419_create_categories.rb
@@ -0,0 +1,9 @@
+class CreateCategories < ActiveRecord::Migration[5.1]
+ def change
+ create_table :categories do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419035721_create_order_items.rb b/db/migrate/20180419035721_create_order_items.rb
new file mode 100644
index 0000000000..1db1bd91fe
--- /dev/null
+++ b/db/migrate/20180419035721_create_order_items.rb
@@ -0,0 +1,11 @@
+class CreateOrderItems < ActiveRecord::Migration[5.1]
+ def change
+ create_table :order_items do |t|
+ t.integer :order_id
+ t.integer :product_id
+ t.integer :quantity
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419155031_create_reviews.rb b/db/migrate/20180419155031_create_reviews.rb
new file mode 100644
index 0000000000..37e7773acc
--- /dev/null
+++ b/db/migrate/20180419155031_create_reviews.rb
@@ -0,0 +1,11 @@
+class CreateReviews < ActiveRecord::Migration[5.1]
+ def change
+ create_table :reviews do |t|
+ t.integer :product_id
+ t.integer :rating
+ t.string :text_review
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180419210802_change_carts_to_orders.rb b/db/migrate/20180419210802_change_carts_to_orders.rb
new file mode 100644
index 0000000000..2dd331e6b7
--- /dev/null
+++ b/db/migrate/20180419210802_change_carts_to_orders.rb
@@ -0,0 +1,5 @@
+class ChangeCartsToOrders < ActiveRecord::Migration[5.1]
+ def change
+ rename_table :carts, :orders
+ end
+end
diff --git a/db/migrate/20180419212546_add_category_id_to_products.rb b/db/migrate/20180419212546_add_category_id_to_products.rb
new file mode 100644
index 0000000000..a0346911fe
--- /dev/null
+++ b/db/migrate/20180419212546_add_category_id_to_products.rb
@@ -0,0 +1,5 @@
+class AddCategoryIdToProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :category_id, :integer
+ end
+end
diff --git a/db/migrate/20180419220917_add_order_status_to_order_item.rb b/db/migrate/20180419220917_add_order_status_to_order_item.rb
new file mode 100644
index 0000000000..6f00645d35
--- /dev/null
+++ b/db/migrate/20180419220917_add_order_status_to_order_item.rb
@@ -0,0 +1,5 @@
+class AddOrderStatusToOrderItem < ActiveRecord::Migration[5.1]
+ def change
+ add_column :order_items, :status, :string
+ end
+end
diff --git a/db/migrate/20180419221855_add_imageto_products.rb b/db/migrate/20180419221855_add_imageto_products.rb
new file mode 100644
index 0000000000..3a33167f4d
--- /dev/null
+++ b/db/migrate/20180419221855_add_imageto_products.rb
@@ -0,0 +1,5 @@
+class AddImagetoProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :image, :string
+ end
+end
diff --git a/db/migrate/20180419232140_add_user_i_dto_products.rb b/db/migrate/20180419232140_add_user_i_dto_products.rb
new file mode 100644
index 0000000000..bde24efa31
--- /dev/null
+++ b/db/migrate/20180419232140_add_user_i_dto_products.rb
@@ -0,0 +1,5 @@
+class AddUserIDtoProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :user_id, :integer
+ end
+end
diff --git a/db/migrate/20180419232327_add_quantityto_products.rb b/db/migrate/20180419232327_add_quantityto_products.rb
new file mode 100644
index 0000000000..9e92707732
--- /dev/null
+++ b/db/migrate/20180419232327_add_quantityto_products.rb
@@ -0,0 +1,5 @@
+class AddQuantitytoProducts < ActiveRecord::Migration[5.1]
+ def change
+ add_column :products, :quantity, :integer
+ end
+end
diff --git a/db/migrate/20180420005014_remove_columns.rb b/db/migrate/20180420005014_remove_columns.rb
new file mode 100644
index 0000000000..bd3418a505
--- /dev/null
+++ b/db/migrate/20180420005014_remove_columns.rb
@@ -0,0 +1,5 @@
+class RemoveColumns < ActiveRecord::Migration[5.1]
+ def change
+ remove_column :products, :category_id
+ end
+end
diff --git a/db/migrate/20180420174143_add_more_columns_to_order.rb b/db/migrate/20180420174143_add_more_columns_to_order.rb
new file mode 100644
index 0000000000..5b95066487
--- /dev/null
+++ b/db/migrate/20180420174143_add_more_columns_to_order.rb
@@ -0,0 +1,14 @@
+class AddMoreColumnsToOrder < ActiveRecord::Migration[5.1]
+ def change
+ add_column :orders, :email, :string
+ add_column :orders, :street, :string
+ add_column :orders, :city, :string
+ add_column :orders, :state, :string
+ add_column :orders, :zip, :int
+ add_column :orders, :card_number, :int
+ add_column :orders, :date_year, :int
+ add_column :orders, :date_month, :int
+ add_column :orders, :date_day, :int
+ add_column :orders, :cvv, :int
+ end
+end
diff --git a/db/migrate/20180420180008_add_nameto_order.rb b/db/migrate/20180420180008_add_nameto_order.rb
new file mode 100644
index 0000000000..9a9e0dc27c
--- /dev/null
+++ b/db/migrate/20180420180008_add_nameto_order.rb
@@ -0,0 +1,5 @@
+class AddNametoOrder < ActiveRecord::Migration[5.1]
+ def change
+ add_column :orders, :name, :string
+ end
+end
diff --git a/db/migrate/20180420212624_change_int_to_bigint.rb b/db/migrate/20180420212624_change_int_to_bigint.rb
new file mode 100644
index 0000000000..f2ae1d8170
--- /dev/null
+++ b/db/migrate/20180420212624_change_int_to_bigint.rb
@@ -0,0 +1,5 @@
+class ChangeIntToBigint < ActiveRecord::Migration[5.1]
+ def change
+ change_column :orders, :card_number, :bigint
+ end
+end
diff --git a/db/migrate/20180422051721_create_categories_products.rb b/db/migrate/20180422051721_create_categories_products.rb
new file mode 100644
index 0000000000..9eb0176ffb
--- /dev/null
+++ b/db/migrate/20180422051721_create_categories_products.rb
@@ -0,0 +1,8 @@
+class CreateCategoriesProducts < ActiveRecord::Migration[5.1]
+ def change
+ create_join_table :categories, :products do |t|
+ t.belongs_to :category, index: true
+ t.belongs_to :product, index: true
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000000..b66024cb16
--- /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: 20180423212509) 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", id: false, 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 "order_items", force: :cascade do |t|
+ t.integer "order_id"
+ t.integer "product_id"
+ t.integer "quantity"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "status"
+ end
+
+ create_table "orders", force: :cascade do |t|
+ t.integer "user_id"
+ t.string "status"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "email"
+ t.string "street"
+ t.string "city"
+ t.string "state"
+ t.integer "zip"
+ t.bigint "card_number"
+ t.integer "date_year"
+ t.integer "date_month"
+ t.integer "date_day"
+ t.integer "cvv"
+ t.string "name"
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "name"
+ t.float "price"
+ t.string "description"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "image"
+ t.integer "user_id"
+ t.integer "quantity"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.integer "product_id"
+ t.integer "rating"
+ t.string "text_review"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.string "email"
+ t.integer "uid"
+ t.string "provider"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000000..71111e35a2
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,151 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
+
+require 'csv'
+
+USER_FILE = Rails.root.join('db', 'MerchantSeed.csv')
+puts "Loading user data from #{USER_FILE}"
+
+user_failures = []
+CSV.foreach(USER_FILE, :headers => true) do |row|
+ user = User.new
+ user.name = row['name']
+ user.email = row['email']
+ 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
+
+PRODUCT_FILE = Rails.root.join('db', 'ProductSeed2.csv')
+puts "Loading product data from #{PRODUCT_FILE}"
+
+product_failures = []
+CSV.foreach(PRODUCT_FILE, :headers => true) do |row|
+ product = Product.new
+ product.name = row['Product']
+ product.price = row['price']
+ product.description = row['description']
+ product.image = row['image']
+ product.user_id = row['user_id']
+ product.quantity = rand(1..50)
+
+ # add category to product
+ if row['category'] != "-"
+ category = Category.find_by(name: row['category'])
+ if category
+ product.categories << category
+ else
+ category = Category.new
+ category.name = row['category']
+ category.save
+ puts "Category created: #{category.inspect}"
+ product.categories << category
+ end
+ end
+
+ successful = product.save
+ if !successful
+ product_failures << product
+ puts "Failed to save product: #{product.inspect}"
+ else
+ puts "Created product: #{product.inspect}"
+ end
+end
+
+# CATEGORY_FILE = Rails.root.join('db', 'Categoryseed.csv')
+# puts "Loading category data from #{CATEGORY_FILE}"
+#
+# category_failures = []
+# CSV.foreach(CATEGORY_FILE, :headers => true) do |row|
+# category = Category.new
+# category.name = row['Category']
+#
+# successful = category.save
+# if !successful
+# category_failures << category
+# puts "Failed to save category: #{category.inspect}"
+# else
+# puts "Created category: #{category.inspect}"
+# end
+# end
+
+REVIEW_FILE = Rails.root.join('db', 'ReviewsSeed.csv')
+puts "Loading review data from #{REVIEW_FILE}"
+
+review_failures = []
+CSV.foreach(REVIEW_FILE, :headers => true) do |row|
+ review = Review.new
+ review.product_id = row['product_id']
+ review.rating = row['rating']
+ review.text_review = row['text_review']
+
+ successful = review.save
+ puts successful
+ if !successful
+ review_failures << review
+ puts "Failed to save review: #{review.inspect}"
+ else
+ puts "Created review: #{review.inspect}"
+ end
+end
+
+ORDER_FILE = Rails.root.join('db', 'OrdersSeed.csv')
+puts "Loading order data from #{ORDER_FILE}"
+
+order_failures = []
+CSV.foreach(ORDER_FILE, :headers => true) do |row|
+ order = Order.new
+ order.user_id = row['user_id']
+ order.name = row['name']
+ order.card_number = row['card_number']
+ order.email = row['email']
+ order.street = row['street']
+ order.city = row['city']
+ order.state = row['state']
+ order.zip = row['zip']
+ order.date_year = row['date_year']
+ order.date_month = row['date_month']
+ order.date_day = row['date_day']
+ order.cvv = row['cvv']
+ order.status = row['status']
+
+ successful = order.save
+ if !successful
+ order_failures << order
+ puts "Failed to save order: #{order.inspect}"
+ else
+ puts "Created order: #{order.inspect}"
+ end
+end
+
+ORDER_ITEM_FILE = Rails.root.join('db', 'OrderItemsSeed.csv')
+puts "Loading order_item data from #{ORDER_ITEM_FILE}"
+
+order_item_failures = []
+CSV.foreach(ORDER_ITEM_FILE, :headers => true) do |row|
+ order_item = OrderItem.new
+ order_item.order_id = row['order_id']
+ order_item.product_id = row['product_id']
+ order_item.quantity = row['quantity']
+ order_item.status = row['status']
+
+ successful = order_item.save
+ if !successful
+ order_item_failures << order_item
+ puts "Failed to save order_item: #{order_item.inspect}"
+ else
+ puts "Created order_item: #{order_item.inspect}"
+ end
+end
diff --git a/feedback.md b/feedback.md
index 5950f49c8e..178629cb42 100644
--- a/feedback.md
+++ b/feedback.md
@@ -14,7 +14,7 @@ oAuth used for User authentication |
Functionality restricted based on user roles |
Products can be added and removed from cart |
Users can view past orders |
-Merchants can add, edit and view their products |
+users can add, edit and view their products |
Errors are reported to the user |
**Order Functionality** |
Reduces products' inventory |
diff --git a/fruetsy b/fruetsy
new file mode 160000
index 0000000000..dda08ed370
--- /dev/null
+++ b/fruetsy
@@ -0,0 +1 @@
+Subproject commit dda08ed37097c79a4e1f24f4c6e17658cc171778
diff --git a/lib/assets/.keep b/lib/assets/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000..f874acf437
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "betsy",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/public/404.html b/public/404.html
new file mode 100644
index 0000000000..2be3af26fc
--- /dev/null
+++ b/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/422.html b/public/422.html
new file mode 100644
index 0000000000..c08eac0d1d
--- /dev/null
+++ b/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/500.html b/public/500.html
new file mode 100644
index 0000000000..78a030af22
--- /dev/null
+++ b/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000000..37b576a4a0
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
new file mode 100644
index 0000000000..d19212abd5
--- /dev/null
+++ b/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
+end
diff --git a/test/controllers/.keep b/test/controllers/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb
new file mode 100644
index 0000000000..1abf2294bb
--- /dev/null
+++ b/test/controllers/categories_controller_test.rb
@@ -0,0 +1,77 @@
+require "test_helper"
+
+describe CategoriesController do
+ let(:cherries) { products(:cherries) }
+ let(:valid_category) { categories(:summer) }
+
+ describe "index" do
+ it "succeeds with multiple categories" do
+ get categories_path
+ must_respond_with :success
+ end
+
+ it "succeeds with no categories " do
+ categories = Category.all
+ categories.each do |cat|
+ cat.destroy
+ end
+ get categories_path
+ must_respond_with :success
+ end
+
+ it "succeeds with some categories " do
+ categories = Category.where(name: 'summer fruit')
+ categories.each do |cat|
+ cat.destroy
+ end
+ get categories_path
+ must_respond_with :success
+ end
+ end
+
+ describe "show" do
+ it "succeeds for a valid category" do
+ get category_path(valid_category.id)
+ must_respond_with :success
+ end
+
+ it "redirects to root path for invalid id" do
+ get category_path(999)
+ must_redirect_to root_path
+ end
+ end
+
+ describe "new" do
+ it "succeeds" do
+ get new_category_path
+ must_respond_with :success
+ end
+ end
+
+ describe "create" do
+ it "succeeds with valid data" do
+ proc {
+ post categories_path, params: {
+ category: {
+ name: "new category"
+ }
+ }
+ }.must_change 'Category.count', 1
+
+ must_respond_with :found
+ must_redirect_to new_product_path
+ end
+
+ it "fails with invalid data" do
+ proc {
+ post categories_path, params: {
+ category: {
+ name: nil
+ }
+ }
+ }.must_change 'Category.count', 0
+ must_respond_with :bad_request
+ 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..90051defee
--- /dev/null
+++ b/test/controllers/order_items_controller_test.rb
@@ -0,0 +1,69 @@
+require "test_helper"
+
+describe OrderItemsController do
+ let(:user) { users(:beyonce) }
+
+ describe "index" do
+ it "redirects to root path if user is not a merchant" do
+ user = nil
+ get order_items_path
+ must_redirect_to root_path
+ end
+
+ it "succeeds with a merchant" do
+ login(user)
+ get order_items_path
+ must_respond_with :success
+ end
+ end
+
+ describe "edit" do
+ it "succeeds with a valid order_item" do
+ login(users(:beyonce))
+ get edit_order_item_path(order_items(:fruit_salad), params: {
+ :id => order_items(:fruit_salad).id
+ })
+ must_respond_with :success
+ end
+
+ it "fails with an invalid order_item" do
+ invalid_id = 9999
+ get edit_order_item_path(invalid_id), params: {
+ :id => invalid_id
+ }
+ must_redirect_to root_path
+ end
+ end
+
+ describe "update" do
+ it "successfully updates an order_item with valid data and logged in user" do
+ item = order_items(:fruit_salad)
+ new_status = "completed"
+
+ login(user)
+ patch order_item_path(item.id), params: {
+ :id => item.id,
+ order_item: {
+ status: new_status
+ }
+ }
+
+ must_redirect_to user_order_items_path(user.id)
+ end
+
+ it "redirects to the root path if the order_item id is invalid" do
+ invalid_id = 9999
+
+ login(user)
+ patch order_item_path(invalid_id), params: {
+ :id => invalid_id,
+ order_item: {
+ status: "completed"
+ }
+ }
+
+ must_redirect_to root_path
+ 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..5a7f81c80c
--- /dev/null
+++ b/test/controllers/orders_controller_test.rb
@@ -0,0 +1,217 @@
+require "test_helper"
+require 'pry'
+describe OrdersController do
+ before do
+ @test_user = users(:beyonce)
+ @test_order = orders(:cart1)
+ @test_product = products(:cherries)
+ end
+
+ describe "index" do
+ it "should get index" do
+ get orders_path
+ value(response).must_be :success?
+ end
+ end
+
+ describe "new" do
+ it "should get new order for logged in user" do
+ user = users(:beyonce)
+ login(user)
+ get new_order_path
+ value(response).must_be :success?
+ end
+
+ it "should get new order for not logged in guest" do
+ user = users(:beyonce)
+ login(user)
+ delete logout_path
+ get new_order_path
+ value(response).must_be :success?
+ end
+ end
+
+ describe "create" do
+ it "should get create" do
+ get new_order_path(@test_user.id)
+ value(response).must_be :success?
+ end
+
+ it "valid data should create a new order for logged in user" do
+ user = users(:beyonce)
+ login(user)
+
+ post add_to_order_path, params: { :product_id => products(:cherries).id,
+ :quantity => 2}
+
+ order_count = Order.count
+
+ post orders_path, params: { order:
+ { user: user ,
+ status: "paid" ,
+ name: user.name ,
+ card_number: 1234123412341234 ,
+ email: user.email ,
+ street: "malden" ,
+ city: "seattle" ,
+ state: "wa" ,
+ zip: 12345 ,
+ date_year: 19 ,
+ date_month: 5 ,
+ date_day: 3 ,
+ cvv: 123
+ }
+ }
+ must_respond_with :redirect
+
+ must_redirect_to order_details_path(Order.last.id)
+
+ Order.count.must_equal (order_count + 1)
+ end
+
+ it "valid data should create a new order when no user is logged in" do
+ user = User.first
+ user.id = 1
+ user.save
+ post add_to_order_path, params: { :product_id => products(:cherries).id,
+ :quantity => 2}
+ order_count = Order.count
+ post orders_path, params: { order:
+ { user: user ,
+ status: "paid" ,
+ name: user.name ,
+ card_number: 1234123412341234 ,
+ email: user.email ,
+ street: "malden" ,
+ city: "seattle" ,
+ state: "wa" ,
+ zip: 12345 ,
+ date_year: 19 ,
+ date_month: 5 ,
+ date_day: 3 ,
+ cvv: 123
+ }
+ }
+ must_respond_with :redirect
+ must_redirect_to order_details_path(Order.last.id)
+ Order.count.must_equal (order_count + 1)
+ end
+
+ it "invalid data should redirect to order new page if user logged in" do
+ user = users(:beyonce)
+ login(user)
+ post add_to_order_path, params: { :product_id => products(:cherries).id,
+ :quantity => 2}
+ order_count = Order.count
+ post orders_path, params: { order:
+ { user: user ,
+ status: "paid" ,
+ name: user.name ,
+ card_number: nil ,
+ email: user.email ,
+ street: "malden" ,
+ city: "seattle" ,
+ state: "wa" ,
+ zip: 12345 ,
+ date_year: 19 ,
+ date_month: 5 ,
+ date_day: 3 ,
+ cvv: 123
+ }
+ }
+ must_respond_with :bad_request
+ Order.count.must_equal order_count
+ end
+
+ it "invalid data should redirect to order new page if no user logged in" do
+ user = User.first
+ user.id = 1
+ user.save
+ post add_to_order_path, params: { :product_id => products(:cherries).id,
+ :quantity => 2}
+ order_count = Order.count
+ post orders_path, params: { order:
+ { user: user ,
+ status: "paid" ,
+ name: user.name ,
+ card_number: nil ,
+ email: user.email ,
+ street: "malden" ,
+ city: "seattle" ,
+ state: "wa" ,
+ zip: 12345 ,
+ date_year: 19 ,
+ date_month: 5 ,
+ date_day: 3 ,
+ cvv: 123
+ }
+ }
+ must_respond_with :bad_request
+ Order.count.must_equal order_count
+ end
+ end
+
+ describe "show" do
+ it "should get show order confirmation page for logged in users" do
+
+ test_user_hash =
+ {
+ :name => @test_user.name,
+ :email => @test_user.email,
+ :uid => @test_user.uid,
+ :provider => @test_user.provider
+ }
+ user = User.new(test_user_hash)
+ user.save
+
+
+ product = products(:watermelon)
+ product.user_id = user.id
+ product.save
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+
+ post add_to_order_path, params: { :product_id => products(:cherries).id,
+ :quantity => 2}
+
+ get order_details_path(@test_order.id), params: { :id => @test_order.id }
+ value(response).must_be :success?
+ end
+
+ it "should show order page with no order_items if no order_items in order to show" do
+ test_user_hash =
+ {
+ :name => @test_user.name,
+ :email => @test_user.email,
+ :uid => @test_user.uid,
+ :provider => @test_user.provider
+ }
+ user = User.new(test_user_hash)
+ user.save
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+
+ get order_details_path(@test_order.id)
+ value(response).must_be :success?
+ end
+ end
+
+ describe "merchant_order_show" do
+ it "should get order show page for merchants order_items and their order details" do
+ test_user_hash =
+ {
+ :name => @test_user.name,
+ :email => @test_user.email,
+ :uid => @test_user.uid,
+ :provider => @test_user.provider
+ }
+ user = User.new(test_user_hash)
+ user.save
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+ get sold_order_path(@test_order.id), params: { :id => @test_user.id}
+ value(response).must_be :success?
+ end
+ end
+end
diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb
new file mode 100644
index 0000000000..22d8e58e7f
--- /dev/null
+++ b/test/controllers/products_controller_test.rb
@@ -0,0 +1,218 @@
+require "test_helper"
+
+describe ProductsController do
+
+ describe "index" do
+
+ it "succeeds with multiple products" do
+ get products_path
+ must_respond_with :success
+ end
+
+ it "succeeds with no products " do
+ products = Product.all
+ products.each do |prod|
+ prod.destroy
+ end
+ get products_path
+ must_respond_with :success
+
+ end
+
+ end
+
+ describe 'root' do
+
+ it "succeeds" do
+ get root_path
+ must_respond_with :success
+ end
+
+ it "succeeds with no products" do
+ products = Product.all
+ products.each do |prod|
+ prod.reviews.destroy
+ prod.destroy
+ end
+ get root_path
+ must_respond_with :success
+ end
+ end
+
+ describe 'new' do
+ it "succeeds with a logged in user" do
+ user = users(:beyonce)
+ login(user)
+
+ get new_product_path
+ must_respond_with :success
+ end
+
+ it "redirects without a user" do
+ get new_product_path
+ must_respond_with :redirect
+ must_redirect_to root_path
+ end
+ end
+
+ describe 'create' do
+ it "creates a product with valid data for a real category" do
+ user = users(:beyonce)
+ login(user)
+
+ proc {
+ post products_path, params: {
+ product: {
+ name: 'pear',
+ price: 4.0,
+ description: 'peary',
+ image: 'image',
+ user: user,
+ quantity: 5
+ }
+ }
+ }.must_change 'Product.count', 1
+
+ must_respond_with :redirect
+ must_redirect_to user_products_url(user.id)
+ end
+
+ it "Does not update the DB for bogus data" do
+ existing_user = users(:beyonce)
+
+ login(existing_user)
+
+ proc {
+ post products_path, params: {
+ product: {
+ name: nil,
+ price: 4.0,
+ description: 'peary',
+ image: 'image',
+ user: existing_user,
+ quantity: nil
+ }
+ }
+ }.must_change 'Product.count', 0
+
+ end
+ end
+
+ describe "edit" do
+ it "succeeds for a logged in user with their own product" do
+ user = users(:beyonce)
+ product = products(:cherries)
+
+ login(user)
+
+ get edit_product_path(product.id)
+ must_respond_with :success
+
+ end
+
+ it "redirects someone without permissions to edit a product" do
+
+ product = products(:cherries)
+ get edit_product_path(product.id)
+
+ must_respond_with :redirect
+ must_redirect_to root_path
+ end
+
+ it "redirects to the root path if the product does not exist" do
+ user = users(:beyonce)
+
+ login(user)
+
+ get edit_product_path(800)
+ must_respond_with :redirect
+ must_redirect_to root_path
+ end
+ end
+
+ describe "update" do
+ it "succeeds for valid data and a logged on user with permissions" do
+ user = users(:beyonce)
+ login(user)
+
+ product = products(:cherries)
+
+ patch product_path(product.id), params: {
+ product: {
+ name: "yellow cherries",
+ price: 3.0,
+ description: '1kg ranier cherries',
+ image: 'image_url',
+ user: user,
+ quantity: 4
+ }
+ }
+
+ product.name.must_equal "yellow cherries"
+ must_respond_with :redirect
+ must_redirect_to product_path(product.id)
+ end
+
+
+ it "redirects to the product index if product does not exist" do
+ user = users(:beyonce)
+ product = products(:cherries)
+
+ login(user)
+
+ patch product_path(789)
+ must_respond_with :redirect
+ must_redirect_to products_path
+
+ end
+ end
+
+ describe "show" do
+ it "succeeds for an exisiting work" do
+ product = products(:cherries)
+
+ get product_path(product.id)
+ must_respond_with :success
+ end
+
+ it "redirects to products path if a product does not exist" do
+ get product_path(984)
+ must_respond_with :redirect
+ must_redirect_to products_path
+ end
+ end
+
+ describe "destroy" do
+ it "succeeds for an existing product for user with permissions" do
+ user = users(:beyonce)
+ product = products(:cherries)
+ login(user)
+
+ delete product_path(product.id)
+ must_respond_with :redirect
+ must_redirect_to user_products_path(user.id)
+ end
+
+ it "must delete product from database if successful" do
+ user = users(:beyonce)
+ product = products(:cherries)
+ login(user)
+
+ count = Product.count
+ delete product_path(product.id)
+
+ Product.count.must_equal count - 1
+ end
+
+ it "redirects for a nonexistant product id" do
+ user = users(:beyonce)
+ product = products(:cherries)
+ login(user)
+
+ delete product_path(789)
+ must_respond_with :redirect
+ must_redirect_to products_path
+ 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..fe2edd30c1
--- /dev/null
+++ b/test/controllers/reviews_controller_test.rb
@@ -0,0 +1,51 @@
+require "test_helper"
+
+describe ReviewsController do
+ let(:cherries) { products(:cherries) }
+ let(:first_review) { reviews(:rating1) }
+
+ describe "new" do
+ it "succeeds with a valid product" do
+ # get the path of the controller method
+ get new_product_review_path(first_review.product.id)
+ must_respond_with :success
+ end
+
+
+ # is this test necessary??
+ # it "fails when a review does not a product" do
+ # cherries = nil
+ # get new_product_review_path(cherries.id)
+ # must_respond_with :error
+ # end
+ end
+
+
+ describe "create" do
+ it "succeeds with a valid product" do
+ product = cherries
+ proc {
+ post product_reviews_path(product.id), params: {
+ review: {
+ rating: first_review.rating, text_review: first_review.text_review
+ }
+ }
+ }.must_change 'Review.count', 1
+ must_respond_with :redirect
+ must_redirect_to product_path(product.id)
+ end
+
+ it "renders bad request if review has no rating" do
+ product = cherries
+ proc {
+ post product_reviews_path(product.id), params: {
+ review: {
+ rating: nil, text_review: first_review.text_review
+ }
+ }
+ }.must_change 'Review.count', 0
+ must_respond_with :bad_request
+ 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..25571ab2f4
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,27 @@
+require "test_helper"
+
+describe SessionsController do
+ describe "create" do
+ #
+ # it "succeeds for a logged in user" do
+ # product = products(:watermelon)
+ # login(users(:beyonce))
+ #
+ # post add_to_order_path params: {
+ # product: {
+ # name: watermelon,
+ # price: 4.0,
+ # description: seedless,
+ # image: image_url,
+ # user: hermonie,
+ # quantity: 5
+ # }
+ # }
+ # must_respond_with :redirect
+ #
+ #
+ # end
+
+ end
+
+end
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
new file mode 100644
index 0000000000..f7bea71830
--- /dev/null
+++ b/test/controllers/users_controller_test.rb
@@ -0,0 +1,105 @@
+require "test_helper"
+
+describe UsersController do
+
+ describe "index" do
+ it "succeeds when there are users" do
+ get users_path
+ must_respond_with :success
+ end
+
+ it "succeeds when there are no users" do
+ users = User.all
+ users.each do |user|
+ user.products.destroy
+ user.destroy
+ end
+ get users_path
+ must_respond_with :success
+ end
+ end
+
+ describe "show" do
+ it "succeeds with a valid id" do
+ user = users(:ron)
+ get users_path(user.id)
+ must_respond_with :success
+ end
+ end
+
+ describe "edit" do
+ it "succeeds with valid data" do
+ user = users(:ron)
+ login(user)
+ get edit_user_path(user.id)
+ must_respond_with :success
+ end
+ end
+
+ describe "update" do
+ it "successfully updates user information" do
+ user = users(:ron)
+ login(user)
+ proc {
+ patch user_path(user.id), params: {
+ user: {
+ name: 'ronnie',
+ email: 'new_email@gmail.com'
+ }
+ }
+ }.must_change 'User.count', 0
+ must_redirect_to user_path(user.id)
+ end
+ end
+
+ describe "auth_callback" do
+
+ # test/controllers/users_controller_test.rb
+ it "logs in an existing user" do
+ start_count = User.count
+ user = users(:beyonce)
+
+ login(user)
+ must_redirect_to root_path
+ session[:user_id].must_equal user.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
+ user = User.new
+
+ user.name = "not bey"
+ user.email = "not_beyonce@github.com"
+ user.uid = 1101
+ user.provider = "github"
+
+ user.save
+
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+
+ get auth_callback_path(:github)
+
+ must_redirect_to root_path
+
+ session_user = User.find(session[:user_id])
+
+ user.name.must_equal session_user.name
+
+ User.count.must_equal (start_count + 1)
+ end
+
+ it "redirects to the login route if given invalid user data" do
+ invalid_user = User.new
+ invalid_user.name = nil
+ invalid_user.save
+
+ get auth_callback_path(:github)
+
+ 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..18c5a22015
--- /dev/null
+++ b/test/fixtures/categories.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+summer:
+ name: summer fruit
+
+fruit:
+ name: fruit salad
+
+pits:
+ name: pits
+
+edible:
+ name: edible fruit
diff --git a/test/fixtures/categories_products.yml b/test/fixtures/categories_products.yml
new file mode 100644
index 0000000000..c249cc8208
--- /dev/null
+++ b/test/fixtures/categories_products.yml
@@ -0,0 +1,4 @@
+
+test:
+ category_id: summer
+ product_id: cherries
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml
new file mode 100644
index 0000000000..d6a63daa9b
--- /dev/null
+++ b/test/fixtures/order_items.yml
@@ -0,0 +1,20 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# I am unsure of what to call the status
+fruit_salad:
+ order: cart1
+ product: cherries
+ quantity: 3
+ status: paid
+
+watermelon_salad:
+ order: cart2
+ product: watermelon
+ quantity: 2
+ status: paid
+
+citris_salad:
+ order: cart2
+ product: orange
+ quantity: 2
+ status: paid
diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml
new file mode 100644
index 0000000000..9ec5809c47
--- /dev/null
+++ b/test/fixtures/orders.yml
@@ -0,0 +1,91 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+cart1:
+ user: beyonce
+ status: shipped
+ name: bey
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
+
+cart2:
+ user: beyonce
+ status: shipped
+ name: bey
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
+
+cart3:
+ user: hermonie
+ status: paid
+ name: bey
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
+
+cart4:
+ user: mcgonagall
+ status: paid
+ name: beyyy
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
+
+cart5:
+ user: snape
+ status: paid
+ name: bey
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
+
+cart6:
+ user: snape
+ status: paid
+ name: bey
+ card_number: 1234123412341234
+ email: bey@github.com
+ street: malden
+ city: seattle
+ state: wa
+ zip: 12345
+ date_year: 18
+ date_month: 5
+ date_day: 3
+ cvv: 123
diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml
new file mode 100644
index 0000000000..dd5f2ce897
--- /dev/null
+++ b/test/fixtures/products.yml
@@ -0,0 +1,48 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+cherries:
+ name: cherries
+ price: 3.0
+ description: 1kg ranier cherries
+ image: image_url
+ user: beyonce
+ quantity: 4
+
+watermelon:
+ name: watermelon
+ price: 4.0
+ description: seedless
+ image: image_url
+ user: hermonie
+ quantity: 5
+
+orange:
+ name: orange
+ price: 1.0
+ description: single orange
+ image: image_url
+ user: hermonie
+ quantity: 4
+
+blood_orange:
+ name: blood orange
+ price: 1.0
+ description: single blood orange with magical properties
+ image: image_url
+ user: mcgonagall
+ quantity: 4
+
+gillyweed:
+ name: gillyweed
+ price: 1.0
+ description: not a fruit, allows for increased aquaability
+ image: image_url
+ user: beyonce
+ quantity: 4
+
+veritberry:
+ name: verit berry
+ price: 1.0
+ description: bitter berry used for veritaserum
+ image: image_url
+ user: snape
+ quantity: 4
diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml
new file mode 100644
index 0000000000..c448a6afd4
--- /dev/null
+++ b/test/fixtures/reviews.yml
@@ -0,0 +1,16 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+rating1:
+ product: cherries
+ rating: 1
+ text_review: too sour
+
+rating3:
+ product: cherries
+ rating: 1
+ text_review: rotten
+
+rating2:
+ product: watermelon
+ rating: 5
+ text_review: perfect
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000000..cb19669d47
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,31 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+beyonce:
+ name: beyonce
+ email: beyonce@github.com
+ uid: 101
+ provider: github
+
+hermonie:
+ name: hermonie
+ email: hermonie@github.com
+ uid: 100
+ provider: github
+
+ron:
+ name: ron
+ email: ron@github.com
+ uid: 107
+ provider: github
+
+mcgonagall:
+ name: professor mcgonagall
+ email: p_mcgonagall@github.com
+ uid: 899
+ provider: github
+
+snape:
+ name: professor snape
+ email: p_snape@github.com
+ uid: 899
+ provider: github
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..3fdb004a00
--- /dev/null
+++ b/test/models/category_test.rb
@@ -0,0 +1,34 @@
+require "test_helper"
+
+describe Category do
+ let(:category) { categories(:summer) }
+
+
+ it "must have a name" do
+ category.valid?.must_equal true
+ category.name = nil
+ category.valid?.must_equal false
+ end
+
+ it "must have a name of length > 1" do
+ category.name = ""
+ category.valid?.must_equal false
+ end
+
+ it "must have a unique name" do
+ fruit = categories(:fruit)
+ fruit.name = "summer fruit"
+ fruit.valid?.must_equal false
+ end
+
+ it "can have zero products" do
+ category.products.must_equal []
+ end
+
+ it "can have many products" do
+ category.products << products(:cherries)
+ category.products << products(:watermelon)
+
+ category.products.count.must_equal 2
+ end
+end
diff --git a/test/models/order_item_test.rb b/test/models/order_item_test.rb
new file mode 100644
index 0000000000..301c75f4af
--- /dev/null
+++ b/test/models/order_item_test.rb
@@ -0,0 +1,116 @@
+require 'test_helper'
+require 'pry'
+
+describe OrderItem do
+ let(:order_item) { OrderItem.new }
+
+ it "must be valid" do
+ salad = order_items(:fruit_salad)
+ value(salad).must_be :valid?
+ end
+
+ it "belongs to product" do
+ salad = order_items(:fruit_salad)
+ value(salad.product).must_be :valid?
+ salad.product.must_equal products(:cherries)
+
+ end
+
+ it "must have a product" do
+ salad = order_items(:fruit_salad)
+ products(:cherries).destroy
+
+ salad.valid?.must_equal false
+ end
+
+ it "belongs to order" do
+ salad = order_items(:fruit_salad)
+ value(salad.order).must_be :valid?
+ salad.order.must_equal orders(:cart1)
+
+ end
+
+ it "must have an order" do
+ salad = order_items(:fruit_salad)
+ orders(:cart1).destroy
+
+ salad.valid?.must_equal false
+ end
+
+ it "must have a product id" do
+ salad = order_items(:fruit_salad)
+ value(salad).must_be :valid?
+
+ salad.product_id = nil
+ salad.valid?.must_equal false
+ end
+
+ it "must have an order id" do
+ salad = order_items(:fruit_salad)
+ value(salad).must_be :valid?
+
+ salad.order_id = nil
+ salad.valid?.must_equal false
+ end
+
+ it "must have a quantity" do
+ salad = order_items(:fruit_salad)
+ value(salad).must_be :valid?
+
+ salad.quantity = nil
+ salad.valid?.must_equal false
+ end
+
+ it "must have a numerical quantity" do
+ salad = order_items(:fruit_salad)
+ value(salad).must_be :valid?
+
+ salad.quantity = "quantity!"
+ salad.valid?.must_equal false
+ end
+
+ # describe 'make order items' do
+ #
+ # it "" do
+ # hash = { products(:cherries).id => 3 }
+ # id = orders(:cart1).id
+ #
+ # order_item = OrderItem.make_order_items(id, hash)
+ #
+ # order_item.must_be_instance_of Hash
+ # end
+
+ # end
+
+ describe 'user_order_items' do
+
+ it 'returns an array of order items' do
+
+ items = OrderItem.user_order_items(users(:beyonce))
+
+ items.must_be_instance_of Array
+
+ items.each do |i|
+ i.must_be_instance_of OrderItem
+ end
+ end
+
+ it 'returns an array of order items belonging to one user' do
+
+ items = OrderItem.user_order_items(users(:beyonce))
+ items.each do |i|
+ i.user.must_be users(:beyonce)
+ end
+ end
+
+ it 'returns an empty array if there are no order items for a user' do
+
+ items = OrderItem.user_order_items(users(:hermonie))
+ items.must_equal []
+
+ end
+
+ end
+
+
+end
diff --git a/test/models/order_test.rb b/test/models/order_test.rb
new file mode 100644
index 0000000000..2951b6d4c2
--- /dev/null
+++ b/test/models/order_test.rb
@@ -0,0 +1,141 @@
+require "test_helper"
+
+describe Order do
+ let(:order) { orders(:cart2)}
+
+ it "must be valid" do
+ order.valid?.must_equal true
+ end
+
+ it "must have a name" do
+ order.name = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have a name with a length > 0" do
+ order.name = ""
+ order.valid?.must_equal false
+ end
+
+ it "must have a name with a length < 50" do
+ order.name = "jdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjd"
+
+ order.valid?.must_equal false
+ end
+
+ it "must have a card number" do
+ order.card_number = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have a integer card number of length 16" do
+ order.card_number = "aa fe"
+ order.valid?.must_equal false
+
+ order.card_number = 12354552
+ order.valid?.must_equal false
+
+ end
+
+ it "must have an integer zip" do
+ order.zip = "g vukj"
+ order.valid?.must_equal false
+ end
+
+ it "must have a date month" do
+ order.date_month = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have an integer cvv" do
+ order.cvv = "2348"
+ order.valid?.must_equal false
+ order.cvv = 2.67
+ order.valid?.must_equal false
+ end
+
+ it "must have a cvv with length 3" do
+ order.cvv = 3456
+ order.valid?.must_equal false
+ end
+
+ it "must have a zip with length 5" do
+ order.zip = 123
+ order.valid?.must_equal false
+ end
+
+ it "must have an email" do
+ order.email = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have proper email format" do
+ order.email = "aiesfn@"
+ order.valid?.must_equal false
+ order.email = 23485
+ order.valid?.must_equal false
+ end
+
+ it "must have a street" do
+ order.street = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have a city" do
+ order.city = nil
+ order.valid?.must_equal false
+ end
+
+ it "must have a state" do
+ order.state = nil
+ order.valid?.must_equal false
+ end
+
+ it "can have many order items" do
+ order.order_items.count.must_equal 2
+ end
+
+ it "must have a user" do
+ order.user = nil
+ order.valid?.must_equal false
+ end
+
+ describe 'order_status' do
+
+ it 'returns a status' do
+ statuses = ['complete', 'paid', 'pending']
+
+ order = orders(:cart2)
+ status = Order.order_status(order)
+
+ statuses.include?(status).must_equal true
+ end
+
+ it 'returns pending status if all order items are paid' do
+
+ order = orders(:cart2)
+ status = Order.order_status(order)
+
+ status.must_equal 'pending'
+ end
+
+ it 'returns pending status if some order items are paid and some are complete' do
+
+ order = orders(:cart2)
+
+ order_items(:watermelon_salad).status = 'complete'
+ status = Order.order_status(order)
+
+ status.must_equal 'pending'
+ end
+
+ it 'returns complete status if all order items are complete' do
+
+ order = orders(:cart2)
+ order.order_items.each do |i|
+ i.status = 'complete'
+ end
+ Order.order_status(order).must_equal 'complete'
+ end
+ end
+end
diff --git a/test/models/product_test.rb b/test/models/product_test.rb
new file mode 100644
index 0000000000..fd8cf5dfb1
--- /dev/null
+++ b/test/models/product_test.rb
@@ -0,0 +1,60 @@
+require "test_helper"
+
+describe Product do
+ let(:user) {User.create name: "Bey", email: "bey@yonce.com", uid: 2231, provider: "yonce"}
+
+ category = Category.create name: "summer fruit"
+
+ let(:product) { Product.create name: "green apple", price: 2, description: "granny smith organic apple", user_id: user.id}
+
+ it "is invalid when missing a name" do
+ product.name = nil
+ product.save
+ product.valid?.must_equal false
+ end
+
+ it "is invalid when a name is less than 1 characters" do
+ product.name = ""
+ product.save
+ product.valid?.must_equal false
+ end
+
+ it "is invalid when a price is not a number" do
+ product.price = "blah"
+ product.save
+ product.valid?.must_equal false
+ end
+
+ describe "relations" do
+ it "can have zero categories" do
+ product.categories.must_equal []
+
+ end
+
+ it "can have multiple categories" do
+ product.categories << categories(:summer)
+ product.categories << categories(:fruit)
+
+ product.categories.must_include categories(:summer)
+ product.categories.count.must_equal 2
+ end
+
+ it "must have a user" do
+ product.user_id.must_equal user.id
+
+ product.user_id = nil
+
+ product.valid?.must_equal false
+ end
+
+ it "can have multiple reviews" do
+ products(:cherries).reviews.count.must_equal 2
+ end
+
+ it "can have zero reviews" do
+ product.reviews.must_equal []
+ end
+
+ end
+
+end
diff --git a/test/models/review_test.rb b/test/models/review_test.rb
new file mode 100644
index 0000000000..50ba66373a
--- /dev/null
+++ b/test/models/review_test.rb
@@ -0,0 +1,34 @@
+require "test_helper"
+
+describe Review do
+ let(:review) { Review.create rating: 4, text_review: "very fresh!" }
+
+ it "must be valid" do
+ review = reviews(:rating1)
+ value(review).must_be :valid?
+ end
+
+ it "is invalid when missing a rating" do
+ review.rating = nil
+ review.valid?.must_equal false
+ end
+
+ it "is invalid when a rating greater than 5" do
+ review.rating = 6
+ review.valid?.must_equal false
+ end
+
+ it "is invalid when a rating less than 1" do
+ review.rating = 0
+ review.valid?.must_equal false
+ end
+
+ it "must have a product" do
+ review.valid?.must_equal false
+
+ review.product = products(:cherries)
+
+ review.valid?.must_equal true
+ end
+
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 0000000000..e042864e11
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,83 @@
+require "test_helper"
+
+describe User do
+ let(:user) { User.create name: "Bey", email: "bey@yonce.com", uid: 2231, provider: "yonce"}
+
+ it "must be valid" do
+
+ value(user).must_be :valid?
+ end
+
+ it "is invalid when missing a name" do
+ user.name = nil
+
+ user.valid?.must_equal false
+ end
+
+ it "is invalid when given a non-unique name" do
+ user.name = "Bey"
+
+ dup_user_name = User.new
+ dup_user_name.name = "Bey"
+ dup_user_name.save
+ dup_user_name.valid?.must_equal false
+ end
+
+ describe "relations" do
+ describe "order" do
+ it "can have an order" do
+ user1 = users(:hermonie)
+ user1.orders.count.must_equal 1
+ end
+
+ it "can have multiple orders" do
+ user1 = users(:beyonce)
+ user1.orders.count.must_equal 2
+ end
+
+ it "can have no orders" do
+ user1 = users(:ron)
+ user1.orders.count.must_equal 0
+ end
+ end
+
+ describe "products" do
+ it "can have a product" do
+ user1 = users(:mcgonagall)
+ user1.products.count.must_equal 1
+ end
+
+ it "can have multiple products" do
+ user1 = users(:hermonie)
+ user1.products.count.must_equal 2
+ end
+
+ it "can have no products" do
+ user1 = users(:ron)
+ user1.products.count.must_equal 0
+ end
+ end
+
+ describe "order and products" do
+ it "can have no products and no orders" do
+ user = users(:ron)
+ user.orders.count.must_equal 0
+ user.products.count.must_equal 0
+ end
+
+ it "can have multiple products and orders" do
+ user = users(:beyonce)
+
+ user.orders.count.must_equal 2
+
+ user.products.count.must_equal 2
+ end
+
+ it "can have one products and one orders" do
+ user = users(:mcgonagall)
+ user.orders.count.must_equal 1
+ user.products.count.must_equal 1
+ end
+ end
+ end
+end
diff --git a/test/system/.keep b/test/system/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000000..0c7add2ad7
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,52 @@
+require 'simplecov'
+SimpleCov.start
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters" # for Colorized output
+
+# For colorful output!
+Minitest::Reporters.use!(
+ Minitest::Reporters::SpecReporter.new,
+ ENV,
+ Minitest.backtrace_filter
+)
+
+
+# To add Capybara feature tests add `gem "minitest-rails-capybara"`
+# to the test group in the Gemfile and uncomment the following:
+# require "minitest/rails/capybara"
+
+# Uncomment for awesome colorful output
+# require "minitest/pride"
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ def setup
+ # Once you have enabled test mode, all requests
+ # to OmniAuth will be short circuited to use the mock authentication hash.
+ # A request to /auth/provider will redirect immediately to /auth/provider/callback.
+ OmniAuth.config.test_mode = true
+ end
+
+ def mock_auth_hash(user)
+ return {
+ provider: user.provider,
+ uid: user.uid,
+ info: {
+ email: user.email,
+ nickname: user.name
+ }
+ }
+ end
+
+ def login(user)
+ OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user))
+ get auth_callback_path(:github)
+ end
+
+end
diff --git a/tmp/.keep b/tmp/.keep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/vendor/.keep b/vendor/.keep
new file mode 100644
index 0000000000..e69de29bb2