From 6116eb6115cdec122dc1cf524fbc88840b6b9e44 Mon Sep 17 00:00:00 2001 From: Aurea Date: Wed, 17 Oct 2018 10:50:03 -0700 Subject: [PATCH 001/234] new rails, fix test_helper.rb --- .gitignore | 27 ++ .ruby-version | 1 + Gemfile | 81 +++++ Gemfile.lock | 277 ++++++++++++++++++ Guardfile | 9 + Rakefile | 6 + app/assets/config/manifest.js | 3 + app/assets/images/.keep | 0 app/assets/javascripts/application.js | 20 ++ app/assets/javascripts/cable.js | 13 + app/assets/javascripts/channels/.keep | 0 app/assets/stylesheets/application.scss | 18 ++ app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/controllers/application_controller.rb | 2 + app/controllers/concerns/.keep | 0 app/helpers/application_helper.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 4 + app/models/application_record.rb | 3 + app/models/concerns/.keep | 0 app/views/layouts/application.html.erb | 15 + app/views/layouts/mailer.html.erb | 13 + app/views/layouts/mailer.text.erb | 1 + bin/bundle | 3 + bin/rails | 9 + bin/rake | 9 + bin/setup | 36 +++ bin/spring | 17 ++ bin/update | 31 ++ bin/yarn | 11 + config.ru | 5 + config/application.rb | 25 ++ config/boot.rb | 4 + config/cable.yml | 10 + config/credentials.yml.enc | 1 + config/database.yml | 85 ++++++ config/environment.rb | 5 + config/environments/development.rb | 61 ++++ config/environments/production.rb | 94 ++++++ config/environments/test.rb | 46 +++ .../application_controller_renderer.rb | 8 + config/initializers/assets.rb | 14 + config/initializers/backtrace_silencers.rb | 7 + .../initializers/content_security_policy.rb | 25 ++ config/initializers/cookies_serializer.rb | 5 + .../initializers/filter_parameter_logging.rb | 4 + config/initializers/inflections.rb | 16 + config/initializers/mime_types.rb | 4 + config/initializers/wrap_parameters.rb | 14 + config/locales/en.yml | 33 +++ config/puma.rb | 34 +++ config/routes.rb | 3 + config/spring.rb | 6 + config/storage.yml | 34 +++ db/seeds.rb | 7 + lib/assets/.keep | 0 lib/tasks/.keep | 0 log/.keep | 0 package.json | 5 + public/404.html | 67 +++++ public/422.html | 67 +++++ public/500.html | 66 +++++ public/apple-touch-icon-precomposed.png | 0 public/apple-touch-icon.png | 0 public/favicon.ico | 0 public/robots.txt | 1 + storage/.keep | 0 test/application_system_test_case.rb | 5 + test/controllers/.keep | 0 test/fixtures/.keep | 0 test/fixtures/files/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/system/.keep | 0 test/test_helper.rb | 26 ++ tmp/.keep | 0 vendor/.keep | 0 80 files changed, 1408 insertions(+) create mode 100644 .gitignore create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Guardfile create mode 100644 Rakefile create mode 100644 app/assets/config/manifest.js create mode 100644 app/assets/images/.keep create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/cable.js create mode 100644 app/assets/javascripts/channels/.keep create mode 100644 app/assets/stylesheets/application.scss create mode 100644 app/channels/application_cable/channel.rb create mode 100644 app/channels/application_cable/connection.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/helpers/application_helper.rb create mode 100644 app/jobs/application_job.rb create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/models/application_record.rb create mode 100644 app/models/concerns/.keep create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/setup create mode 100755 bin/spring create mode 100755 bin/update create mode 100755 bin/yarn create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/cable.yml create mode 100644 config/credentials.yml.enc create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/en.yml create mode 100644 config/puma.rb create mode 100644 config/routes.rb create mode 100644 config/spring.rb create mode 100644 config/storage.yml create mode 100644 db/seeds.rb create mode 100644 lib/assets/.keep create mode 100644 lib/tasks/.keep create mode 100644 log/.keep create mode 100644 package.json create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/apple-touch-icon-precomposed.png create mode 100644 public/apple-touch-icon.png create mode 100644 public/favicon.ico create mode 100644 public/robots.txt create mode 100644 storage/.keep create mode 100644 test/application_system_test_case.rb create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/.keep create mode 100644 test/fixtures/files/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/system/.keep create mode 100644 test/test_helper.rb create mode 100644 tmp/.keep create mode 100644 vendor/.keep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..18b43c9cd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..25c81fe399 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.5.1 \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..6219256bd8 --- /dev/null +++ b/Gemfile @@ -0,0 +1,81 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.5.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.1' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +# gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'jquery-rails' +gem 'jquery-turbolinks' +gem 'bootstrap', '~> 4.1.3' +group :development, :test do + gem 'pry-rails' +end + +group :development do + gem 'better_errors' + gem 'binding_of_caller' + gem 'guard' + gem 'guard-minitest' +end + +group :test do + gem 'minitest-rails' + gem 'minitest-reporters' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..51100b2a1d --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,277 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.1) + actionpack (= 5.2.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.1) + actionview (= 5.2.1) + activesupport (= 5.2.1) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.1) + activesupport (= 5.2.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.1) + activesupport (= 5.2.1) + globalid (>= 0.3.6) + activemodel (5.2.1) + activesupport (= 5.2.1) + activerecord (5.2.1) + activemodel (= 5.2.1) + activesupport (= 5.2.1) + arel (>= 9.0) + activestorage (5.2.1) + actionpack (= 5.2.1) + activerecord (= 5.2.1) + marcel (~> 0.3.1) + activesupport (5.2.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + ansi (1.5.0) + archive-zip (0.11.0) + io-like (~> 0.3.0) + arel (9.0.0) + autoprefixer-rails (9.2.1) + execjs + better_errors (2.5.0) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + bindex (0.5.0) + binding_of_caller (0.8.0) + debug_inspector (>= 0.0.1) + bootsnap (1.3.2) + msgpack (~> 1.0) + bootstrap (4.1.3) + autoprefixer-rails (>= 6.0.3) + popper_js (>= 1.12.9, < 2) + sass (>= 3.5.2) + builder (3.2.3) + byebug (10.0.2) + capybara (3.9.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + xpath (~> 3.1) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chromedriver-helper (2.1.0) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.2) + concurrent-ruby (1.0.5) + crass (1.0.4) + debug_inspector (0.0.3) + erubi (1.7.1) + execjs (2.7.0) + ffi (1.9.25) + formatador (0.2.5) + globalid (0.4.1) + activesupport (>= 4.2.0) + guard (2.14.2) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-minitest (2.4.6) + guard-compat (~> 1.2) + minitest (>= 3.0) + i18n (1.1.1) + concurrent-ruby (~> 1.0) + io-like (0.3.0) + jbuilder (2.7.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.2) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + lumberjack (1.0.13) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.0) + mimemagic (0.3.2) + mini_mime (1.0.1) + mini_portile2 (2.3.0) + minitest (5.11.3) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) + minitest-reporters (1.3.5) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + msgpack (1.2.4) + multi_json (1.13.1) + nenv (0.3.0) + nio4r (2.3.1) + nokogiri (1.8.5) + mini_portile2 (~> 2.3.0) + notiffany (0.1.1) + nenv (~> 0.1) + shellany (~> 0.0) + pg (1.1.3) + popper_js (1.14.3) + pry (0.11.3) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.6) + pry (>= 0.10.4) + public_suffix (3.0.3) + puma (3.12.0) + rack (2.0.5) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.1) + actioncable (= 5.2.1) + actionmailer (= 5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) + activemodel (= 5.2.1) + activerecord (= 5.2.1) + activestorage (= 5.2.1) + activesupport (= 5.2.1) + bundler (>= 1.3.0) + railties (= 5.2.1) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.2.1) + actionpack (= 5.2.1) + activesupport (= 5.2.1) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (12.3.1) + rb-fsevent (0.10.3) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + ruby-progressbar (1.10.0) + ruby_dep (1.5.0) + rubyzip (1.2.2) + sass (3.6.0) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.14.1) + childprocess (~> 0.5) + rubyzip (~> 1.2, >= 1.2.2) + shellany (0.0.1) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.0) + thread_safe (0.3.6) + tilt (2.0.8) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.1.19) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + binding_of_caller + bootsnap (>= 1.1.0) + bootstrap (~> 4.1.3) + byebug + capybara (>= 2.15) + chromedriver-helper + guard + guard-minitest + jbuilder (~> 2.5) + jquery-rails + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + pg (>= 0.18, < 2.0) + pry-rails + puma (~> 3.11) + rails (~> 5.2.1) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.5.1p57 + +BUNDLED WITH + 1.16.2 diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000000..e34f706f4a --- /dev/null +++ b/Guardfile @@ -0,0 +1,9 @@ +guard :minitest, autorun: false, spring: true do + watch(%r{^app/(.+).rb$}) { |m| "test/#{m[1]}_test.rb" } + watch(%r{^app/controllers/application_controller.rb$}) { 'test/controllers' } + watch(%r{^app/controllers/(.+)_controller.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } + watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } + watch(%r{^lib/(.+).rb$}) { |m| "test/lib/#{m[1]}_test.rb" } + watch(%r{^test/.+_test.rb$}) + watch(%r{^test/test_helper.rb$}) { 'test' } +end diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..e85f913914 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000000..b16e53d6d5 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000000..4f73c21a7d --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,20 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's +// vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. + //= require jquery3 + //= require popper + //= require bootstrap-sprockets + +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 0000000000..739aa5f022 --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 0000000000..8b1701e581 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,18 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + */ + +/* Custom bootstrap variables must be set or imported *before* bootstrap. */ +@import "bootstrap"; +/* Import scss content */ +@import "**/*"; diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 0000000000..d672697283 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 0000000000..0ff5442f47 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000000..09705d12ab --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000000..de6be7945c --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..a009ace51c --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000000..286b2239d1 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000000..10a4cba84d --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000000..f18f1b6820 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + Betsy + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000000..cbd34d2e9d --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000000..37f0bddbd7 --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000000..f19acf5b5c --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..5badb2fde0 --- /dev/null +++ b/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..d87d5f5781 --- /dev/null +++ b/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..94fd4d7977 --- /dev/null +++ b/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/spring b/bin/spring new file mode 100755 index 0000000000..fb2ec2ebb4 --- /dev/null +++ b/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/bin/update b/bin/update new file mode 100755 index 0000000000..58bfaed518 --- /dev/null +++ b/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 0000000000..460dd565b4 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..f7ba0b527b --- /dev/null +++ b/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..5c09a3eefc --- /dev/null +++ b/config/application.rb @@ -0,0 +1,25 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Betsy + class Application < Rails::Application + config.generators do |g| + # Force new test files to be generated in the minitest-spec style + g.test_framework :minitest, spec: true + # Always use .js files, never .coffee + g.javascript_engine :js + end + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000..b9e460cef3 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..dd2a324c68 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: betsy_production diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000000..6b169e821b --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +/MzRPeazUWZZIFKyxQGagt5ecLbxDZpO19R7uanF8E5sHrUE/6ypZKnH/ZDleWcewYZ65pIg/cc8ADMys5Drt8Ea59PDo9r9QLOzj4L4nwByhMVHyyLcezx6SGJ+CdDbq2JB0bt+kUa1De/niqg5dF4hOVqRubMCLPGuif1Z13/qSNZC9hC8lAtHifUNB1ugQY0v0HkH9O79NFVrfAh8mv05J4xa6sQlNjjCiREpTlAX6QPVF7QGZpRvPqjtDOoIujPgeuZ1aXTEpzEHOWNo9PZiZbVKGLY0aoYNN8G6kWii7kRzGOpu/RhcYCsm+XbEoarvvZVUguTtTiPg8FfOurTNODxiJ+qWPhrMiVANED9irE4c2wOZQkkT7OUWFaEF7dRItChlF5BGCTYDigN7GJIyeTMwTEL/0lvr--eZLILJm0c6kkzYLF--8Rc6/Fzq3tv12+01/IGNlw== \ No newline at end of file diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000000..6903bb6083 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,85 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: betsy_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: betsy + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: betsy_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: betsy_production + username: betsy + password: <%= ENV['BETSY_DATABASE_PASSWORD'] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000000..426333bb46 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000000..1311e3e4ef --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000000..5f6f3058c6 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "betsy_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000000..0a38fd3ce9 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000000..89d2efab2b --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000000..4b828e80cb --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000000..59385cdf37 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000000..d3bcaa5ec8 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000000..5a6a32d371 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000000..4a994e1e7b --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000000..ac033bf9dc --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000000..dc1899682b --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000000..bbfc3961bf --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..decc5a8573 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000000..a5eccf816b --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,34 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..787824f888 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 0000000000..9fa7863f99 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000000..d32f76e8fb --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000000..1beea2accd --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# 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) diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/package.json b/package.json new file mode 100644 index 0000000000..f874acf437 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "name": "betsy", + "private": true, + "dependencies": {} +} diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000000..2be3af26fc --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000000..c08eac0d1d --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000000..78a030af22 --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000000..37b576a4a0 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000000..d19212abd5 --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000000..e69de29bb2 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/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..36b42dbe93 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,26 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path("../../config/environment", __FILE__) +require "rails/test_help" +require "minitest/rails" +require "minitest/reporters" # for Colorized output +require "pry" +# For colorful output! +Minitest::Reporters.use!( + Minitest::Reporters::SpecReporter.new, + ENV, + Minitest.backtrace_filter +) + + +# To add Capybara feature tests add `gem "minitest-rails-capybara"` +# to the test group in the Gemfile and uncomment the following: +# require "minitest/rails/capybara" + +# Uncomment for awesome colorful output +# require "minitest/pride" + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + # Add more helper methods to be used by all tests here... +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 From 03785aa926f6d565846e61638f87392ae5532dbd Mon Sep 17 00:00:00 2001 From: Aurea Date: Wed, 17 Oct 2018 15:49:23 -0700 Subject: [PATCH 002/234] add models --- app/models/merchant.rb | 2 + app/models/order.rb | 2 + app/models/order_item.rb | 2 + app/models/product.rb | 2 + app/models/review.rb | 2 + db/migrate/20181017222943_create_merchants.rb | 11 +++ db/migrate/20181017222948_create_products.rb | 15 ++++ db/migrate/20181017222952_create_orders.rb | 14 ++++ .../20181017222957_create_order_items.rb | 11 +++ db/migrate/20181017223000_create_reviews.rb | 11 +++ db/schema.rb | 74 +++++++++++++++++++ test/fixtures/merchants.yml | 11 +++ test/fixtures/order_items.yml | 11 +++ test/fixtures/orders.yml | 11 +++ test/fixtures/products.yml | 11 +++ test/fixtures/reviews.yml | 11 +++ test/models/merchant_test.rb | 9 +++ test/models/order_item_test.rb | 9 +++ test/models/order_test.rb | 9 +++ test/models/product_test.rb | 9 +++ test/models/review_test.rb | 9 +++ 21 files changed, 246 insertions(+) create mode 100644 app/models/merchant.rb create mode 100644 app/models/order.rb create mode 100644 app/models/order_item.rb create mode 100644 app/models/product.rb create mode 100644 app/models/review.rb create mode 100644 db/migrate/20181017222943_create_merchants.rb create mode 100644 db/migrate/20181017222948_create_products.rb create mode 100644 db/migrate/20181017222952_create_orders.rb create mode 100644 db/migrate/20181017222957_create_order_items.rb create mode 100644 db/migrate/20181017223000_create_reviews.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/merchants.yml create mode 100644 test/fixtures/order_items.yml create mode 100644 test/fixtures/orders.yml create mode 100644 test/fixtures/products.yml create mode 100644 test/fixtures/reviews.yml create mode 100644 test/models/merchant_test.rb create mode 100644 test/models/order_item_test.rb create mode 100644 test/models/order_test.rb create mode 100644 test/models/product_test.rb create mode 100644 test/models/review_test.rb diff --git a/app/models/merchant.rb b/app/models/merchant.rb new file mode 100644 index 0000000000..0440407160 --- /dev/null +++ b/app/models/merchant.rb @@ -0,0 +1,2 @@ +class Merchant < ApplicationRecord +end diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 0000000000..10281b3450 --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,2 @@ +class Order < ApplicationRecord +end diff --git a/app/models/order_item.rb b/app/models/order_item.rb new file mode 100644 index 0000000000..acc6099fd0 --- /dev/null +++ b/app/models/order_item.rb @@ -0,0 +1,2 @@ +class OrderItem < ApplicationRecord +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 0000000000..35a85acab3 --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,2 @@ +class Product < ApplicationRecord +end diff --git a/app/models/review.rb b/app/models/review.rb new file mode 100644 index 0000000000..b2ca4935ed --- /dev/null +++ b/app/models/review.rb @@ -0,0 +1,2 @@ +class Review < ApplicationRecord +end diff --git a/db/migrate/20181017222943_create_merchants.rb b/db/migrate/20181017222943_create_merchants.rb new file mode 100644 index 0000000000..846cedd125 --- /dev/null +++ b/db/migrate/20181017222943_create_merchants.rb @@ -0,0 +1,11 @@ +class CreateMerchants < ActiveRecord::Migration[5.2] + def change + create_table :merchants do |t| + t.string :username + t.string :email + t.integer :uid + t.string :provider + t.timestamps + end + end +end diff --git a/db/migrate/20181017222948_create_products.rb b/db/migrate/20181017222948_create_products.rb new file mode 100644 index 0000000000..f5ece18922 --- /dev/null +++ b/db/migrate/20181017222948_create_products.rb @@ -0,0 +1,15 @@ +class CreateProducts < ActiveRecord::Migration[5.2] + def change + create_table :products do |t| + t.string :name + t.decimal :price + t.string :photo + t.integer :stock + t.boolean :active + t.string :category + t.decimal :rating + t.belongs_to :merchant, index: true + t.timestamps + end + end +end diff --git a/db/migrate/20181017222952_create_orders.rb b/db/migrate/20181017222952_create_orders.rb new file mode 100644 index 0000000000..5396ce84dd --- /dev/null +++ b/db/migrate/20181017222952_create_orders.rb @@ -0,0 +1,14 @@ +class CreateOrders < ActiveRecord::Migration[5.2] + def change + create_table :orders do |t| + t.string :status + t.string :name + t.string :email + t.string :address + t.integer :cc_num + t.integer :cc_cvv + t.date :cc_expiration + t.timestamps + end + end +end diff --git a/db/migrate/20181017222957_create_order_items.rb b/db/migrate/20181017222957_create_order_items.rb new file mode 100644 index 0000000000..55800924ca --- /dev/null +++ b/db/migrate/20181017222957_create_order_items.rb @@ -0,0 +1,11 @@ +class CreateOrderItems < ActiveRecord::Migration[5.2] + def change + create_table :order_items do |t| + t.integer :quantity + t.string :status + t.belongs_to :product, index: true + t.belongs_to :order, index: true + t.timestamps + end + end +end diff --git a/db/migrate/20181017223000_create_reviews.rb b/db/migrate/20181017223000_create_reviews.rb new file mode 100644 index 0000000000..b3151c6ac6 --- /dev/null +++ b/db/migrate/20181017223000_create_reviews.rb @@ -0,0 +1,11 @@ +class CreateReviews < ActiveRecord::Migration[5.2] + def change + create_table :reviews do |t| + t.string :name + t.integer :rating + t.string :description + t.belongs_to :product, index: true + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..1e10d43d9a --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,74 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2018_10_17_223000) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "merchants", force: :cascade do |t| + t.string "username" + t.string "email" + t.integer "uid" + t.string "provider" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "order_items", force: :cascade do |t| + t.integer "quantity" + t.string "status" + t.bigint "product_id" + t.bigint "order_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["order_id"], name: "index_order_items_on_order_id" + t.index ["product_id"], name: "index_order_items_on_product_id" + end + + create_table "orders", force: :cascade do |t| + t.string "status" + t.string "name" + t.string "email" + t.string "address" + t.integer "cc_num" + t.integer "cc_cvv" + t.date "cc_expiration" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: :cascade do |t| + t.string "name" + t.decimal "price" + t.string "photo" + t.integer "stock" + t.boolean "active" + t.string "category" + t.decimal "rating" + t.bigint "merchant_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["merchant_id"], name: "index_products_on_merchant_id" + end + + create_table "reviews", force: :cascade do |t| + t.string "name" + t.integer "rating" + t.string "description" + t.bigint "product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["product_id"], name: "index_reviews_on_product_id" + end + +end diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/merchants.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/order_items.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/orders.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/products.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/reviews.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/merchant_test.rb b/test/models/merchant_test.rb new file mode 100644 index 0000000000..1cc99d985f --- /dev/null +++ b/test/models/merchant_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Merchant do + let(:merchant) { Merchant.new } + + it "must be valid" do + value(merchant).must_be :valid? + end +end diff --git a/test/models/order_item_test.rb b/test/models/order_item_test.rb new file mode 100644 index 0000000000..19a9bf8f58 --- /dev/null +++ b/test/models/order_item_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe OrderItem do + let(:order_item) { OrderItem.new } + + it "must be valid" do + value(order_item).must_be :valid? + end +end diff --git a/test/models/order_test.rb b/test/models/order_test.rb new file mode 100644 index 0000000000..df80f10fb6 --- /dev/null +++ b/test/models/order_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Order do + let(:order) { Order.new } + + it "must be valid" do + value(order).must_be :valid? + end +end diff --git a/test/models/product_test.rb b/test/models/product_test.rb new file mode 100644 index 0000000000..a618b0a156 --- /dev/null +++ b/test/models/product_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Product do + let(:product) { Product.new } + + it "must be valid" do + value(product).must_be :valid? + end +end diff --git a/test/models/review_test.rb b/test/models/review_test.rb new file mode 100644 index 0000000000..ce8378a033 --- /dev/null +++ b/test/models/review_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Review do + let(:review) { Review.new } + + it "must be valid" do + value(review).must_be :valid? + end +end From 73f4be0a0b85d48d62985d6eb52ab42b52ccb397 Mon Sep 17 00:00:00 2001 From: Aurea Date: Wed, 17 Oct 2018 15:55:37 -0700 Subject: [PATCH 003/234] add relations in model class --- app/models/merchant.rb | 2 ++ app/models/order.rb | 1 + app/models/order_item.rb | 2 ++ app/models/product.rb | 5 +++++ app/models/review.rb | 1 + 5 files changed, 11 insertions(+) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index 0440407160..7ddb9ab183 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -1,2 +1,4 @@ class Merchant < ApplicationRecord + + has_many :products end diff --git a/app/models/order.rb b/app/models/order.rb index 10281b3450..b8ff4b192c 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,2 +1,3 @@ class Order < ApplicationRecord + has_many :order_items end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index acc6099fd0..eecf9e7ebf 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,2 +1,4 @@ class OrderItem < ApplicationRecord + belongs_to :product + belongs_to :order end diff --git a/app/models/product.rb b/app/models/product.rb index 35a85acab3..b792e868ee 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,2 +1,7 @@ class Product < ApplicationRecord + belongs_to :merchant + + has_many :reviews + has_many :order_items + end diff --git a/app/models/review.rb b/app/models/review.rb index b2ca4935ed..949d4ccddb 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,2 +1,3 @@ class Review < ApplicationRecord + belongs_to :product end From ebface66717d15bfe79282a88eec0b5aa7b5cbc2 Mon Sep 17 00:00:00 2001 From: Sigrid Benezra Date: Thu, 18 Oct 2018 10:20:01 -0700 Subject: [PATCH 004/234] Generated products controller --- app/assets/javascripts/products.js | 2 ++ app/assets/stylesheets/products.scss | 3 +++ app/controllers/products_controller.rb | 2 ++ app/helpers/products_helper.rb | 2 ++ test/controllers/products_controller_test.rb | 7 +++++++ 5 files changed, 16 insertions(+) create mode 100644 app/assets/javascripts/products.js create mode 100644 app/assets/stylesheets/products.scss create mode 100644 app/controllers/products_controller.rb create mode 100644 app/helpers/products_helper.rb create mode 100644 test/controllers/products_controller_test.rb diff --git a/app/assets/javascripts/products.js b/app/assets/javascripts/products.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/products.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss new file mode 100644 index 0000000000..bff386e55a --- /dev/null +++ b/app/assets/stylesheets/products.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Products controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 0000000000..f1ad12ddea --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,2 @@ +class ProductsController < ApplicationController +end diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb new file mode 100644 index 0000000000..ab5c42b325 --- /dev/null +++ b/app/helpers/products_helper.rb @@ -0,0 +1,2 @@ +module ProductsHelper +end diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb new file mode 100644 index 0000000000..392a20e292 --- /dev/null +++ b/test/controllers/products_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe ProductsController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end From cabd25732fc79b94666b4b9fa9a42a4e3866b37f Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 10:59:20 -0700 Subject: [PATCH 005/234] Generate OrderItems controller --- app/assets/javascripts/order_items.js | 2 ++ app/assets/stylesheets/order_items.scss | 3 +++ app/controllers/order_items_controller.rb | 2 ++ app/helpers/order_items_helper.rb | 2 ++ test/controllers/order_items_controller_test.rb | 7 +++++++ 5 files changed, 16 insertions(+) create mode 100644 app/assets/javascripts/order_items.js create mode 100644 app/assets/stylesheets/order_items.scss create mode 100644 app/controllers/order_items_controller.rb create mode 100644 app/helpers/order_items_helper.rb create mode 100644 test/controllers/order_items_controller_test.rb diff --git a/app/assets/javascripts/order_items.js b/app/assets/javascripts/order_items.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/order_items.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/order_items.scss b/app/assets/stylesheets/order_items.scss new file mode 100644 index 0000000000..584862de9b --- /dev/null +++ b/app/assets/stylesheets/order_items.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the OrderItems controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb new file mode 100644 index 0000000000..357e7f5c80 --- /dev/null +++ b/app/controllers/order_items_controller.rb @@ -0,0 +1,2 @@ +class OrderItemsController < ApplicationController +end diff --git a/app/helpers/order_items_helper.rb b/app/helpers/order_items_helper.rb new file mode 100644 index 0000000000..e197528ae1 --- /dev/null +++ b/app/helpers/order_items_helper.rb @@ -0,0 +1,2 @@ +module OrderItemsHelper +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..96e3063c9c --- /dev/null +++ b/test/controllers/order_items_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe OrderItemsController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end From 5e9e0132e3e01ffd953a7052e5a4b18f73fe538e Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 11:12:22 -0700 Subject: [PATCH 006/234] create CRUD routes for orders controller, add tests for index and new --- app/assets/javascripts/orders.js | 2 + app/assets/stylesheets/orders.scss | 3 ++ app/controllers/orders_controller.rb | 28 ++++++++++++ app/helpers/orders_helper.rb | 2 + app/models/order.rb | 3 ++ config/routes.rb | 2 + .../20181018180824_reformat_order_cc_num.rb | 5 +++ db/schema.rb | 4 +- test/controllers/orders_controller_test.rb | 44 +++++++++++++++++++ test/fixtures/orders.yml | 13 +++--- 10 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/orders.js create mode 100644 app/assets/stylesheets/orders.scss create mode 100644 app/controllers/orders_controller.rb create mode 100644 app/helpers/orders_helper.rb create mode 100644 db/migrate/20181018180824_reformat_order_cc_num.rb create mode 100644 test/controllers/orders_controller_test.rb diff --git a/app/assets/javascripts/orders.js b/app/assets/javascripts/orders.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/orders.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/orders.scss b/app/assets/stylesheets/orders.scss new file mode 100644 index 0000000000..741506954d --- /dev/null +++ b/app/assets/stylesheets/orders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Orders controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb new file mode 100644 index 0000000000..84e38633a7 --- /dev/null +++ b/app/controllers/orders_controller.rb @@ -0,0 +1,28 @@ +class OrdersController < ApplicationController + + before_action :find_order + + def index + @orders = Order.all + end + + def new + @order = Order.new + end + + def create + + end + + def show + end + + def edit + end + + def update + end + + def destroy + end +end diff --git a/app/helpers/orders_helper.rb b/app/helpers/orders_helper.rb new file mode 100644 index 0000000000..443227fd48 --- /dev/null +++ b/app/helpers/orders_helper.rb @@ -0,0 +1,2 @@ +module OrdersHelper +end diff --git a/app/models/order.rb b/app/models/order.rb index b8ff4b192c..d148a8d1e4 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,3 +1,6 @@ class Order < ApplicationRecord + STATUS = %w(pending paid) has_many :order_items + + end diff --git a/config/routes.rb b/config/routes.rb index 787824f888..3d5d7e388d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + resources :orders end diff --git a/db/migrate/20181018180824_reformat_order_cc_num.rb b/db/migrate/20181018180824_reformat_order_cc_num.rb new file mode 100644 index 0000000000..fc0dc77270 --- /dev/null +++ b/db/migrate/20181018180824_reformat_order_cc_num.rb @@ -0,0 +1,5 @@ +class ReformatOrderCcNum < ActiveRecord::Migration[5.2] + def change + change_column :orders, :cc_num, :bigint + end +end diff --git a/db/schema.rb b/db/schema.rb index 1e10d43d9a..aa9bcaba97 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_10_17_223000) do +ActiveRecord::Schema.define(version: 2018_10_18_180824) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -40,7 +40,7 @@ t.string "name" t.string "email" t.string "address" - t.integer "cc_num" + t.bigint "cc_num" t.integer "cc_cvv" t.date "cc_expiration" t.datetime "created_at", null: false diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb new file mode 100644 index 0000000000..71510df7cc --- /dev/null +++ b/test/controllers/orders_controller_test.rb @@ -0,0 +1,44 @@ +require "test_helper" + +describe OrdersController do + + let (:delete_all) { + Order.all.each do |order| + order.destroy + end + } + + describe "index" do + it "should get index" do + get orders_path + + must_respond_with :success + end + end + + describe "new" do + it "can get the new page" do + get new_order_path + + must_respond_with :success + end + end + + describe "create" do + it "can create an order" do + order_data = { + order: { + status: 'pending', + name: 'Ada', + email: 'ada@adacademy.com', + address: '123 Street Dr. Seattle, WA', + cc_num: 1123384229389283, + cc_cvv: 280, + cc_expiration: 01-09-2020 + } + } + + + end + end +end diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index dc3ee79b5d..5034045962 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -4,8 +4,11 @@ # model remove the "{}" from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value -# -two: {} -# column: value +bob: + status: pending + name: Bob Li + email: bobli@adacademy.com + address: 100 6th Avenue, Seattle WA + cc_num: 1232837292749182 + cc_cvv: 293 + cc_expiration: 01-09-2018 From c090f0d1dd811b97f2c9776fffdb9ab75fb39c26 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 11:24:14 -0700 Subject: [PATCH 007/234] all tests pass for order index and new controller methods --- app/controllers/orders_controller.rb | 3 +- app/models/order.rb | 4 +-- app/views/orders/index.html.erb | 0 app/views/orders/new.html.erb | 0 test/controllers/orders_controller_test.rb | 36 ++++++++++++++-------- test/fixtures/orders.yml | 2 +- 6 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 app/views/orders/index.html.erb create mode 100644 app/views/orders/new.html.erb diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 84e38633a7..e64bd547d1 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -1,9 +1,10 @@ class OrdersController < ApplicationController - before_action :find_order + # before_action :find_order def index @orders = Order.all + end def new diff --git a/app/models/order.rb b/app/models/order.rb index d148a8d1e4..ec7ca6a854 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,6 +1,6 @@ class Order < ApplicationRecord - STATUS = %w(pending paid) + STATUS = %w(paid fulfilled) has_many :order_items - + end diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/orders/new.html.erb b/app/views/orders/new.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 71510df7cc..d68e0cf10b 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -8,8 +8,30 @@ end } + let (:order_data) { + { + order: { + status: 'paid', + name: 'Ada', + email: 'ada@adacademy.com', + address: '123 Street Dr. Seattle, WA', + cc_num: 1123384229389283, + cc_cvv: 280, + cc_expiration: 01-9-2020 + } + } + } + describe "index" do - it "should get index" do + it "succeeds with orders present" do + get orders_path + + must_respond_with :success + end + + it "succeeds with no orders present" do + delete_all + get orders_path must_respond_with :success @@ -26,18 +48,6 @@ describe "create" do it "can create an order" do - order_data = { - order: { - status: 'pending', - name: 'Ada', - email: 'ada@adacademy.com', - address: '123 Street Dr. Seattle, WA', - cc_num: 1123384229389283, - cc_cvv: 280, - cc_expiration: 01-09-2020 - } - } - end end diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index 5034045962..c59225f511 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -5,7 +5,7 @@ # below each fixture, per the syntax in the comments below # bob: - status: pending + status: paid name: Bob Li email: bobli@adacademy.com address: 100 6th Avenue, Seattle WA From 9d73a02503e9052784e1a9d13ed5b31c7dbff22c Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 11:37:09 -0700 Subject: [PATCH 008/234] create controller with valid test passing --- app/controllers/orders_controller.rb | 21 +++++++++++++++++++++ app/views/orders/show.html.erb | 0 test/controllers/orders_controller_test.rb | 9 ++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/views/orders/show.html.erb diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index e64bd547d1..9539814445 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -12,9 +12,16 @@ def new end def create + @order = Order.new(order_params) + if @order.save + redirect_to order_path(@order.id) + else + render :edit, status: :bad_request + end end + def show end @@ -26,4 +33,18 @@ def update def destroy end + + private + + def order_params + params.require(:order).permit( + :status, + :name, + :email, + :address, + :cc_num, + :cc_cvv, + :cc_expiration + ) + end end diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index d68e0cf10b..e2ad51cbc2 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -48,7 +48,14 @@ describe "create" do it "can create an order" do - + test_order = Order.new(order_data[:order]) + expect(test_order).must_be :valid?, "Order data was invalid. Please fix." + + expect{ + post orders_path, params: order_data + }.must_change('Order.count', +1 ) + + must_redirect_to order_path(Order.last) end end end From 7ca30356113685af0bab3050aec047ceb13ea83d Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 11:46:21 -0700 Subject: [PATCH 009/234] Add OrderItemsController CRUD actions --- app/controllers/order_items_controller.rb | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 357e7f5c80..7980d52e21 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -1,2 +1,56 @@ class OrderItemsController < ApplicationController + + def index + @order_items = OrderItem.all + end + + def new + @order_item = OrderItem.new + end + + # order item is created when added to cart + def create + @order_item = OrderItem.new(order_item_params) + # order item is created when added to cart + if @order_item.save + flash[:success] = "Item added to cart." + redirect_back + # where do we want to go/redirect_to if an order item is successfully saved? + else + flash[:error] = "Error adding item to cart." + # should other messages be displayed if it isn't successfully saved? i.e., 'quantity not available' + end + end + + def show + @order_item = OrderItem.find_by(id: params[:id]) + end + + def edit + @order_item = OrderItem.find_by(id: params[:id]) + end + + def update + @order_item = OrderItem.find_by(id: params[:id]) + if @order_item.update(order_item_params) + flash[:success] = "Successful update." + # where to redirect to? + else + render :edit + # what do we want to render here? + end + end + + def destroy + @order_item = OrderItem.find_by(id: params[:id]) + + @order_item.destroy + # where to redirect to? + end + + private + def order_item_params + params.require(:order_item).permit(:quantity, :status) + end + end From 670d505f72b85eac2191cb6ef270aab7ad63d225 Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 11:46:37 -0700 Subject: [PATCH 010/234] Add OrderItems routes --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 787824f888..bb52952860 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + resources :order_items end From 54ff02ec05db0f597e8dd7a98b56edbd1dbacee8 Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 12:01:14 -0700 Subject: [PATCH 011/234] Add new view template for OrderItemsController --- app/views/order_items/new.html.erb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/views/order_items/new.html.erb diff --git a/app/views/order_items/new.html.erb b/app/views/order_items/new.html.erb new file mode 100644 index 0000000000..e69de29bb2 From a53503f01d58bd20d7e45a88e6a21a95de8a0cfd Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 12:01:43 -0700 Subject: [PATCH 012/234] Test for OrderItemsController#new --- test/controllers/order_items_controller_test.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/controllers/order_items_controller_test.rb b/test/controllers/order_items_controller_test.rb index 96e3063c9c..f72fbe7037 100644 --- a/test/controllers/order_items_controller_test.rb +++ b/test/controllers/order_items_controller_test.rb @@ -1,7 +1,10 @@ require "test_helper" describe OrderItemsController do - # it "must be a real test" do - # flunk "Need real tests" - # end + describe 'new' do + it 'succeeds' do + get new_order_item_path + must_respond_with :success + end + end end From b5ea01a5eb8168d0106559ab8f4d6692cac337fa Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 12:13:06 -0700 Subject: [PATCH 013/234] edit tests in progress, add update tests --- app/controllers/application_controller.rb | 5 +++ app/controllers/orders_controller.rb | 14 +++++++- app/views/orders/edit.html.erb | 0 test/controllers/orders_controller_test.rb | 38 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 app/views/orders/edit.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12ab..3280cc3de9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,7 @@ class ApplicationController < ActionController::Base + + def render_404 + # this will actually render a 404 page in production + raise ActionController::RoutingError.new('Not Found') + end end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 9539814445..b034f5afee 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -1,6 +1,6 @@ class OrdersController < ApplicationController - # before_action :find_order + before_action :find_order, except: [:index, :new, :create] def index @orders = Order.all @@ -29,6 +29,13 @@ def edit end def update + @order.update_attributes(order_params) + + if @order.save + redirect_to order_path(@order.id) + else + render :edit, status: :bad_request + end end def destroy @@ -47,4 +54,9 @@ def order_params :cc_expiration ) end + + def find_order + @order = Order.find_by(id: params[:id]) + render_404 unless @order + end end diff --git a/app/views/orders/edit.html.erb b/app/views/orders/edit.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index e2ad51cbc2..04a9c9c104 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -22,6 +22,10 @@ } } + let (:existing_order) { + orders(:bob) + } + describe "index" do it "succeeds with orders present" do get orders_path @@ -58,4 +62,38 @@ must_redirect_to order_path(Order.last) end end + + describe "edit" do + it "succeeds with an extant order ID" do + get edit_order_path(existing_order.id) + + must_respond_with :success + end + + it "renders 404 not_found for a bogus order ID" do + existing_order.destroy + + get edit_order_path(existing_order.id) + + must_respond_with :not_found + end + end + + describe "update" do + it "succeeds for valid data and an extant work ID" do + test_order = Order.new(order_data[:order]) + expect(test_order).must_be :valid?, "Order data was invalid. Please fix." + + expect{ + patch order_path(existing_order.id), params: order_data + }.wont_change('Order.count') + + existing_order.reload + (existing_order.email).must_equal test_order.email + (existing_order.name).must_equal test_order.name + (existing_order.address).must_equal test_order.address + + must_redirect_to order_path(existing_order.id) + end + end end From 6a92aa633536009bb9ecc3b6f24451e5df365982 Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 12:17:11 -0700 Subject: [PATCH 014/234] Add test template for OrderItemsController#edit --- test/controllers/order_items_controller_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/controllers/order_items_controller_test.rb b/test/controllers/order_items_controller_test.rb index f72fbe7037..3b56ad2d67 100644 --- a/test/controllers/order_items_controller_test.rb +++ b/test/controllers/order_items_controller_test.rb @@ -7,4 +7,17 @@ must_respond_with :success end end + + describe 'edit' do + # need product and order yml fixture data before can add order_item yml fixture data + it 'succeeds for existing order item id' do + expect { + get edit_order_item_path(OrderItem.first) + must_respond_with :success + } + end + it 'renders 404 not found for non-existant order item id' do + + end + end end From b8dff7f061bb0609477149e12963ffe87329e398 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 12:30:18 -0700 Subject: [PATCH 015/234] add update tests --- app/controllers/application_controller.rb | 3 +++ test/controllers/orders_controller_test.rb | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3280cc3de9..6d841530e7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,7 @@ class ApplicationController < ActionController::Base + # protect_from_forgery with: :exception + protect_from_forgery with: :exception + def render_404 # this will actually render a 404 page in production diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 04a9c9c104..0ccce53dd4 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -95,5 +95,19 @@ must_redirect_to order_path(existing_order.id) end + + it "renders bad_request for bogus data" do + + end + + it "renders 404 not_found for a bogus order ID" do + existing_order.destroy + + patch order_path(existing_order.id), params: order_data + + must_respond_with :not_found + end end + + end From 945d64d2749dfc1cb640abc5f39eadc23743c777 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 13:55:58 -0700 Subject: [PATCH 016/234] finish CRUD and tests for order controller --- app/controllers/application_controller.rb | 3 ++- app/controllers/orders_controller.rb | 2 ++ test/controllers/orders_controller_test.rb | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6d841530e7..5ec079928a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base def render_404 # this will actually render a 404 page in production - raise ActionController::RoutingError.new('Not Found') + # raise ActionController::RoutingError.new('Not Found') + render :index, status: :not_found end end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index b034f5afee..da6705466d 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -39,6 +39,8 @@ def update end def destroy + @order.destroy + redirect_to orders_path end private diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 0ccce53dd4..9571ec809b 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -109,5 +109,27 @@ end end + describe "destroy" do + it "succeeds for an extant work ID" do + expect{ + delete order_path(existing_order.id) + }.must_change('Order.count', -1) + + must_respond_with :redirect + must_redirect_to orders_path + end + + it "renders 404 not_found and does not update the DB for a bogus work ID" do + existing_order.destroy + + expect{ + delete order_path(existing_order.id) + }.wont_change('Order.count') + + must_respond_with :not_found + + end + end + end From fac1ab8bb42f772740bf56b13142c837a9c11690 Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 14:12:42 -0700 Subject: [PATCH 017/234] Create seed script for Merchant --- db/generate_seeds.rb | 17 +++++++++++++++++ db/merchant_seeds.csv | 26 ++++++++++++++++++++++++++ db/seeds.rb | 8 ++++++++ 3 files changed, 51 insertions(+) create mode 100644 db/generate_seeds.rb create mode 100644 db/merchant_seeds.csv diff --git a/db/generate_seeds.rb b/db/generate_seeds.rb new file mode 100644 index 0000000000..70c05d3a8f --- /dev/null +++ b/db/generate_seeds.rb @@ -0,0 +1,17 @@ +require 'faker' +require 'date' +require 'csv' + +# Merchant seed script +CSV.open('db/merchant_seeds.csv', "w", :write_headers=> true, + :headers => ["username", "email", "uid", "provider"]) do |csv| + + 25.times do + username = Faker::HarryPotter.character + email = Faker::Internet.email + uid = Faker::Number.number(3) + provider = "github" + + csv << [username, email, uid, provider] + end +end diff --git a/db/merchant_seeds.csv b/db/merchant_seeds.csv new file mode 100644 index 0000000000..ab6d8de115 --- /dev/null +++ b/db/merchant_seeds.csv @@ -0,0 +1,26 @@ +username,email,uid,provider +"Barty Crouch, Jr.",mark@bashirian.co,811,github +Katie Bell,birdie@gutmann.com,550,github +Fawkes,christ_kling@goldner.info,995,github +Scabior,ozella_swift@barton.io,324,github +Percy Weasley,georgiana_pagac@kutchhomenick.name,794,github +Godric Gryffindor,hilma@botsford.net,437,github +Michael Corner,clinton@schultz.io,339,github +Marietta Edgecombe,eileen_abernathy@nienow.net,605,github +Rolanda Hooch,hector_walsh@frami.io,702,github +Pigwidgeon,rasheed_leffler@simonis.io,572,github +Great Aunt Muriel,oran.olson@stehr.co,619,github +Charlie Weasley,jenifer@mante.io,315,github +Everard,laurianne_stehr@murraylarson.com,965,github +Griphook,krista.schumm@gleichner.org,322,github +Fridwulfa,green_hane@spencer.io,583,github +Hokey,angeline@herman.info,278,github +James Potter,verna_stamm@schimmeloberbrunner.org,281,github +Merope Gaunt,frederique.wilderman@buckridge.io,459,github +Igor Karkaroff,althea.hansen@hills.org,744,github +Mary Cattermole,liza@reicherthayes.biz,413,github +Morfin Gaunt,mae_casper@walsh.io,548,github +Nagini,kyla_anderson@franeckitrantow.info,138,github +Justin Finch-Fletchley,aric@damore.co,529,github +Helga Hufflepuff,kristy@robel.net,902,github +Roger Davies,dana.raynor@bogisich.co,179,github diff --git a/db/seeds.rb b/db/seeds.rb index 1beea2accd..c55cfe3254 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,11 @@ # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) +require 'csv' +merchant_file = Rails.root.join('db', 'merchant_seeds.csv') + +CSV.foreach(merchant_file, headers: true, header_converters: :symbol, converters: :all) do |row| + data = Hash[row.headers.zip(row.fields)] + puts data + Merchant.create!(data) +end From 2de323eb2c24332a8b8af42a7d55c7c4a1a6ee3f Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 14:16:06 -0700 Subject: [PATCH 018/234] Generate Merchants controller --- app/assets/javascripts/merchants.js | 2 ++ app/assets/stylesheets/merchants.scss | 3 +++ app/controllers/merchants_controller.rb | 2 ++ app/helpers/merchants_helper.rb | 2 ++ test/controllers/merchants_controller_test.rb | 7 +++++++ 5 files changed, 16 insertions(+) create mode 100644 app/assets/javascripts/merchants.js create mode 100644 app/assets/stylesheets/merchants.scss create mode 100644 app/controllers/merchants_controller.rb create mode 100644 app/helpers/merchants_helper.rb create mode 100644 test/controllers/merchants_controller_test.rb diff --git a/app/assets/javascripts/merchants.js b/app/assets/javascripts/merchants.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/merchants.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/merchants.scss b/app/assets/stylesheets/merchants.scss new file mode 100644 index 0000000000..f4c164d600 --- /dev/null +++ b/app/assets/stylesheets/merchants.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Merchants controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb new file mode 100644 index 0000000000..ae95f7677b --- /dev/null +++ b/app/controllers/merchants_controller.rb @@ -0,0 +1,2 @@ +class MerchantsController < ApplicationController +end diff --git a/app/helpers/merchants_helper.rb b/app/helpers/merchants_helper.rb new file mode 100644 index 0000000000..5337747b0f --- /dev/null +++ b/app/helpers/merchants_helper.rb @@ -0,0 +1,2 @@ +module MerchantsHelper +end diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb new file mode 100644 index 0000000000..6eb57f7baa --- /dev/null +++ b/test/controllers/merchants_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe MerchantsController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end From add2905db731d18d2e1ce9168029bf11ac898a9b Mon Sep 17 00:00:00 2001 From: Sigrid Benezra Date: Thu, 18 Oct 2018 14:14:18 -0700 Subject: [PATCH 019/234] Product index controller action and view created. Product index action passes test without products in db. --- app/controllers/products_controller.rb | 44 ++++++++++++++++++++ app/views/products/index.html.erb | 31 ++++++++++++++ config/routes.rb | 3 ++ test/controllers/products_controller_test.rb | 5 +++ 4 files changed, 83 insertions(+) create mode 100644 app/views/products/index.html.erb diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index f1ad12ddea..cc9f541d9b 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -1,2 +1,46 @@ class ProductsController < ApplicationController + + def index + @products = Product.all + end + + def show + @product = Product.find_by(params[:id]) + end + + def new + @product = Product.new + end + + def create + @product = Product.new(product_params) + if @product.save + redirect_to products_path + else + render :new + end + end + + def edit + @product = Product.find_by(product_params[:id]) + end + + def update + @product = Product.find_by(product_params[:id]) + if @product.update(product_params) + redirect_to product_path(@product) + else + render :edit + end + end + + def destroy + @product.destroy + redirect_to products_path + end + + def product_params + params.require(:product).permit(:name, :price, :photo, :stock, :active, :category, :rating, :merchant_id) + end + end diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb new file mode 100644 index 0000000000..cbab5ecdd4 --- /dev/null +++ b/app/views/products/index.html.erb @@ -0,0 +1,31 @@ +

All Products

+ + + + + + + + + + + + + + + + <% @products.each do |product| %> + + + + + + + + + + + + <% end %> + +
NamePricePhotoStockActiveCategoryRatingMerchant ID
<%= product.name %><%= product.price %><%= product.photo %><%= product.stock %><%= product.active %><%= product.category %><%= product.rating %><%= product.merchant_id %>
diff --git a/config/routes.rb b/config/routes.rb index 787824f888..1f7ef6dab0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,6 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + resources :products + end diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 392a20e292..9d67780f6c 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -4,4 +4,9 @@ # it "must be a real test" do # flunk "Need real tests" # end + it "succeeds when there are no products" do + get products_path + + must_respond_with :success + end end From dbb0766cc2e122c66c281f88feff88c3fa66efae Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 14:36:13 -0700 Subject: [PATCH 020/234] Add CRUD actions to Merchants controller + merchant_params --- app/controllers/merchants_controller.rb | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index ae95f7677b..153df82e6e 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,2 +1,48 @@ class MerchantsController < ApplicationController + def new + @merchant = Merchant.new + end + + def create + @merchant = Merchant.new(merchant_params) + end + + def show + @merchant = Merchant.find_by(id: params[:id]) + render_404 unless @merchant + end + + def index + @merchants = Merchant.all + end + + def edit + @merchant = Merchant.find(params[:id]) + end + + def update + @merchant = Merchant.find(params[:id]) + + if @merchant.save(merchant_params) + redirect_to merchant_path(@merchant) + else + render :edit + end + end + + def destroy + @merchant.destroy + end + +private + + def merchant_params + return params.require(:merchant).permit( + :username, + :email, + :uid, + :provider + ) + end + end From f716f47bb355e76b6ff6eba98743880e4261345b Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 14:46:11 -0700 Subject: [PATCH 021/234] Add seed scripts for all models --- db/generate_seeds.rb | 49 ++++++++++++++++++++++++++++++++++++++- db/merchant_seeds.csv | 30 ++++-------------------- db/order_item_seeds.csv | 51 +++++++++++++++++++++++++++++++++++++++++ db/order_seeds.csv | 21 +++++++++++++++++ db/product_seeds.csv | 51 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+), 26 deletions(-) create mode 100644 db/order_item_seeds.csv create mode 100644 db/order_seeds.csv create mode 100644 db/product_seeds.csv diff --git a/db/generate_seeds.rb b/db/generate_seeds.rb index 70c05d3a8f..ed2b1ef14d 100644 --- a/db/generate_seeds.rb +++ b/db/generate_seeds.rb @@ -6,7 +6,7 @@ CSV.open('db/merchant_seeds.csv', "w", :write_headers=> true, :headers => ["username", "email", "uid", "provider"]) do |csv| - 25.times do + 5.times do username = Faker::HarryPotter.character email = Faker::Internet.email uid = Faker::Number.number(3) @@ -15,3 +15,50 @@ csv << [username, email, uid, provider] end end + +# Product seed script +CSV.open('db/product_seeds.csv', "w", :write_headers=> true, + :headers => ["name", "price", "photo", "stock", "active", "category", "rating"]) do |csv| + + 50.times do + name = Faker::Cat.name + price = Faker::Commerce.price + photo = 'http://placekitten.com/200/300' + stock = Faker::Number.number(2) + active = Faker::Boolean.boolean(0.9) + category = Faker::Cat.breed + rating = Faker::Number.between(1, 5) + + csv << [name, price, photo, stock, active, category, rating] + end +end + +# Order item seed script +CSV.open('db/order_item_seeds.csv', "w", :write_headers=> true, + :headers => ["quantity", "status"]) do |csv| + + 50.times do + quantity = Faker::Number.number(2) + status = %w(pending paid complete cancelled).sample + + csv << [quantity, status] + end +end + +# Order seed screipt +CSV.open('db/order_seeds.csv', "w", :write_headers=> true, + :headers => ["status", "name", "email", "address", "cc_num", "cc_cvv", "cc_expiration"]) do |csv| + + 20.times do + status = %w(paid complete cancelled).sample + name = Faker::RickAndMorty.character + email = Faker::Internet.email + address = Faker::Address.full_address + cc_num = Faker::Number.number(16) + cc_cvv = Faker::Number.number(3) + cc_expiration = Faker::Date.backward(21) + + + csv << [status, name, email, address, cc_num, cc_cvv, cc_expiration] + end +end diff --git a/db/merchant_seeds.csv b/db/merchant_seeds.csv index ab6d8de115..b225c2b60a 100644 --- a/db/merchant_seeds.csv +++ b/db/merchant_seeds.csv @@ -1,26 +1,6 @@ username,email,uid,provider -"Barty Crouch, Jr.",mark@bashirian.co,811,github -Katie Bell,birdie@gutmann.com,550,github -Fawkes,christ_kling@goldner.info,995,github -Scabior,ozella_swift@barton.io,324,github -Percy Weasley,georgiana_pagac@kutchhomenick.name,794,github -Godric Gryffindor,hilma@botsford.net,437,github -Michael Corner,clinton@schultz.io,339,github -Marietta Edgecombe,eileen_abernathy@nienow.net,605,github -Rolanda Hooch,hector_walsh@frami.io,702,github -Pigwidgeon,rasheed_leffler@simonis.io,572,github -Great Aunt Muriel,oran.olson@stehr.co,619,github -Charlie Weasley,jenifer@mante.io,315,github -Everard,laurianne_stehr@murraylarson.com,965,github -Griphook,krista.schumm@gleichner.org,322,github -Fridwulfa,green_hane@spencer.io,583,github -Hokey,angeline@herman.info,278,github -James Potter,verna_stamm@schimmeloberbrunner.org,281,github -Merope Gaunt,frederique.wilderman@buckridge.io,459,github -Igor Karkaroff,althea.hansen@hills.org,744,github -Mary Cattermole,liza@reicherthayes.biz,413,github -Morfin Gaunt,mae_casper@walsh.io,548,github -Nagini,kyla_anderson@franeckitrantow.info,138,github -Justin Finch-Fletchley,aric@damore.co,529,github -Helga Hufflepuff,kristy@robel.net,902,github -Roger Davies,dana.raynor@bogisich.co,179,github +Myrtle Warren,lindsey_pfeffer@gusikowski.co,794,github +Petunia Dursley,josiah@moorereinger.co,724,github +Enid,kristoffer@bernier.co,465,github +Cadmus Peverell,ettie.runte@bayercarter.info,625,github +Bertha Jorkins,vincent@kulasbarrows.info,607,github diff --git a/db/order_item_seeds.csv b/db/order_item_seeds.csv new file mode 100644 index 0000000000..0b37485049 --- /dev/null +++ b/db/order_item_seeds.csv @@ -0,0 +1,51 @@ +quantity,status +58,pending +48,pending +10,paid +85,paid +52,pending +90,cancelled +70,paid +52,pending +90,paid +62,complete +35,cancelled +66,cancelled +88,cancelled +70,paid +25,cancelled +41,complete +82,pending +93,complete +38,paid +13,paid +65,cancelled +18,complete +60,pending +25,pending +45,cancelled +74,complete +51,cancelled +81,pending +61,cancelled +98,paid +23,pending +85,paid +82,pending +19,complete +27,complete +13,cancelled +72,pending +46,paid +50,complete +50,complete +74,paid +54,cancelled +65,paid +89,pending +38,cancelled +86,cancelled +25,complete +98,pending +86,pending +30,pending diff --git a/db/order_seeds.csv b/db/order_seeds.csv new file mode 100644 index 0000000000..449b87a5f0 --- /dev/null +++ b/db/order_seeds.csv @@ -0,0 +1,21 @@ +status,name,email,address,cc_num,cc_cvv,cc_expiration +complete,Krombopulos Michael,lyric_heidenreich@treutel.io,"2446 Kozey Club, Lake Wilburn, NM 60988",3922340489560492,688,2018-10-17 +cancelled,Tinkles,lulu_purdy@koelpinquigley.info,"Suite 253 1042 Hailie River, West Cassandremouth, MS 41854-7982",8152981943121218,723,2018-10-06 +cancelled,Squanchy,rogers_boyle@renner.co,"Suite 768 933 Laurence Field, North Brandon, RI 54070",1160404745806277,231,2018-10-02 +complete,Loggins,salma@grimes.io,"Suite 290 744 Kelsie Spurs, New Rowan, WI 40432-4073",7291818594782497,865,2018-10-16 +cancelled,Scary Terry,betsy@flatleyrunolfon.biz,"Apt. 669 2156 Zulauf Hollow, Strackebury, AL 24476-5490",3007141611494611,871,2018-10-12 +cancelled,Shrimply Pibbles,eleanore@jacobitromp.name,"44731 Gilbert Forest, Port Hellenborough, NH 19024-6611",2900023008480644,485,2018-10-07 +paid,Tinkles,furman_towne@mcclure.com,"Apt. 532 4497 Jarrod Pines, East Dock, VA 94118",5752880347867729,992,2018-09-29 +complete,Abradolf Lincler,kristopher_donnelly@beckerratke.info,"6544 Neva Pass, New Randyberg, TN 86762-9881",7720250494292397,115,2018-10-10 +complete,Arthricia,fiona@douglapinka.name,"Suite 987 3693 Hazle Village, New Garrettfort, MD 94820-5911",7164115417495278,120,2018-09-28 +complete,Tiny Rick,elijah.dubuque@hauck.io,"Suite 303 39841 Evert Walks, Annamaeburgh, RI 79620-3467",1530140453678366,365,2018-10-02 +paid,Mr. Poopybutthole,fermin@sipes.net,"90413 Witting Port, O'Connellmouth, AR 48159-4496",1232779812364109,402,2018-10-14 +complete,King Jellybean,idella.cormier@kshlerin.io,"Apt. 985 592 Dach Harbor, Efrainbury, RI 66627-3171",9270857836203677,214,2018-10-16 +paid,Morty Jr.,dean.hayes@heel.biz,"Suite 346 8586 Margaret Tunnel, Malindaburgh, NH 38356",8024403170168208,576,2018-10-13 +cancelled,Unity,louvenia_cronin@wiegandabernathy.biz,"865 Dooley Junctions, Orrinton, WV 19481-3299",9959247054971075,643,2018-09-30 +complete,Jerry's Mytholog,jevon.kovacek@dachyost.io,"Suite 567 91794 Chesley Throughway, North Garretshire, AZ 73956-9458",2150669151440771,593,2018-10-02 +complete,Tinkles,michel.fadel@deckow.info,"7831 Thora Courts, New Soledad, DE 88327-6437",4873398449388634,784,2018-10-12 +cancelled,Krombopulos Michael,zoe@medhurstratke.name,"939 Kieran Freeway, Lake Timmothyland, LA 30967-1548",7443128064834304,139,2018-09-30 +cancelled,Eyeholes Man,francisca@runolfon.org,"84795 Alfonso Valleys, North Omabury, MN 27304-9051",3319688530104246,751,2018-10-01 +complete,Squanchy,genesis@kris.org,"360 Sabrina Pass, Lake Nelsmouth, GA 73584",6302929895833513,432,2018-10-07 +paid,King Jellybean,kaya_heathcote@nicolas.name,"3311 Lehner Fork, Port Linnieburgh, NH 23448-8977",1700533053092453,400,2018-10-15 diff --git a/db/product_seeds.csv b/db/product_seeds.csv new file mode 100644 index 0000000000..08b11c1dca --- /dev/null +++ b/db/product_seeds.csv @@ -0,0 +1,51 @@ +name,price,photo,stock,active,category,rating +Simba,7.6,http://placekitten.com/200/300,38,true,British Semipi-longhair,5 +Oscar,28.22,http://placekitten.com/200/300,51,true,Manx,3 +Lily,38.06,http://placekitten.com/200/300,99,true,Aegean,1 +Angel,36.92,http://placekitten.com/200/300,74,true,Devon Rex,5 +Chloe,1.09,http://placekitten.com/200/300,79,true,Cheetoh,2 +Sam,61.39,http://placekitten.com/200/300,30,true,Cheetoh,4 +Bella,50.37,http://placekitten.com/200/300,11,true,Snowshoe,2 +Jasper,78.43,http://placekitten.com/200/300,94,true,Turkish Van,4 +Simba,93.17,http://placekitten.com/200/300,69,true,British Shorthair,1 +Poppy,87.13,http://placekitten.com/200/300,64,true,Birman,1 +Alfie,42.78,http://placekitten.com/200/300,65,true,Chantilly-Tiffany,2 +Misty,65.09,http://placekitten.com/200/300,85,false,Oriental Bicolor,1 +Charlie,60.33,http://placekitten.com/200/300,26,true,Kurilian Bobtail,1 +Angel,56.59,http://placekitten.com/200/300,56,true,Suphalak,1 +Sam,33.04,http://placekitten.com/200/300,70,true,Siamese,5 +Smudge,36.97,http://placekitten.com/200/300,33,true,Serengeti,4 +Chloe,65.61,http://placekitten.com/200/300,56,false,Asian Semi-longhair,3 +Missy,78.32,http://placekitten.com/200/300,81,true,Singapura,4 +Chloe,8.73,http://placekitten.com/200/300,96,true,"Himalayan, or Colorpoint Persian",5 +Max,90.54,http://placekitten.com/200/300,53,true,Foldex Cat,1 +Jasper,14.14,http://placekitten.com/200/300,44,true,Javanese,4 +Lily,2.0,http://placekitten.com/200/300,40,true,Peterbald,5 +Alfie,69.29,http://placekitten.com/200/300,97,true,Korat,5 +Molly,27.14,http://placekitten.com/200/300,98,false,Korean Bobtail,3 +Jasper,67.74,http://placekitten.com/200/300,93,true,Oregon Rex,1 +Oliver,99.46,http://placekitten.com/200/300,87,true,Sokoke,1 +Poppy,23.38,http://placekitten.com/200/300,76,true,Savannah,1 +Oscar,27.25,http://placekitten.com/200/300,75,true,Siberian,4 +Smudge,34.18,http://placekitten.com/200/300,12,false,Mekong Bobtail,2 +Lucky,55.92,http://placekitten.com/200/300,47,true,Oriental Longhair,3 +Max,27.0,http://placekitten.com/200/300,47,true,Ocicat,2 +Sam,13.07,http://placekitten.com/200/300,88,true,Bombay,1 +Oscar,96.54,http://placekitten.com/200/300,71,true,Havana Brown,3 +Chloe,39.78,http://placekitten.com/200/300,10,true,Chartreux,5 +Felix,11.08,http://placekitten.com/200/300,97,true,Chausie,4 +Oscar,68.75,http://placekitten.com/200/300,66,true,Sokoke,2 +Misty,56.56,http://placekitten.com/200/300,47,true,Persian (Modern Persian Cat),1 +Lily,90.11,http://placekitten.com/200/300,73,true,Australian Mist,4 +Chloe,97.19,http://placekitten.com/200/300,80,true,California Spangled,1 +Lucy,84.2,http://placekitten.com/200/300,97,true,Cornish Rex,4 +Lily,77.42,http://placekitten.com/200/300,54,true,Ocicat,3 +Coco,31.88,http://placekitten.com/200/300,15,true,Mekong Bobtail,4 +Lily,14.97,http://placekitten.com/200/300,47,true,Korn Ja,1 +Lucky,62.4,http://placekitten.com/200/300,34,false,Ukrainian Levkoy,5 +Coco,16.26,http://placekitten.com/200/300,92,true,Exotic Shorthair,5 +Lucy,97.49,http://placekitten.com/200/300,73,true,Birman,1 +Sooty,1.53,http://placekitten.com/200/300,46,false,British Semipi-longhair,5 +Shadow,74.48,http://placekitten.com/200/300,55,true,"Dwarf cat, or Dwelf",5 +Chloe,8.8,http://placekitten.com/200/300,97,true,American Curl,3 +Simba,74.04,http://placekitten.com/200/300,97,true,Suphalak,4 From ba813c7612a2e88479e71b359d60b050605788f1 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 14:55:37 -0700 Subject: [PATCH 022/234] Add flash error handling and redirects to Merchants controller --- app/controllers/merchants_controller.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 153df82e6e..545342cf7d 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -4,7 +4,16 @@ def new end def create + #change for OAuth sign in @merchant = Merchant.new(merchant_params) + + if @merchant.save + flash[:success] = "Successfully created new merchant" + redirect_to merchant_path(@merchant) + else + flash.now[:error] = "Merchant not created. Please try again" + render :new, status: :bad_request + end end def show @@ -24,14 +33,18 @@ def update @merchant = Merchant.find(params[:id]) if @merchant.save(merchant_params) + flash[:success] = "Successfully updated merchant." redirect_to merchant_path(@merchant) else - render :edit + flash.now[:error] = "Invalid merchant information" + render :edit, status: :not_found end end def destroy + # Add sessions id / OAuth handling @merchant.destroy + redirect_to merchants_path end private From 0497985a54b8f40d2f06d42ed949bf4075fab8bf Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 14:56:10 -0700 Subject: [PATCH 023/234] add script for seeds --- db/seeds.rb | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index c55cfe3254..1920684836 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,15 +1,35 @@ -# 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' + + merchant_file = Rails.root.join('db', 'merchant_seeds.csv') +order_item_file = Rails.root.join('db', 'order_item_seeds.csv') +order_file = Rails.root.join('db', 'order_seeds.csv') +product_file = Rails.root.join('db', 'product_seeds.csv') CSV.foreach(merchant_file, headers: true, header_converters: :symbol, converters: :all) do |row| data = Hash[row.headers.zip(row.fields)] puts data Merchant.create!(data) end + +CSV.foreach(order_file, headers: true, header_converters: :symbol, converters: :all) do |row| + data = Hash[row.headers.zip(row.fields)] + puts data + Order.create!(data) +end + +CSV.foreach(product_file, headers: true, header_converters: :symbol, converters: :all) do |row| + data = Hash[row.headers.zip(row.fields)] + puts data + merchant = Merchant.all.shuffle.first + Product.create!(data, merchant: merchant) +end + + +CSV.foreach(order_item_file, headers: true, header_converters: :symbol, converters: :all) do |row| + data = Hash[row.headers.zip(row.fields)] + puts data + product = Product.all.shuffle.first + order = Order.all.shuffle.first + OrderItem.create!(data, product: product, order: order) +end From 90961bc7fcad33a673e98bdccce0f3a5ed81926c Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 15:00:07 -0700 Subject: [PATCH 024/234] Add merchants resources to routes --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 787824f888..a68873db16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + resources :merchants end From 0cb474bbc4bc64b653856928c86cdc4a18e23f68 Mon Sep 17 00:00:00 2001 From: Valerie Gidzinski Date: Thu, 18 Oct 2018 15:05:06 -0700 Subject: [PATCH 025/234] Debug and complete seed scripts for all models --- db/seeds.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 1920684836..d2370be50e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -22,7 +22,9 @@ data = Hash[row.headers.zip(row.fields)] puts data merchant = Merchant.all.shuffle.first - Product.create!(data, merchant: merchant) + product = Product.new(data) + product.update_attributes(merchant: merchant) + product.save! end @@ -31,5 +33,7 @@ puts data product = Product.all.shuffle.first order = Order.all.shuffle.first - OrderItem.create!(data, product: product, order: order) + orderitem = OrderItem.new(data) + orderitem.update_attributes(order: order, product: product) + orderitem.save! end From a33bf08b0033fc1167e2c9d48ea956b2667adea7 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 15:45:02 -0700 Subject: [PATCH 026/234] add view show page for order --- app/models/order.rb | 3 +++ app/models/order_item.rb | 4 ++++ app/models/product.rb | 2 +- app/views/orders/show.html.erb | 24 ++++++++++++++++++++++++ db/seeds.rb | 1 - 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index ec7ca6a854..3750ff68de 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -3,4 +3,7 @@ class Order < ApplicationRecord has_many :order_items + def total_price + return self.order_items.sum { |item| item.price} + end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index eecf9e7ebf..df741604df 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,4 +1,8 @@ class OrderItem < ApplicationRecord belongs_to :product belongs_to :order + + def price + return self.product.price * self.quantity + end end diff --git a/app/models/product.rb b/app/models/product.rb index b792e868ee..a2679e21d4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -3,5 +3,5 @@ class Product < ApplicationRecord has_many :reviews has_many :order_items - + end diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index e69de29bb2..d5bd411fa8 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -0,0 +1,24 @@ +

Order Confirmation

+ +

<%= @order.created_at %>

+ + + + + + + + + + + + + <% @order.order_items.each do |item| %> + + + + + + <% end %> +
Name Quantity Price Status
<%= item.product.name %> <%= item.quantity %> <%= item.price %> + <%= item.status %>
diff --git a/db/seeds.rb b/db/seeds.rb index d2370be50e..58b2085c1e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -27,7 +27,6 @@ product.save! end - CSV.foreach(order_item_file, headers: true, header_converters: :symbol, converters: :all) do |row| data = Hash[row.headers.zip(row.fields)] puts data From 8e6aaaece8431717c3ed1f3bca544a0096329470 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 15:48:22 -0700 Subject: [PATCH 027/234] add total line at end of show table --- app/models/order.rb | 2 +- app/views/orders/show.html.erb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 3750ff68de..e226c735b3 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -3,7 +3,7 @@ class Order < ApplicationRecord has_many :order_items - def total_price + def price return self.order_items.sum { |item| item.price} end end diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index d5bd411fa8..b65d341703 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -8,8 +8,8 @@ Name Quantity - Price Status + Price @@ -17,8 +17,13 @@ <%= item.product.name %> <%= item.quantity %> - <%= item.price %> <%= item.status %> + <%= item.price %> <% end %> + + + Total + <%= @order.price %> + From 2bfb0664b2bdf19fe09f4efdaf0a715a9318b2dd Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 15:56:38 -0700 Subject: [PATCH 028/234] Comment out all CRUD except for show for Merchants --- app/controllers/merchants_controller.rb | 88 +++++++++++++------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 545342cf7d..ea802887f9 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,51 +1,53 @@ class MerchantsController < ApplicationController - def new - @merchant = Merchant.new - end - def create - #change for OAuth sign in - @merchant = Merchant.new(merchant_params) - - if @merchant.save - flash[:success] = "Successfully created new merchant" - redirect_to merchant_path(@merchant) - else - flash.now[:error] = "Merchant not created. Please try again" - render :new, status: :bad_request - end - end + # Sessions takes most of CRUD for Merchants? + + # def new + # @merchant = Merchant.new + # end + # + # def create + # @merchant = Merchant.new(merchant_params) + # + # if @merchant.save + # flash[:success] = "Successfully created new merchant" + # redirect_to merchant_path(@merchant) + # else + # flash.now[:error] = "Merchant not created. Please try again" + # render :new, status: :bad_request + # end + # end def show @merchant = Merchant.find_by(id: params[:id]) - render_404 unless @merchant - end - - def index - @merchants = Merchant.all - end - - def edit - @merchant = Merchant.find(params[:id]) - end - - def update - @merchant = Merchant.find(params[:id]) - - if @merchant.save(merchant_params) - flash[:success] = "Successfully updated merchant." - redirect_to merchant_path(@merchant) - else - flash.now[:error] = "Invalid merchant information" - render :edit, status: :not_found - end - end - - def destroy - # Add sessions id / OAuth handling - @merchant.destroy - redirect_to merchants_path - end + head :not_found unless @merchant + end + + # def index + # @merchants = Merchant.all + # end + + # def edit + # @merchant = Merchant.find(params[:id]) + # end + # + # def update + # @merchant = Merchant.find(params[:id]) + # + # if @merchant.save(merchant_params) + # flash[:success] = "Successfully updated merchant." + # redirect_to merchant_path(@merchant) + # else + # flash.now[:error] = "Invalid merchant information" + # render :edit, status: :not_found + # end + # end + + # def destroy + # # Add sessions id / OAuth handling + # @merchant.destroy + # redirect_to merchants_path + # end private From 6d883dbf00ad50a35ee87b813ac3f2d501c98e21 Mon Sep 17 00:00:00 2001 From: Aurea Date: Thu, 18 Oct 2018 15:56:59 -0700 Subject: [PATCH 029/234] add delete button in order show --- app/views/orders/show.html.erb | 2 ++ test/controllers/orders_controller_test.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index b65d341703..d6819efa3d 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -27,3 +27,5 @@ <%= @order.price %> + +<%= link_to "Cancel Order", order_path(@order), class: "btn btn-danger", method: :delete %> diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 9571ec809b..cec963b8cb 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -110,7 +110,7 @@ end describe "destroy" do - it "succeeds for an extant work ID" do + it "succeeds for an extant work ID with status not cancelled" do expect{ delete order_path(existing_order.id) }.must_change('Order.count', -1) From 98e2fc64aa4d19c58cc5bb4585787ceb439c4dda Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 15:57:17 -0700 Subject: [PATCH 030/234] Add Merchants controller show page --- app/views/merchants/show.html.erb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/views/merchants/show.html.erb diff --git a/app/views/merchants/show.html.erb b/app/views/merchants/show.html.erb new file mode 100644 index 0000000000..5d02e15f03 --- /dev/null +++ b/app/views/merchants/show.html.erb @@ -0,0 +1,2 @@ +

Merchant Show Page

+

This is an individual merchant's page

From f6af46ddefaffbb9bfb37642567ae7112ad1c521 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 16:05:32 -0700 Subject: [PATCH 031/234] Add Gemfiles for OAuth --- Gemfile | 5 +++++ Gemfile.lock | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6219256bd8..528aea1579 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,11 @@ gem 'jbuilder', '~> 2.5' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false +# OAuth +gem 'omniauth' +gem 'omniauth-github' + + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 51100b2a1d..b195849f4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,8 @@ GEM debug_inspector (0.0.3) erubi (1.7.1) execjs (2.7.0) + faraday (0.15.3) + multipart-post (>= 1.2, < 3) ffi (1.9.25) formatador (0.2.5) globalid (0.4.1) @@ -100,6 +102,7 @@ GEM guard-minitest (2.4.6) guard-compat (~> 1.2) minitest (>= 3.0) + hashie (3.5.7) i18n (1.1.1) concurrent-ruby (~> 1.0) io-like (0.3.0) @@ -113,6 +116,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + jwt (2.1.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -140,6 +144,8 @@ GEM ruby-progressbar msgpack (1.2.4) multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) nenv (0.3.0) nio4r (2.3.1) nokogiri (1.8.5) @@ -147,6 +153,21 @@ GEM notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) + oauth2 (1.4.1) + faraday (>= 0.8, < 0.16.0) + jwt (>= 1.0, < 3.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + omniauth (1.8.1) + hashie (>= 3.4.6, < 3.6.0) + rack (>= 1.6.2, < 3) + omniauth-github (1.3.0) + omniauth (~> 1.5) + omniauth-oauth2 (>= 1.4.0, < 2.0) + omniauth-oauth2 (1.5.0) + oauth2 (~> 1.1) + omniauth (~> 1.2) pg (1.1.3) popper_js (1.14.3) pry (0.11.3) @@ -257,6 +278,8 @@ DEPENDENCIES listen (>= 3.0.5, < 3.2) minitest-rails minitest-reporters + omniauth + omniauth-github pg (>= 0.18, < 2.0) pry-rails puma (~> 3.11) @@ -274,4 +297,4 @@ RUBY VERSION ruby 2.5.1p57 BUNDLED WITH - 1.16.2 + 1.16.4 From d4ce35ec18b24d1df4bc9caf9c46cd6487e5934a Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 16:06:21 -0700 Subject: [PATCH 032/234] Uncomment merchants#new and merchants#create controller actions --- app/controllers/merchants_controller.rb | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index ea802887f9..93bb83f649 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -2,21 +2,21 @@ class MerchantsController < ApplicationController # Sessions takes most of CRUD for Merchants? - # def new - # @merchant = Merchant.new - # end - # - # def create - # @merchant = Merchant.new(merchant_params) - # - # if @merchant.save - # flash[:success] = "Successfully created new merchant" - # redirect_to merchant_path(@merchant) - # else - # flash.now[:error] = "Merchant not created. Please try again" - # render :new, status: :bad_request - # end - # end + def new + @merchant = Merchant.new + end + + def create + @merchant = Merchant.new(merchant_params) + + if @merchant.save + flash[:success] = "Successfully created new merchant" + redirect_to merchant_path(@merchant) + else + flash.now[:error] = "Merchant not created. Please try again" + render :new, status: :bad_request + end + end def show @merchant = Merchant.find_by(id: params[:id]) From 10480d6d02e00ae54aa098b02fd7dfbdfa614f7f Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 21:26:25 -0700 Subject: [PATCH 033/234] Uncomment merchants#index --- app/controllers/merchants_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 93bb83f649..7f3dc92346 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -23,9 +23,9 @@ def show head :not_found unless @merchant end - # def index - # @merchants = Merchant.all - # end + def index + @merchants = Merchant.all + end # def edit # @merchant = Merchant.find(params[:id]) From 1ade198d3059498ff72b967b54b2f9f7316d75f4 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 21:26:59 -0700 Subject: [PATCH 034/234] Add header and nav bars to application layout view --- app/views/layouts/application.html.erb | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f18f1b6820..b6dfcc32bf 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - Betsy + Petsy <%= csrf_meta_tags %> <%= csp_meta_tag %> @@ -10,6 +10,43 @@ - <%= yield %> +
+

Petsy

+

Purring, Leaping, Wagging, and Swimming into Hearts Around the Globe

+ + + + +
+ +
+ <%= yield %> +
+ +
+ © 2018, Pet Sounds +
From 22eb939d660f4f42d871d3dadaddc8cf83334035 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 21:45:14 -0700 Subject: [PATCH 035/234] Add merchants#index view --- app/views/merchants/index.html.erb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/views/merchants/index.html.erb diff --git a/app/views/merchants/index.html.erb b/app/views/merchants/index.html.erb new file mode 100644 index 0000000000..937ba3ad85 --- /dev/null +++ b/app/views/merchants/index.html.erb @@ -0,0 +1,9 @@ +
+

All Merchants

+ +<%= @merchants.each do |merchant| %> +
    + <%= merchant.name %> +
+ +
From d6e86740ea903a1f176dc9bb07ee2c34cff848fb Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 22:09:53 -0700 Subject: [PATCH 036/234] Edit merchant read view pages --- app/views/merchants/index.html.erb | 12 ++++++------ app/views/merchants/show.html.erb | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/views/merchants/index.html.erb b/app/views/merchants/index.html.erb index 937ba3ad85..a3a97f5207 100644 --- a/app/views/merchants/index.html.erb +++ b/app/views/merchants/index.html.erb @@ -1,9 +1,9 @@
-

All Merchants

- -<%= @merchants.each do |merchant| %> -
    - <%= merchant.name %> -
+

All Merchants

+ <% @merchants.each do |merchant| %> +
    + <%= merchant.username %> +
+ <% end %>
diff --git a/app/views/merchants/show.html.erb b/app/views/merchants/show.html.erb index 5d02e15f03..569e8b2744 100644 --- a/app/views/merchants/show.html.erb +++ b/app/views/merchants/show.html.erb @@ -1,2 +1 @@ -

Merchant Show Page

-

This is an individual merchant's page

+

Merchant <%=@merchant.username%>

From 16ea174fbef1c1093f2c950e43bd597cd13322c6 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 22:10:39 -0700 Subject: [PATCH 037/234] Create merchant fixture data --- test/fixtures/merchants.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml index dc3ee79b5d..d82aaddbf3 100644 --- a/test/fixtures/merchants.yml +++ b/test/fixtures/merchants.yml @@ -4,8 +4,23 @@ # model remove the "{}" from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value -# -two: {} -# column: value +dogdays: + username: dogsdays + email: dogsdays@over.com + uid: 1234566765 + provider: github +palomino: + username: palomino + email: horsesgalore@some.com + uid: 312343546676 + provider: github +larry: + username: lizardlarry + email: larry54@over.com + uid: 7123345664 + provider: github +cuteclothes: + username: cuteclothes + email: cuteclothes@shop.com + uid: 1123345666 + provider: github From 20eea4266ece23e74604281b70df7824cecf2590 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 22:53:12 -0700 Subject: [PATCH 038/234] Gem and file addition for Github OAuth --- .gitignore | 3 +++ Gemfile | 1 + Gemfile.lock | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 18b43c9cd2..c0811eb75d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +#Ignore env file for Github Auth +.env diff --git a/Gemfile b/Gemfile index 528aea1579..a249669efd 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem 'dotenv-rails' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index b195849f4c..31f10ff853 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,10 @@ GEM concurrent-ruby (1.0.5) crass (1.0.4) debug_inspector (0.0.3) + dotenv (2.5.0) + dotenv-rails (2.5.0) + dotenv (= 2.5.0) + railties (>= 3.2, < 6.0) erubi (1.7.1) execjs (2.7.0) faraday (0.15.3) @@ -270,6 +274,7 @@ DEPENDENCIES byebug capybara (>= 2.15) chromedriver-helper + dotenv-rails guard guard-minitest jbuilder (~> 2.5) From 366b26618bdd18d895d7d63915bd119cf905c608 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 22:54:47 -0700 Subject: [PATCH 039/234] Add Sessions Controller and controller test --- app/assets/javascripts/sessions.js | 2 ++ app/assets/stylesheets/sessions.scss | 3 ++ app/controllers/sessions_controller.rb | 30 ++++++++++++++++++++ app/helpers/sessions_helper.rb | 2 ++ test/controllers/sessions_controller_test.rb | 7 +++++ 5 files changed, 44 insertions(+) create mode 100644 app/assets/javascripts/sessions.js create mode 100644 app/assets/stylesheets/sessions.scss create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 test/controllers/sessions_controller_test.rb diff --git a/app/assets/javascripts/sessions.js b/app/assets/javascripts/sessions.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/sessions.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 0000000000..ccb1ed25b2 --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..fb1edce870 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,30 @@ +class SessionsController < ApplicationController + def create + merch_hash = request.env['omniauth.auth'] + + merchant = Merchant.find_by(uid: merch_hash[:uid], provider: merch_hash[:provider]) + + if merchant + flash[:success] = "Welcome #{merchant.username}" + else + merchant = Merchant.create_from_github(merch_hash) + + if merchant.save + flash[:success] = "Logged in as merchant #{merchant.username}" + else + flash[:error] = "Could not create new account: #{merchant.errors.messages}" + redirect_to root_path + return + end + end + + session[:user_id] = merchant.id + redirect_to root_path + end + + def logout + session[:user_id] = nil + flash[:success] = "Successfully logged out" + redirect_to root_path + end +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 0000000000..309f8b2eb3 --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000000..c2632a720b --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe SessionsController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end From df8fbe85afba19a3ed76c95b58c2875a33f8805a Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 22:57:25 -0700 Subject: [PATCH 040/234] Add config initializer for OmniAuth --- config/initializers/omniauth.rb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 config/initializers/omniauth.rb 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 From 57841c9fecaf245df47637a2d440e21affa1a824 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:14:36 -0700 Subject: [PATCH 041/234] Edit local variable in sessions#create --- app/controllers/sessions_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index fb1edce870..dc1126ad26 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,13 +1,13 @@ class SessionsController < ApplicationController def create - merch_hash = request.env['omniauth.auth'] + auth_hash = request.env['omniauth.auth'] - merchant = Merchant.find_by(uid: merch_hash[:uid], provider: merch_hash[:provider]) + merchant = Merchant.find_by(uid: auth_hash[:uid], provider: auth_hash[:provider]) if merchant flash[:success] = "Welcome #{merchant.username}" else - merchant = Merchant.create_from_github(merch_hash) + merchant = Merchant.create_from_github(auth_hash) if merchant.save flash[:success] = "Logged in as merchant #{merchant.username}" From 8894cdec0bff83cf0f9c45b109e5a57c3ffa830e Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:15:17 -0700 Subject: [PATCH 042/234] Add create_from_github method for merchant model --- app/models/merchant.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index 7ddb9ab183..668a0d6ff2 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -1,4 +1,16 @@ class Merchant < ApplicationRecord - has_many :products + + validates :username, uniqueness: true, presence: true + validates :email, uniqueness: true, presence: true + + def self.create_from_github(auth_hash) + merchant = Merchant.new + merchant.username = auth_hash['info']['nickname'] + merchant.email = auth_hash['info']['email'] + merchant.uid = auth_hash['uid'] + merchant.provider = 'github' + + return merchant + end end From 48d00e676c8de274a8a983a05b3542e96d19217b Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:15:53 -0700 Subject: [PATCH 043/234] Add sessions and auth route to routes --- config/routes.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index a68873db16..19a49f2a9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,9 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :merchants + + resources :sessions, only: [:new, :create] + + get '/auth/:provider/callback', to: "sessions#create" + post '/sessions/logout', to: 'sessions#logout', as: 'logout' end From 03eb83bf4a267d6e87c16712b471b49b8000fb50 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:16:34 -0700 Subject: [PATCH 044/234] Edit merchant yml uid numbers shorter --- test/fixtures/merchants.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml index d82aaddbf3..43a0ef2ae1 100644 --- a/test/fixtures/merchants.yml +++ b/test/fixtures/merchants.yml @@ -7,20 +7,20 @@ dogdays: username: dogsdays email: dogsdays@over.com - uid: 1234566765 + uid: 12345 provider: github palomino: username: palomino email: horsesgalore@some.com - uid: 312343546676 + uid: 31234 provider: github larry: username: lizardlarry email: larry54@over.com - uid: 7123345664 + uid: 7124 provider: github cuteclothes: username: cuteclothes email: cuteclothes@shop.com - uid: 1123345666 + uid: 1123 provider: github From 8be0c4cd02aa010051bc86b52b498016f5b08935 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:27:15 -0700 Subject: [PATCH 045/234] Add test merchant controller test for index --- test/controllers/merchants_controller_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb index 6eb57f7baa..ae5e6e77dd 100644 --- a/test/controllers/merchants_controller_test.rb +++ b/test/controllers/merchants_controller_test.rb @@ -1,7 +1,9 @@ require "test_helper" describe MerchantsController do - # it "must be a real test" do - # flunk "Need real tests" - # end + it "should get index" do + get merchants_path + must_respond_with :success + end + end From 098c4d71655adee11df3d03436beba3a0210fed8 Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Thu, 18 Oct 2018 23:29:11 -0700 Subject: [PATCH 046/234] Add spacing to merchants_controller methods --- app/controllers/merchants_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 7f3dc92346..c1fbdde8eb 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,11 +1,10 @@ class MerchantsController < ApplicationController - # Sessions takes most of CRUD for Merchants? - def new @merchant = Merchant.new end + def create @merchant = Merchant.new(merchant_params) @@ -18,11 +17,13 @@ def create end end + def show @merchant = Merchant.find_by(id: params[:id]) head :not_found unless @merchant end + def index @merchants = Merchant.all end From 0bca6373d8b2bb22d3f5cd98493063a6cc02f79a Mon Sep 17 00:00:00 2001 From: Sigrid Benezra Date: Fri, 19 Oct 2018 00:20:49 -0700 Subject: [PATCH 047/234] Finished basic product controller methods, views, and testing. --- app/controllers/products_controller.rb | 14 ++- app/models/product.rb | 4 +- app/views/products/_product_form.html.erb | 11 ++ app/views/products/edit.html.erb | 3 + app/views/products/new.html.erb | 4 + app/views/products/show.html.erb | 13 ++ test/controllers/products_controller_test.rb | 121 ++++++++++++++++++- test/fixtures/products.yml | 9 +- 8 files changed, 165 insertions(+), 14 deletions(-) create mode 100644 app/views/products/_product_form.html.erb create mode 100644 app/views/products/edit.html.erb create mode 100644 app/views/products/new.html.erb create mode 100644 app/views/products/show.html.erb diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index cc9f541d9b..21e8e1d68a 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -1,11 +1,12 @@ class ProductsController < ApplicationController + before_action :find_product, only: [:show, :edit, :update, :destroy] + def index @products = Product.all end - def show - @product = Product.find_by(params[:id]) + def show; end def new @@ -21,12 +22,10 @@ def create end end - def edit - @product = Product.find_by(product_params[:id]) + def edit; end def update - @product = Product.find_by(product_params[:id]) if @product.update(product_params) redirect_to product_path(@product) else @@ -43,4 +42,9 @@ def product_params params.require(:product).permit(:name, :price, :photo, :stock, :active, :category, :rating, :merchant_id) end + def find_product + @product = Product.find_by(id: params[:id]) + head :not_found unless @product + end + end diff --git a/app/models/product.rb b/app/models/product.rb index b792e868ee..5d9cc67cd6 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,7 +1,7 @@ class Product < ApplicationRecord - belongs_to :merchant + # belongs_to :merchant has_many :reviews has_many :order_items - + end diff --git a/app/views/products/_product_form.html.erb b/app/views/products/_product_form.html.erb new file mode 100644 index 0000000000..c5cc2149b0 --- /dev/null +++ b/app/views/products/_product_form.html.erb @@ -0,0 +1,11 @@ +
+ <%= form_with model: @product do |f| %> +
+ <%= f.label :name %> + <%= f.text_field :name %> +
+
+ <%= f.submit class: "btn btn-primary" %> +
+ <% end %> +
diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb new file mode 100644 index 0000000000..4b80c9787f --- /dev/null +++ b/app/views/products/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Product

+ +<%= render partial: "product_form" %> diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb new file mode 100644 index 0000000000..81ac5f1d3b --- /dev/null +++ b/app/views/products/new.html.erb @@ -0,0 +1,4 @@ +

New Product

+ + +<%= render partial: "product_form" %> diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb new file mode 100644 index 0000000000..d085b29112 --- /dev/null +++ b/app/views/products/show.html.erb @@ -0,0 +1,13 @@ +

Product Detail

+<% if @product %> + +
    +
  • Name: <%= "#{@product.name}" %>
  • +
  • Price: <%= "#{@product.price}" %>
  • +
  • Photo: <%= "#{@product.photo}" %>
  • +
  • In Stock: <%= "#{@product.stock}" %>
  • +
  • Category: <%= "#{@product.category}" %>
  • +
  • Rating: <%= "#{@product.rating}" %>
  • +
  • Merchant: <%= "#{@product.merchant_id}" %>
  • +
+<% end %> diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 9d67780f6c..f5a97ced76 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -1,12 +1,127 @@ require "test_helper" +require 'pry' describe ProductsController do # it "must be a real test" do # flunk "Need real tests" # end - it "succeeds when there are no products" do - get products_path - + describe "index" do + it "succeeds when there are no products" do + get products_path + + must_respond_with :success + end + + it "succeeds when there are products" do + end + end + + describe "show" do + it "should respond with success for showing an existing product" do + + product = products.first + id = product.id + + get product_path(id) + + must_respond_with :success + end + + it "should respond with not found for showing a non-existing product" do + + product = products.first + id = product.id + + get product_path(id) + must_respond_with :success + # Act + product.delete + + get product_path(id) + + # Assert + must_respond_with :missing + end + + end + + describe "new" do + it "successfully retrieves new page" do + + get new_product_path + must_respond_with :success + + end + end + + describe "create" do + it "creates new product when given valid data" do + product_hash = { + product: { + name: "Test product", + price: 3 + } + } + + expect { + post products_path, params: product_hash }.must_change 'Product.count', 1 + + must_respond_with :redirect + + expect(Product.count).must_equal 3 + expect(Product.last.name).must_equal product_hash[:product][:name] + end + end + + describe "edit" do + it "responds with success for an existing product" do + get edit_product_path(Product.first) + + must_respond_with :success + end + + it "responds with not_found for a product that doesn't exist" do + product = Product.first.destroy + + get edit_product_path(product) + + must_respond_with :not_found + end + end + + describe "update" do + it "should show success when showing an existing product" do + + product = products.first + + get product_path(product.id) + + must_respond_with :success + end + + it "should return error message if product doesn't exist" do + + product = products.first + id = product.id + product.destroy + + get product_path(id) + + must_respond_with :not_found + end + end + + describe "destroy" do + it "can destroy an existing product" do + product = products.first + + expect { + delete product_path(product) + }.must_change('Product.count', -1) + + must_respond_with :redirect + must_redirect_to products_path + end end end diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index dc3ee79b5d..fbe0a08259 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -4,8 +4,9 @@ # model remove the "{}" from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value +one: + name: test product 1 + # -two: {} -# column: value +two: + name: test product 2 From 8b8af6368f4589cb7329022d53af89ab99d58e00 Mon Sep 17 00:00:00 2001 From: Aurea Date: Fri, 19 Oct 2018 08:48:30 -0700 Subject: [PATCH 048/234] add order form --- app/controllers/orders_controller.rb | 3 +-- app/views/orders/new.html.erb | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index da6705466d..e68c10fc78 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -8,7 +8,7 @@ def index end def new - @order = Order.new + @order = Order.new(status: 'paid') end def create @@ -47,7 +47,6 @@ def destroy def order_params params.require(:order).permit( - :status, :name, :email, :address, diff --git a/app/views/orders/new.html.erb b/app/views/orders/new.html.erb index e69de29bb2..4b2fc37989 100644 --- a/app/views/orders/new.html.erb +++ b/app/views/orders/new.html.erb @@ -0,0 +1 @@ +<%= render partial: "order_form" %> From 5eaef3395bf8e9ebf217ed34610ed78355f85a8f Mon Sep 17 00:00:00 2001 From: Aurea Date: Fri, 19 Oct 2018 08:59:20 -0700 Subject: [PATCH 049/234] fix expiration date format --- app/controllers/order_items_controller.rb | 1 + app/views/layouts/_form_errors.html.erb | 15 +++++++++++ app/views/orders/_order_form.html.erb | 31 +++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 app/views/layouts/_form_errors.html.erb create mode 100644 app/views/orders/_order_form.html.erb diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 7980d52e21..88ff3e6cc9 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -13,6 +13,7 @@ def create @order_item = OrderItem.new(order_item_params) # order item is created when added to cart if @order_item.save + flash[:success] = "Item added to cart." redirect_back # where do we want to go/redirect_to if an order item is successfully saved? diff --git a/app/views/layouts/_form_errors.html.erb b/app/views/layouts/_form_errors.html.erb new file mode 100644 index 0000000000..4f9c141b70 --- /dev/null +++ b/app/views/layouts/_form_errors.html.erb @@ -0,0 +1,15 @@ +<% if model.errors.messages.any? %> +
+

There were some problems. Please fix them.

+
    + <% model.errors.messages.each do |field, problem_list| %> + <% problem_list.each do |problem| %> +
  • + <%= field %> + <%= problem %> +
  • + <% end %> + <% end %> +
+
+<% end %> diff --git a/app/views/orders/_order_form.html.erb b/app/views/orders/_order_form.html.erb new file mode 100644 index 0000000000..a61eca526e --- /dev/null +++ b/app/views/orders/_order_form.html.erb @@ -0,0 +1,31 @@ +<%= render partial: 'layouts/form_errors', +locals: { + model: @order +} +%> + +<%= form_with model: @order, class: 'order-form' do |f| %> + +

New Order

+ + <%= f.label :name %> + <%= f.text_field :name, class: "form-control" %> + + <%= f.label :email %> + <%= f.text_field :email, class: "form-control" %> + + <%= f.label :address %> + <%= f.text_field :address, class: "form-control" %> + + <%= f.label :cc_num %> + <%= f.text_field :cc_num, class: "form-control" %> + + <%= f.label :cc_cvv %> + <%= f.text_field :cc_cvv, class: "form-control" %> + + <%= f.label :cc_expiration, 'Expiration date' %> + <%= f.date_select :cc_expiration, :discard_day => true, :start_year => Date.today.year, :end_year => (Date.today.year+10), :use_month_numbers => true, :order => [:month, :year], class: "form-control" %> + + <%= f.submit "Submit Order", class: "order-form-submit-button btn btn-primary" %> + +<% end %> From dd17540a788a0486fcc21e340a6c8e27b8481205 Mon Sep 17 00:00:00 2001 From: Sigrid Benezra Date: Fri, 19 Oct 2018 09:00:37 -0700 Subject: [PATCH 050/234] Update controller tests to handle link between product and merchant. --- app/models/product.rb | 2 +- test/controllers/products_controller_test.rb | 3 ++- test/fixtures/merchants.yml | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/product.rb b/app/models/product.rb index 5d9cc67cd6..a2679e21d4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,5 +1,5 @@ class Product < ApplicationRecord - # belongs_to :merchant + belongs_to :merchant has_many :reviews has_many :order_items diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index f5a97ced76..84c2e40c21 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -60,7 +60,8 @@ product_hash = { product: { name: "Test product", - price: 3 + price: 3, + merchant_id: Merchant.first.id } } diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml index dc3ee79b5d..a5acf75f21 100644 --- a/test/fixtures/merchants.yml +++ b/test/fixtures/merchants.yml @@ -4,8 +4,8 @@ # model remove the "{}" from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value +one: + username: name1 # -two: {} -# column: value +two: + username: name2 From e53c0bf8f645752509f8e86ca91bb24279c7bb13 Mon Sep 17 00:00:00 2001 From: Sigrid Benezra Date: Fri, 19 Oct 2018 10:30:35 -0700 Subject: [PATCH 051/234] Add edit link to product show page --- app/views/products/show.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index d085b29112..48a633a92a 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -10,4 +10,8 @@
  • Rating: <%= "#{@product.rating}" %>
  • Merchant: <%= "#{@product.merchant_id}" %>
  • + +

    + <%= link_to "Edit", edit_product_path(@product), class: "btn btn-primary" %> +

    <% end %> From 521005fbe2f559b7c8662d2b506a7872a28d6ebc Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Fri, 19 Oct 2018 11:19:30 -0700 Subject: [PATCH 052/234] Add group pets photo to images --- app/assets/images/petstogether.jpeg | Bin 0 -> 18897 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/assets/images/petstogether.jpeg diff --git a/app/assets/images/petstogether.jpeg b/app/assets/images/petstogether.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..1f41b75a6ba4884fa53c2a859e2552908e0bc4dd GIT binary patch literal 18897 zcmeFYbyQqmw=Gy$&_Ey*Zo%E%wV)ulySuw51PfYd6~W!zJ%QlvMUdcb!8IX|-}kz2 z-@c=J^!IM}pS?$|G1jTQPgTvc_t~q~T=V?>@pl98MiB%C0T2)n0RL)#Hv!Uee)cv1 zfU+`x`Q6X&j^x#4MLOz0FYih1b`|4Ac^p=p8xIqfBOHf0Av7|=;)~b zdZDAgxc@XvbWBVv%olt81`8MaH8vI=F&-TWIUPAMB^eVF0i6IJKM6CpI2#iuvBM z@<8yyX z%15J-uI~kE%$(EmSa^h@V-OG$5tGo-GcYnS^YZZv2nq?y$jX7_6~Ky`TG~3gdin;I zR@OGQcJ>aQUfw>we*OVr;SrIaqoQMyQ&OR@v@huy1%*Y$C8cHM6%CC|%`L5M?H%9y z`UeJwhDSzc=jIpSi$9i@H@CKTcK7xV4v#J_udZ)y@9rNS|G|X-K>DAs{sY;6!G-&R z3lSL^2^sYtTnLE1{{Y8DMtR5e3QtNM)!h9pHTNepeCee8`d)Mz9*uLLg~tpA0WI$) z-Nir9{)Oz{0~Y$e%R$u)EC^cvZ z<01uZACUq-!`}t+tm?O@nlroibo$7e}+% z#DZEnc8movHd1oYaEMvhp9n!-LFLH8HV`?LGF3=Pm7(dKHr8g4hjiz>-0Xor{h-Q4oy(&RvFBJjh|) z-aIaOh>BkXJ`@|og$*qn@;4Xj2a!hY`3+4D>WDTfd~m|4cCW@tAZzT3=Nmk|;tk*Z z(`Y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mS$x4x5Xiq2Ekp3AvqX^2IX3tIn9!rzzO3X>(fM@KfSw$(Il>uEM7Y z%dYI4_}uVT{Ox19>rA>=iX>=uv%1;xW^#N@>AMs4vaea1F(=QVdUEVi(e|r}JNI8( zR$TC6dsf%^qU5=KZ%@tMIR9Z{_?s;&b<;oJdb#A(gJlO+@BV#gYsT7#eg$K8)KfVOUDA#CQO`rI5$Mw)9#nX%Vo~gg`t-341@tNDcRq(Lwp6gaeChPdg98u)z p?K=+KGwmImE#$O@CxdBG>#+;gp|dm_$T+5fm_c}A)iD0Q2>|(17A61y literal 0 HcmV?d00001 From 5d1edb3dbfa80d6c986342e9419c0d34b092b18c Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Fri, 19 Oct 2018 11:29:30 -0700 Subject: [PATCH 053/234] Add named route to routes for auth callback --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 19a49f2a9e..a704619906 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,6 @@ resources :sessions, only: [:new, :create] - get '/auth/:provider/callback', to: "sessions#create" + get '/auth/:provider/callback', to: "sessions#create", as: 'auth_callback' post '/sessions/logout', to: 'sessions#logout', as: 'logout' end From cf7e2a10b1e283ea063e3eccf531f274f6a1db7f Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Fri, 19 Oct 2018 12:14:17 -0700 Subject: [PATCH 054/234] Add header, nav, and body styling --- app/assets/stylesheets/application.scss | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 8b1701e581..d69d17b0b7 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -16,3 +16,29 @@ @import "bootstrap"; /* Import scss content */ @import "**/*"; + +body { + background: url("petstogether.jpeg") no-repeat fixed center; + background-size: cover; + background-position: 20px 200px 20px; +} + +header { + display: flex; + flex-direction: column; + text-align: center; + color: #191970; + border-bottom: solid .75px #191970; + margin-bottom: 35px; + padding: 10px; +} + +.user-nav-list, .shopping-nav-list { + display: flex; + flex-direction: row; +} + +header a:hover, header a:link, header a:visited { + color: #191970; + text-decoration: none; +} From cb89ba64ba225ecca308b53e5f70d386c2634f4d Mon Sep 17 00:00:00 2001 From: Katricia Smith Date: Fri, 19 Oct 2018 12:14:57 -0700 Subject: [PATCH 055/234] Edit application layout html --- app/views/layouts/application.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b6dfcc32bf..8751a44aec 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,8 +11,8 @@
    -

    Petsy

    -

    Purring, Leaping, Wagging, and Swimming into Hearts Around the Globe

    +

    Petsy

    +

    Purring, Leaping, Wagging, and Swimming into Hearts Around the Globe