From 51ea8fa6dd31dd72bb81de6777d1c832c827b636 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Wed, 18 Apr 2018 12:27:46 -0700 Subject: [PATCH 001/283] generated new rails app to project --- .gitignore | 19 + Gemfile | 72 ++ Gemfile.lock | 236 +++++ 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/_settings.scss | 869 ++++++++++++++++++ app/assets/stylesheets/application.css | 19 + app/assets/stylesheets/browserslist | 4 + .../stylesheets/foundation_and_overrides.scss | 61 ++ app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/controllers/application_controller.rb | 3 + 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 | 19 + 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 | 38 + bin/spring | 17 + bin/update | 29 + bin/yarn | 11 + config.ru | 5 + config/application.rb | 25 + config/boot.rb | 3 + config/cable.yml | 10 + config/database.yml | 85 ++ config/environment.rb | 5 + config/environments/development.rb | 54 ++ config/environments/production.rb | 91 ++ config/environments/test.rb | 42 + .../application_controller_renderer.rb | 8 + config/initializers/assets.rb | 14 + config/initializers/backtrace_silencers.rb | 7 + 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 | 56 ++ config/routes.rb | 3 + config/secrets.yml | 32 + config/spring.rb | 6 + 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 + 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 78 files changed, 2259 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.lock 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/_settings.scss create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/browserslist create mode 100644 app/assets/stylesheets/foundation_and_overrides.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/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/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/secrets.yml create mode 100644 config/spring.rb 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 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..82701fedc8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# 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 + +/node_modules +/yarn-error.log + +.byebug_history diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..8490d0efb5 --- /dev/null +++ b/Gemfile @@ -0,0 +1,72 @@ +source 'https://rubygems.org' + +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://github.com/#{repo_name}.git" +end + + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.1.6' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# Use Puma as the app server +gem 'puma', '~> 3.7' +# 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 'therubyracer', 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 Capistrano for deployment +# gem 'capistrano-rails', group: :development + +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] + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '~> 2.13' + gem 'selenium-webdriver' +end + +group :development do + # Access an IRB console on exception pages or by using <%= 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 + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'jquery-turbolinks' +gem 'jquery-rails' +gem 'foundation-rails' +gem 'normalize-rails' +group :development, :test do + gem 'pry-rails' +end + +group :development do + gem 'better_errors' + gem 'binding_of_caller' +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..d528acb17a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,236 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.1.6) + actionpack (= 5.1.6) + nio4r (~> 2.0) + websocket-driver (~> 0.6.1) + actionmailer (5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.1.6) + actionview (= 5.1.6) + activesupport (= 5.1.6) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.1.6) + activesupport (= 5.1.6) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.1.6) + activesupport (= 5.1.6) + globalid (>= 0.3.6) + activemodel (5.1.6) + activesupport (= 5.1.6) + activerecord (5.1.6) + activemodel (= 5.1.6) + activesupport (= 5.1.6) + arel (~> 8.0) + activesupport (5.1.6) + 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) + arel (8.0.0) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) + better_errors (2.4.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) + builder (3.2.3) + byebug (10.0.2) + capybara (2.18.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (>= 2.0, < 4.0) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + 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.23) + foundation-rails (6.4.3.0) + railties (>= 3.1.0) + sass (>= 3.3.0, < 3.5) + sprockets-es6 (>= 0.9.0) + globalid (0.4.1) + activesupport (>= 4.2.0) + i18n (1.0.1) + concurrent-ruby (~> 1.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) + mail (2.7.0) + mini_mime (>= 0.1.1) + method_source (0.9.0) + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) + minitest-reporters (1.2.0) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + multi_json (1.13.1) + nio4r (2.3.0) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + normalize-rails (4.1.1) + pg (1.0.0) + 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.2) + puma (3.11.4) + rack (2.0.4) + rack-test (1.0.0) + rack (>= 1.0, < 3) + rails (5.1.6) + actioncable (= 5.1.6) + actionmailer (= 5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) + activemodel (= 5.1.6) + activerecord (= 5.1.6) + activesupport (= 5.1.6) + bundler (>= 1.3.0) + railties (= 5.1.6) + 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.1.6) + actionpack (= 5.1.6) + activesupport (= 5.1.6) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.3.1) + rb-fsevent (0.10.3) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + ruby-progressbar (1.9.0) + ruby_dep (1.5.0) + rubyzip (1.2.1) + sass (3.4.25) + 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.11.0) + childprocess (~> 0.5) + rubyzip (~> 1.2) + 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.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-es6 (0.9.2) + babel-source (>= 5.8.11) + babel-transpiler + sprockets (>= 3.0.0) + 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.1.1) + turbolinks-source (~> 5.1) + turbolinks-source (5.1.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.1.9) + execjs (>= 0.3.0, < 3) + web-console (3.6.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + xpath (3.0.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + binding_of_caller + byebug + capybara (~> 2.13) + foundation-rails + jbuilder (~> 2.5) + jquery-rails + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + normalize-rails + pg (>= 0.18, < 2.0) + pry-rails + puma (~> 3.7) + rails (~> 5.1.6) + 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) + +BUNDLED WITH + 1.16.1 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..f04673be81 --- /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 jquery + +// +//= require rails-ujs +//= require foundation +//= require turbolinks +//= require_tree . + +$(function(){ $(document).foundation(); }); 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/_settings.scss b/app/assets/stylesheets/_settings.scss new file mode 100644 index 0000000000..26f74f9494 --- /dev/null +++ b/app/assets/stylesheets/_settings.scss @@ -0,0 +1,869 @@ +// Foundation for Sites Settings +// ----------------------------- +// +// Table of Contents: +// +// 1. Global +// 2. Breakpoints +// 3. The Grid +// 4. Base Typography +// 5. Typography Helpers +// 6. Abide +// 7. Accordion +// 8. Accordion Menu +// 9. Badge +// 10. Breadcrumbs +// 11. Button +// 12. Button Group +// 13. Callout +// 14. Card +// 15. Close Button +// 16. Drilldown +// 17. Dropdown +// 18. Dropdown Menu +// 19. Flexbox Utilities +// 20. Forms +// 21. Label +// 22. Media Object +// 23. Menu +// 24. Meter +// 25. Off-canvas +// 26. Orbit +// 27. Pagination +// 28. Progress Bar +// 29. Prototype Arrow +// 30. Prototype Border-Box +// 31. Prototype Border-None +// 32. Prototype Bordered +// 33. Prototype Display +// 34. Prototype Font-Styling +// 35. Prototype List-Style-Type +// 36. Prototype Overflow +// 37. Prototype Position +// 38. Prototype Rounded +// 39. Prototype Separator +// 40. Prototype Shadow +// 41. Prototype Sizing +// 42. Prototype Spacing +// 43. Prototype Text-Decoration +// 44. Prototype Text-Transformation +// 45. Prototype Text-Utilities +// 46. Responsive Embed +// 47. Reveal +// 48. Slider +// 49. Switch +// 50. Table +// 51. Tabs +// 52. Thumbnail +// 53. Title Bar +// 54. Tooltip +// 55. Top Bar +// 56. Xy Grid + +@import 'util/util'; + +// 1. Global +// --------- + +$global-font-size: 100%; +$global-width: rem-calc(1200); +$global-lineheight: 1.5; +$foundation-palette: ( + primary: #1779ba, + secondary: #767676, + success: #3adb76, + warning: #ffae00, + alert: #cc4b37, +); +$light-gray: #e6e6e6; +$medium-gray: #cacaca; +$dark-gray: #8a8a8a; +$black: #0a0a0a; +$white: #fefefe; +$body-background: $white; +$body-font-color: $black; +$body-font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; +$body-antialiased: true; +$global-margin: 1rem; +$global-padding: 1rem; +$global-position: 1rem; +$global-weight-normal: normal; +$global-weight-bold: bold; +$global-radius: 0; +$global-menu-padding: 0.7rem 1rem; +$global-menu-nested-margin: 1rem; +$global-text-direction: ltr; +$global-flexbox: true; +$global-prototype-breakpoints: false; +$global-button-cursor: auto; +$global-color-pick-contrast-tolerance: 0; +$print-transparent-backgrounds: true; + +@include add-foundation-colors; + +// 2. Breakpoints +// -------------- + +$breakpoints: ( + small: 0, + medium: 640px, + large: 1024px, + xlarge: 1200px, + xxlarge: 1440px, +); +$print-breakpoint: large; +$breakpoint-classes: (small medium large); + +// 3. The Grid +// ----------- + +$grid-row-width: $global-width; +$grid-column-count: 12; +$grid-column-gutter: ( + small: 20px, + medium: 30px, +); +$grid-column-align-edge: true; +$grid-column-alias: 'columns'; +$block-grid-max: 8; + +// 4. Base Typography +// ------------------ + +$header-font-family: $body-font-family; +$header-font-weight: $global-weight-normal; +$header-font-style: normal; +$font-family-monospace: Consolas, 'Liberation Mono', Courier, monospace; +$header-color: inherit; +$header-lineheight: 1.4; +$header-margin-bottom: 0.5rem; +$header-styles: ( + small: ( + 'h1': ('font-size': 24), + 'h2': ('font-size': 20), + 'h3': ('font-size': 19), + 'h4': ('font-size': 18), + 'h5': ('font-size': 17), + 'h6': ('font-size': 16), + ), + medium: ( + 'h1': ('font-size': 48), + 'h2': ('font-size': 40), + 'h3': ('font-size': 31), + 'h4': ('font-size': 25), + 'h5': ('font-size': 20), + 'h6': ('font-size': 16), + ), +); +$header-text-rendering: optimizeLegibility; +$small-font-size: 80%; +$header-small-font-color: $medium-gray; +$paragraph-lineheight: 1.6; +$paragraph-margin-bottom: 1rem; +$paragraph-text-rendering: optimizeLegibility; +$code-color: $black; +$code-font-family: $font-family-monospace; +$code-font-weight: $global-weight-normal; +$code-background: $light-gray; +$code-border: 1px solid $medium-gray; +$code-padding: rem-calc(2 5 1); +$anchor-color: $primary-color; +$anchor-color-hover: scale-color($anchor-color, $lightness: -14%); +$anchor-text-decoration: none; +$anchor-text-decoration-hover: none; +$hr-width: $global-width; +$hr-border: 1px solid $medium-gray; +$hr-margin: rem-calc(20) auto; +$list-lineheight: $paragraph-lineheight; +$list-margin-bottom: $paragraph-margin-bottom; +$list-style-type: disc; +$list-style-position: outside; +$list-side-margin: 1.25rem; +$list-nested-side-margin: 1.25rem; +$defnlist-margin-bottom: 1rem; +$defnlist-term-weight: $global-weight-bold; +$defnlist-term-margin-bottom: 0.3rem; +$blockquote-color: $dark-gray; +$blockquote-padding: rem-calc(9 20 0 19); +$blockquote-border: 1px solid $medium-gray; +$cite-font-size: rem-calc(13); +$cite-color: $dark-gray; +$cite-pseudo-content: '\2014 \0020'; +$keystroke-font: $font-family-monospace; +$keystroke-color: $black; +$keystroke-background: $light-gray; +$keystroke-padding: rem-calc(2 4 0); +$keystroke-radius: $global-radius; +$abbr-underline: 1px dotted $black; + +// 5. Typography Helpers +// --------------------- + +$lead-font-size: $global-font-size * 1.25; +$lead-lineheight: 1.6; +$subheader-lineheight: 1.4; +$subheader-color: $dark-gray; +$subheader-font-weight: $global-weight-normal; +$subheader-margin-top: 0.2rem; +$subheader-margin-bottom: 0.5rem; +$stat-font-size: 2.5rem; + +// 6. Abide +// -------- + +$abide-inputs: true; +$abide-labels: true; +$input-background-invalid: get-color(alert); +$form-label-color-invalid: get-color(alert); +$input-error-color: get-color(alert); +$input-error-font-size: rem-calc(12); +$input-error-font-weight: $global-weight-bold; + +// 7. Accordion +// ------------ + +$accordion-background: $white; +$accordion-plusminus: true; +$accordion-title-font-size: rem-calc(12); +$accordion-item-color: $primary-color; +$accordion-item-background-hover: $light-gray; +$accordion-item-padding: 1.25rem 1rem; +$accordion-content-background: $white; +$accordion-content-border: 1px solid $light-gray; +$accordion-content-color: $body-font-color; +$accordion-content-padding: 1rem; + +// 8. Accordion Menu +// ----------------- + +$accordionmenu-padding: $global-menu-padding; +$accordionmenu-nested-margin: $global-menu-nested-margin; +$accordionmenu-submenu-padding: $accordionmenu-padding; +$accordionmenu-arrows: true; +$accordionmenu-arrow-color: $primary-color; +$accordionmenu-item-background: null; +$accordionmenu-border: null; +$accordionmenu-submenu-toggle-background: null; +$accordion-submenu-toggle-border: $accordionmenu-border; +$accordionmenu-submenu-toggle-width: 40px; +$accordionmenu-submenu-toggle-height: $accordionmenu-submenu-toggle-width; +$accordionmenu-arrow-size: 6px; + +// 9. Badge +// -------- + +$badge-background: $primary-color; +$badge-color: $white; +$badge-color-alt: $black; +$badge-palette: $foundation-palette; +$badge-padding: 0.3em; +$badge-minwidth: 2.1em; +$badge-font-size: 0.6rem; + +// 10. Breadcrumbs +// --------------- + +$breadcrumbs-margin: 0 0 $global-margin 0; +$breadcrumbs-item-font-size: rem-calc(11); +$breadcrumbs-item-color: $primary-color; +$breadcrumbs-item-color-current: $black; +$breadcrumbs-item-color-disabled: $medium-gray; +$breadcrumbs-item-margin: 0.75rem; +$breadcrumbs-item-uppercase: true; +$breadcrumbs-item-separator: true; +$breadcrumbs-item-separator-item: '/'; +$breadcrumbs-item-separator-item-rtl: '\\'; +$breadcrumbs-item-separator-color: $medium-gray; + +// 11. Button +// ---------- + +$button-font-family: inherit; +$button-padding: 0.85em 1em; +$button-margin: 0 0 $global-margin 0; +$button-fill: solid; +$button-background: $primary-color; +$button-background-hover: scale-color($button-background, $lightness: -15%); +$button-color: $white; +$button-color-alt: $black; +$button-radius: $global-radius; +$button-hollow-border-width: 1px; +$button-sizes: ( + tiny: 0.6rem, + small: 0.75rem, + default: 0.9rem, + large: 1.25rem, +); +$button-palette: $foundation-palette; +$button-opacity-disabled: 0.25; +$button-background-hover-lightness: -20%; +$button-hollow-hover-lightness: -50%; +$button-transition: background-color 0.25s ease-out, color 0.25s ease-out; + +// 12. Button Group +// ---------------- + +$buttongroup-margin: 1rem; +$buttongroup-spacing: 1px; +$buttongroup-child-selector: '.button'; +$buttongroup-expand-max: 6; +$buttongroup-radius-on-each: true; + +// 13. Callout +// ----------- + +$callout-background: $white; +$callout-background-fade: 85%; +$callout-border: 1px solid rgba($black, 0.25); +$callout-margin: 0 0 1rem 0; +$callout-padding: 1rem; +$callout-font-color: $body-font-color; +$callout-font-color-alt: $body-background; +$callout-radius: $global-radius; +$callout-link-tint: 30%; + +// 14. Card +// -------- + +$card-background: $white; +$card-font-color: $body-font-color; +$card-divider-background: $light-gray; +$card-border: 1px solid $light-gray; +$card-shadow: none; +$card-border-radius: $global-radius; +$card-padding: $global-padding; +$card-margin-bottom: $global-margin; + +// 15. Close Button +// ---------------- + +$closebutton-position: right top; +$closebutton-offset-horizontal: ( + small: 0.66rem, + medium: 1rem, +); +$closebutton-offset-vertical: ( + small: 0.33em, + medium: 0.5rem, +); +$closebutton-size: ( + small: 1.5em, + medium: 2em, +); +$closebutton-lineheight: 1; +$closebutton-color: $dark-gray; +$closebutton-color-hover: $black; + +// 16. Drilldown +// ------------- + +$drilldown-transition: transform 0.15s linear; +$drilldown-arrows: true; +$drilldown-padding: $global-menu-padding; +$drilldown-nested-margin: 0; +$drilldown-background: $white; +$drilldown-submenu-padding: $drilldown-padding; +$drilldown-submenu-background: $white; +$drilldown-arrow-color: $primary-color; +$drilldown-arrow-size: 6px; + +// 17. Dropdown +// ------------ + +$dropdown-padding: 1rem; +$dropdown-background: $body-background; +$dropdown-border: 1px solid $medium-gray; +$dropdown-font-size: 1rem; +$dropdown-width: 300px; +$dropdown-radius: $global-radius; +$dropdown-sizes: ( + tiny: 100px, + small: 200px, + large: 400px, +); + +// 18. Dropdown Menu +// ----------------- + +$dropdownmenu-arrows: true; +$dropdownmenu-arrow-color: $anchor-color; +$dropdownmenu-arrow-size: 6px; +$dropdownmenu-arrow-padding: 1.5rem; +$dropdownmenu-min-width: 200px; +$dropdownmenu-background: $white; +$dropdownmenu-submenu-background: $dropdownmenu-background; +$dropdownmenu-padding: $global-menu-padding; +$dropdownmenu-nested-margin: 0; +$dropdownmenu-submenu-padding: $dropdownmenu-padding; +$dropdownmenu-border: 1px solid $medium-gray; +$dropdown-menu-item-color-active: get-color(primary); +$dropdown-menu-item-background-active: transparent; + +// 19. Flexbox Utilities +// --------------------- + +$flex-source-ordering-count: 6; +$flexbox-responsive-breakpoints: true; + +// 20. Forms +// --------- + +$fieldset-border: 1px solid $medium-gray; +$fieldset-padding: rem-calc(20); +$fieldset-margin: rem-calc(18 0); +$legend-padding: rem-calc(0 3); +$form-spacing: rem-calc(16); +$helptext-color: $black; +$helptext-font-size: rem-calc(13); +$helptext-font-style: italic; +$input-prefix-color: $black; +$input-prefix-background: $light-gray; +$input-prefix-border: 1px solid $medium-gray; +$input-prefix-padding: 1rem; +$form-label-color: $black; +$form-label-font-size: rem-calc(14); +$form-label-font-weight: $global-weight-normal; +$form-label-line-height: 1.8; +$select-background: $white; +$select-triangle-color: $dark-gray; +$select-radius: $global-radius; +$input-color: $black; +$input-placeholder-color: $medium-gray; +$input-font-family: inherit; +$input-font-size: rem-calc(16); +$input-font-weight: $global-weight-normal; +$input-line-height: $global-lineheight; +$input-background: $white; +$input-background-focus: $white; +$input-background-disabled: $light-gray; +$input-border: 1px solid $medium-gray; +$input-border-focus: 1px solid $dark-gray; +$input-padding: $form-spacing / 2; +$input-shadow: inset 0 1px 2px rgba($black, 0.1); +$input-shadow-focus: 0 0 5px $medium-gray; +$input-cursor-disabled: not-allowed; +$input-transition: box-shadow 0.5s, border-color 0.25s ease-in-out; +$input-number-spinners: true; +$input-radius: $global-radius; +$form-button-radius: $global-radius; + +// 21. Label +// --------- + +$label-background: $primary-color; +$label-color: $white; +$label-color-alt: $black; +$label-palette: $foundation-palette; +$label-font-size: 0.8rem; +$label-padding: 0.33333rem 0.5rem; +$label-radius: $global-radius; + +// 22. Media Object +// ---------------- + +$mediaobject-margin-bottom: $global-margin; +$mediaobject-section-padding: $global-padding; +$mediaobject-image-width-stacked: 100%; + +// 23. Menu +// -------- + +$menu-margin: 0; +$menu-nested-margin: $global-menu-nested-margin; +$menu-items-padding: $global-menu-padding; +$menu-simple-margin: 1rem; +$menu-item-color-active: $white; +$menu-item-background-active: get-color(primary); +$menu-icon-spacing: 0.25rem; +$menu-item-background-hover: $light-gray; +$menu-state-back-compat: true; +$menu-centered-back-compat: true; +$menu-icons-back-compat: true; + +// 24. Meter +// --------- + +$meter-height: 1rem; +$meter-radius: $global-radius; +$meter-background: $medium-gray; +$meter-fill-good: $success-color; +$meter-fill-medium: $warning-color; +$meter-fill-bad: $alert-color; + +// 25. Off-canvas +// -------------- + +$offcanvas-sizes: ( + small: 250px, +); +$offcanvas-vertical-sizes: ( + small: 250px, +); +$offcanvas-background: $light-gray; +$offcanvas-shadow: 0 0 10px rgba($black, 0.7); +$offcanvas-inner-shadow-size: 20px; +$offcanvas-inner-shadow-color: rgba($black, 0.25); +$offcanvas-overlay-zindex: 11; +$offcanvas-push-zindex: 12; +$offcanvas-overlap-zindex: 13; +$offcanvas-reveal-zindex: 12; +$offcanvas-transition-length: 0.5s; +$offcanvas-transition-timing: ease; +$offcanvas-fixed-reveal: true; +$offcanvas-exit-background: rgba($white, 0.25); +$maincontent-class: 'off-canvas-content'; + +// 26. Orbit +// --------- + +$orbit-bullet-background: $medium-gray; +$orbit-bullet-background-active: $dark-gray; +$orbit-bullet-diameter: 1.2rem; +$orbit-bullet-margin: 0.1rem; +$orbit-bullet-margin-top: 0.8rem; +$orbit-bullet-margin-bottom: 0.8rem; +$orbit-caption-background: rgba($black, 0.5); +$orbit-caption-padding: 1rem; +$orbit-control-background-hover: rgba($black, 0.5); +$orbit-control-padding: 1rem; +$orbit-control-zindex: 10; + +// 27. Pagination +// -------------- + +$pagination-font-size: rem-calc(14); +$pagination-margin-bottom: $global-margin; +$pagination-item-color: $black; +$pagination-item-padding: rem-calc(3 10); +$pagination-item-spacing: rem-calc(1); +$pagination-radius: $global-radius; +$pagination-item-background-hover: $light-gray; +$pagination-item-background-current: $primary-color; +$pagination-item-color-current: $white; +$pagination-item-color-disabled: $medium-gray; +$pagination-ellipsis-color: $black; +$pagination-mobile-items: false; +$pagination-mobile-current-item: false; +$pagination-arrows: true; + +// 28. Progress Bar +// ---------------- + +$progress-height: 1rem; +$progress-background: $medium-gray; +$progress-margin-bottom: $global-margin; +$progress-meter-background: $primary-color; +$progress-radius: $global-radius; + +// 29. Prototype Arrow +// ------------------- + +$prototype-arrow-directions: ( + down, + up, + right, + left +); +$prototype-arrow-size: 0.4375rem; +$prototype-arrow-color: $black; + +// 30. Prototype Border-Box +// ------------------------ + +$prototype-border-box-breakpoints: $global-prototype-breakpoints; + +// 31. Prototype Border-None +// ------------------------- + +$prototype-border-none-breakpoints: $global-prototype-breakpoints; + +// 32. Prototype Bordered +// ---------------------- + +$prototype-bordered-breakpoints: $global-prototype-breakpoints; +$prototype-border-width: rem-calc(1); +$prototype-border-type: solid; +$prototype-border-color: $medium-gray; + +// 33. Prototype Display +// --------------------- + +$prototype-display-breakpoints: $global-prototype-breakpoints; +$prototype-display: ( + inline, + inline-block, + block, + table, + table-cell +); + +// 34. Prototype Font-Styling +// -------------------------- + +$prototype-font-breakpoints: $global-prototype-breakpoints; +$prototype-wide-letter-spacing: rem-calc(4); +$prototype-font-normal: $global-weight-normal; +$prototype-font-bold: $global-weight-bold; + +// 35. Prototype List-Style-Type +// ----------------------------- + +$prototype-list-breakpoints: $global-prototype-breakpoints; +$prototype-style-type-unordered: ( + disc, + circle, + square +); +$prototype-style-type-ordered: ( + decimal, + lower-alpha, + lower-latin, + lower-roman, + upper-alpha, + upper-latin, + upper-roman +); + +// 36. Prototype Overflow +// ---------------------- + +$prototype-overflow-breakpoints: $global-prototype-breakpoints; +$prototype-overflow: ( + visible, + hidden, + scroll +); + +// 37. Prototype Position +// ---------------------- + +$prototype-position-breakpoints: $global-prototype-breakpoints; +$prototype-position: ( + static, + relative, + absolute, + fixed +); +$prototype-position-z-index: 975; + +// 38. Prototype Rounded +// --------------------- + +$prototype-rounded-breakpoints: $global-prototype-breakpoints; +$prototype-border-radius: rem-calc(3); + +// 39. Prototype Separator +// ----------------------- + +$prototype-separator-breakpoints: $global-prototype-breakpoints; +$prototype-separator-align: center; +$prototype-separator-height: rem-calc(2); +$prototype-separator-width: 3rem; +$prototype-separator-background: $primary-color; +$prototype-separator-margin-top: $global-margin; + +// 40. Prototype Shadow +// -------------------- + +$prototype-shadow-breakpoints: $global-prototype-breakpoints; +$prototype-box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), + 0 2px 10px 0 rgba(0,0,0,.12); + +// 41. Prototype Sizing +// -------------------- + +$prototype-sizing-breakpoints: $global-prototype-breakpoints; +$prototype-sizing: ( + width, + height +); +$prototype-sizes: ( + 25: 25%, + 50: 50%, + 75: 75%, + 100: 100% +); + +// 42. Prototype Spacing +// --------------------- + +$prototype-spacing-breakpoints: $global-prototype-breakpoints; +$prototype-spacers-count: 3; + +// 43. Prototype Text-Decoration +// ----------------------------- + +$prototype-decoration-breakpoints: $global-prototype-breakpoints; +$prototype-text-decoration: ( + overline, + underline, + line-through, +); + +// 44. Prototype Text-Transformation +// --------------------------------- + +$prototype-transformation-breakpoints: $global-prototype-breakpoints; +$prototype-text-transformation: ( + lowercase, + uppercase, + capitalize +); + +// 45. Prototype Text-Utilities +// ---------------------------- + +$prototype-utilities-breakpoints: $global-prototype-breakpoints; +$prototype-text-overflow: ellipsis; + +// 46. Responsive Embed +// -------------------- + +$responsive-embed-margin-bottom: rem-calc(16); +$responsive-embed-ratios: ( + default: 4 by 3, + widescreen: 16 by 9, +); + +// 47. Reveal +// ---------- + +$reveal-background: $white; +$reveal-width: 600px; +$reveal-max-width: $global-width; +$reveal-padding: $global-padding; +$reveal-border: 1px solid $medium-gray; +$reveal-radius: $global-radius; +$reveal-zindex: 1005; +$reveal-overlay-background: rgba($black, 0.45); + +// 48. Slider +// ---------- + +$slider-width-vertical: 0.5rem; +$slider-transition: all 0.2s ease-in-out; +$slider-height: 0.5rem; +$slider-background: $light-gray; +$slider-fill-background: $medium-gray; +$slider-handle-height: 1.4rem; +$slider-handle-width: 1.4rem; +$slider-handle-background: $primary-color; +$slider-opacity-disabled: 0.25; +$slider-radius: $global-radius; + +// 49. Switch +// ---------- + +$switch-background: $medium-gray; +$switch-background-active: $primary-color; +$switch-height: 2rem; +$switch-height-tiny: 1.5rem; +$switch-height-small: 1.75rem; +$switch-height-large: 2.5rem; +$switch-radius: $global-radius; +$switch-margin: $global-margin; +$switch-paddle-background: $white; +$switch-paddle-offset: 0.25rem; +$switch-paddle-radius: $global-radius; +$switch-paddle-transition: all 0.25s ease-out; + +// 50. Table +// --------- + +$table-background: $white; +$table-color-scale: 5%; +$table-border: 1px solid smart-scale($table-background, $table-color-scale); +$table-padding: rem-calc(8 10 10); +$table-hover-scale: 2%; +$table-row-hover: darken($table-background, $table-hover-scale); +$table-row-stripe-hover: darken($table-background, $table-color-scale + $table-hover-scale); +$table-is-striped: true; +$table-striped-background: smart-scale($table-background, $table-color-scale); +$table-stripe: even; +$table-head-background: smart-scale($table-background, $table-color-scale / 2); +$table-head-row-hover: darken($table-head-background, $table-hover-scale); +$table-foot-background: smart-scale($table-background, $table-color-scale); +$table-foot-row-hover: darken($table-foot-background, $table-hover-scale); +$table-head-font-color: $body-font-color; +$table-foot-font-color: $body-font-color; +$show-header-for-stacked: false; +$table-stack-breakpoint: medium; + +// 51. Tabs +// -------- + +$tab-margin: 0; +$tab-background: $white; +$tab-color: $primary-color; +$tab-background-active: $light-gray; +$tab-active-color: $primary-color; +$tab-item-font-size: rem-calc(12); +$tab-item-background-hover: $white; +$tab-item-padding: 1.25rem 1.5rem; +$tab-expand-max: 6; +$tab-content-background: $white; +$tab-content-border: $light-gray; +$tab-content-color: $body-font-color; +$tab-content-padding: 1rem; + +// 52. Thumbnail +// ------------- + +$thumbnail-border: solid 4px $white; +$thumbnail-margin-bottom: $global-margin; +$thumbnail-shadow: 0 0 0 1px rgba($black, 0.2); +$thumbnail-shadow-hover: 0 0 6px 1px rgba($primary-color, 0.5); +$thumbnail-transition: box-shadow 200ms ease-out; +$thumbnail-radius: $global-radius; + +// 53. Title Bar +// ------------- + +$titlebar-background: $black; +$titlebar-color: $white; +$titlebar-padding: 0.5rem; +$titlebar-text-font-weight: bold; +$titlebar-icon-color: $white; +$titlebar-icon-color-hover: $medium-gray; +$titlebar-icon-spacing: 0.25rem; + +// 54. Tooltip +// ----------- + +$has-tip-cursor: help; +$has-tip-font-weight: $global-weight-bold; +$has-tip-border-bottom: dotted 1px $dark-gray; +$tooltip-background-color: $black; +$tooltip-color: $white; +$tooltip-padding: 0.75rem; +$tooltip-max-width: 10rem; +$tooltip-font-size: $small-font-size; +$tooltip-pip-width: 0.75rem; +$tooltip-pip-height: $tooltip-pip-width * 0.866; +$tooltip-radius: $global-radius; + +// 55. Top Bar +// ----------- + +$topbar-padding: 0.5rem; +$topbar-background: $light-gray; +$topbar-submenu-background: $topbar-background; +$topbar-title-spacing: 0.5rem 1rem 0.5rem 0; +$topbar-input-width: 200px; +$topbar-unstack-breakpoint: medium; + +// 56. Xy Grid +// ----------- + +$xy-grid: true; +$grid-container: $global-width; +$grid-columns: 12; +$grid-margin-gutters: ( + small: 20px, + medium: 30px +); +$grid-padding-gutters: $grid-margin-gutters; +$grid-container-padding: $grid-padding-gutters; +$grid-container-max: $global-width; +$xy-block-grid-max: 8; + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000000..3a38418320 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,19 @@ +/* + * 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. + *= require normalize-rails + + * + *= require_tree . + *= require_self + *= require foundation_and_overrides + + */ diff --git a/app/assets/stylesheets/browserslist b/app/assets/stylesheets/browserslist new file mode 100644 index 0000000000..6019618a9a --- /dev/null +++ b/app/assets/stylesheets/browserslist @@ -0,0 +1,4 @@ +last 2 versions +ie >= 9 +Android >= 2.3 +ios >= 7 diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss new file mode 100644 index 0000000000..ed4c5a0ecf --- /dev/null +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -0,0 +1,61 @@ +@charset 'utf-8'; + +@import 'settings'; +@import 'foundation'; + +// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package. +// +// @import 'motion-ui/motion-ui'; + +// We include everything by default. To slim your CSS, remove components you don't use. + +@include foundation-global-styles; +@include foundation-xy-grid-classes; +//@include foundation-grid; +//@include foundation-flex-grid; +@include foundation-flex-classes; +@include foundation-typography; +@include foundation-forms; +@include foundation-button; +@include foundation-accordion; +@include foundation-accordion-menu; +@include foundation-badge; +@include foundation-breadcrumbs; +@include foundation-button-group; +@include foundation-callout; +@include foundation-card; +@include foundation-close-button; +@include foundation-menu; +@include foundation-menu-icon; +@include foundation-drilldown-menu; +@include foundation-dropdown; +@include foundation-dropdown-menu; +@include foundation-responsive-embed; +@include foundation-label; +@include foundation-media-object; +@include foundation-off-canvas; +@include foundation-orbit; +@include foundation-pagination; +@include foundation-progress-bar; +@include foundation-slider; +@include foundation-sticky; +@include foundation-reveal; +@include foundation-switch; +@include foundation-table; +@include foundation-tabs; +@include foundation-thumbnail; +@include foundation-title-bar; +@include foundation-tooltip; +@include foundation-top-bar; +@include foundation-visibility-classes; +@include foundation-float-classes; + +// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package. +// +// @include motion-ui-transitions; +// @include motion-ui-animations; +@import 'motion-ui/motion-ui'; +@include motion-ui-transitions; +@include motion-ui-animations; + + 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..1c07694e9d --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery with: :exception +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..cd60004891 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,19 @@ + + + + + + + <%= content_for?(:title) ? yield(:title) : "Untitled" %> + + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + + + <%= 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..66e9889e8b --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..5badb2fde0 --- /dev/null +++ b/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..d87d5f5781 --- /dev/null +++ b/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..78c4e861dc --- /dev/null +++ b/bin/setup @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/spring b/bin/spring new file mode 100755 index 0000000000..fb2ec2ebb4 --- /dev/null +++ b/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/bin/update b/bin/update new file mode 100755 index 0000000000..a8e4462f20 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 0000000000..c2bacef836 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..f7ba0b527b --- /dev/null +++ b/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..5f6ca0f9b2 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,25 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Betsy + class Application < Rails::Application + config.generators do |g| + # Force new test files to be generated in the minitest-spec style + g.test_framework :minitest, spec: true + + # Always use .js files, never .coffee + g.javascript_engine :js + end + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000..30f5120df6 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..3cba994bb2 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 + channel_prefix: betsy_production diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000000..6903bb6083 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,85 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: betsy_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: betsy + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: betsy_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: betsy_production + username: betsy + password: <%= ENV['BETSY_DATABASE_PASSWORD'] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000000..426333bb46 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000000..5187e22186 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,54 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000000..9284f84839 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,91 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "betsy_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000000..8e5cbde533 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000000..89d2efab2b --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000000..4b828e80cb --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000000..59385cdf37 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000000..5a6a32d371 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000000..4a994e1e7b --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000000..ac033bf9dc --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000000..dc1899682b --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000000..bbfc3961bf --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..decc5a8573 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000000..1e19380dcb --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..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/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000000..a178c26ced --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,32 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rails secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +# Shared secrets are available across all environments. + +# shared: +# api_key: a1B2c3D4e5F6 + +# Environmental secrets are only available for that specific environment. + +development: + secret_key_base: 40bd69044c0362921f356c1361b87c4a9ad6884add690a4db5cad50b819008359e30dce7c41e306fce5eea7c72a67e6d60488f29d922b5972d99fcd123637520 + +test: + secret_key_base: d0ac75e3a24b3419a644a4e5b506a4552b8eed17c3ebaf026e93880b588d5c9367c1b5c61ea28a4a85f47ff987caf83e29a67329d7c8ba4d2af6dd2868ceb2ce + +# Do not keep production secrets in the unencrypted secrets file. +# Instead, either read values from the environment. +# Or, use `bin/rails secrets:setup` to configure encrypted secrets +# and move the `production:` environment over there. + +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 0000000000..c9119b40c0 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/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/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..10594a3248 --- /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 + +# 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 ccb1ad85f3fda9efc72f9229f353f6be2a0c1ea8 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 16:02:47 -0700 Subject: [PATCH 002/283] adds homepage and sessions controller --- app/assets/javascripts/homepages.js | 2 ++ app/assets/javascripts/sessions.js | 2 ++ app/assets/stylesheets/homepages.scss | 3 +++ app/assets/stylesheets/sessions.scss | 3 +++ app/controllers/homepages_controller.rb | 4 ++++ app/controllers/sessions_controller.rb | 7 +++++++ app/helpers/homepages_helper.rb | 2 ++ app/helpers/sessions_helper.rb | 2 ++ app/views/homepages/index.html.erb | 2 ++ app/views/sessions/login.html.erb | 2 ++ app/views/sessions/logout.html.erb | 2 ++ config/routes.rb | 6 ++++++ test/controllers/homepages_controller_test.rb | 9 +++++++++ test/controllers/sessions_controller_test.rb | 14 ++++++++++++++ 14 files changed, 60 insertions(+) create mode 100644 app/assets/javascripts/homepages.js create mode 100644 app/assets/javascripts/sessions.js create mode 100644 app/assets/stylesheets/homepages.scss create mode 100644 app/assets/stylesheets/sessions.scss create mode 100644 app/controllers/homepages_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/helpers/homepages_helper.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 app/views/homepages/index.html.erb create mode 100644 app/views/sessions/login.html.erb create mode 100644 app/views/sessions/logout.html.erb create mode 100644 test/controllers/homepages_controller_test.rb create mode 100644 test/controllers/sessions_controller_test.rb diff --git a/app/assets/javascripts/homepages.js b/app/assets/javascripts/homepages.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/homepages.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/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/homepages.scss b/app/assets/stylesheets/homepages.scss new file mode 100644 index 0000000000..2305c36d10 --- /dev/null +++ b/app/assets/stylesheets/homepages.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Homepages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ 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/homepages_controller.rb b/app/controllers/homepages_controller.rb new file mode 100644 index 0000000000..f200c8ac2e --- /dev/null +++ b/app/controllers/homepages_controller.rb @@ -0,0 +1,4 @@ +class HomepagesController < ApplicationController + def index + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..5cb7fba4f1 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,7 @@ +class SessionsController < ApplicationController + def login + end + + def logout + end +end diff --git a/app/helpers/homepages_helper.rb b/app/helpers/homepages_helper.rb new file mode 100644 index 0000000000..4bd8098f37 --- /dev/null +++ b/app/helpers/homepages_helper.rb @@ -0,0 +1,2 @@ +module HomepagesHelper +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/app/views/homepages/index.html.erb b/app/views/homepages/index.html.erb new file mode 100644 index 0000000000..37d3ce7099 --- /dev/null +++ b/app/views/homepages/index.html.erb @@ -0,0 +1,2 @@ +

Homepages#index

+

Find me in app/views/homepages/index.html.erb

diff --git a/app/views/sessions/login.html.erb b/app/views/sessions/login.html.erb new file mode 100644 index 0000000000..6fbfe54fd5 --- /dev/null +++ b/app/views/sessions/login.html.erb @@ -0,0 +1,2 @@ +

Sessions#login

+

Find me in app/views/sessions/login.html.erb

diff --git a/app/views/sessions/logout.html.erb b/app/views/sessions/logout.html.erb new file mode 100644 index 0000000000..42c4d77134 --- /dev/null +++ b/app/views/sessions/logout.html.erb @@ -0,0 +1,2 @@ +

Sessions#logout

+

Find me in app/views/sessions/logout.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 787824f888..6b37f71af3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,9 @@ Rails.application.routes.draw do + get 'sessions/login' + + get 'sessions/logout' + + get 'homepages/index' + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/test/controllers/homepages_controller_test.rb b/test/controllers/homepages_controller_test.rb new file mode 100644 index 0000000000..7395af3dec --- /dev/null +++ b/test/controllers/homepages_controller_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe HomepagesController do + it "should get index" do + get homepages_index_url + value(response).must_be :success? + end + +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000000..93a7e9ca5e --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,14 @@ +require "test_helper" + +describe SessionsController do + it "should get login" do + get sessions_login_url + value(response).must_be :success? + end + + it "should get logout" do + get sessions_logout_url + value(response).must_be :success? + end + +end From 48d1e36a3d55fd23b5d837e70b687b7a98d18328 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 19 Apr 2018 16:03:48 -0700 Subject: [PATCH 003/283] prdocuts controller --- app/assets/javascripts/products.js | 2 ++ app/assets/stylesheets/products.scss | 3 ++ app/controllers/products_controller.rb | 19 +++++++++++ app/helpers/products_helper.rb | 2 ++ app/views/products/create.html.erb | 2 ++ app/views/products/edit.html.erb | 2 ++ app/views/products/index.html.erb | 2 ++ app/views/products/new.html.erb | 2 ++ app/views/products/show.html.erb | 2 ++ app/views/products/update.html.erb | 2 ++ config/routes.rb | 12 +++++++ test/controllers/products_controller_test.rb | 34 ++++++++++++++++++++ 12 files changed, 84 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 app/views/products/create.html.erb create mode 100644 app/views/products/edit.html.erb create mode 100644 app/views/products/index.html.erb create mode 100644 app/views/products/new.html.erb create mode 100644 app/views/products/show.html.erb create mode 100644 app/views/products/update.html.erb 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..89e2e8db07 --- /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..76b732e5d5 --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,19 @@ +class ProductsController < ApplicationController + def index + end + + def show + end + + def new + end + + def create + end + + def edit + end + + def update + end +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/app/views/products/create.html.erb b/app/views/products/create.html.erb new file mode 100644 index 0000000000..d546021001 --- /dev/null +++ b/app/views/products/create.html.erb @@ -0,0 +1,2 @@ +

Products#create

+

Find me in app/views/products/create.html.erb

diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb new file mode 100644 index 0000000000..279b066f30 --- /dev/null +++ b/app/views/products/edit.html.erb @@ -0,0 +1,2 @@ +

Products#edit

+

Find me in app/views/products/edit.html.erb

diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb new file mode 100644 index 0000000000..f8eeb82674 --- /dev/null +++ b/app/views/products/index.html.erb @@ -0,0 +1,2 @@ +

Products#index

+

Find me in app/views/products/index.html.erb

diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb new file mode 100644 index 0000000000..a14e0d91b6 --- /dev/null +++ b/app/views/products/new.html.erb @@ -0,0 +1,2 @@ +

Products#new

+

Find me in app/views/products/new.html.erb

diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb new file mode 100644 index 0000000000..5f44ec44d2 --- /dev/null +++ b/app/views/products/show.html.erb @@ -0,0 +1,2 @@ +

Products#show

+

Find me in app/views/products/show.html.erb

diff --git a/app/views/products/update.html.erb b/app/views/products/update.html.erb new file mode 100644 index 0000000000..039889ac02 --- /dev/null +++ b/app/views/products/update.html.erb @@ -0,0 +1,2 @@ +

Products#update

+

Find me in app/views/products/update.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 787824f888..69a70a8742 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,15 @@ Rails.application.routes.draw do + get 'products/index' + + get 'products/show' + + get 'products/new' + + get 'products/create' + + get 'products/edit' + + get 'products/update' + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb new file mode 100644 index 0000000000..f5b89ce82c --- /dev/null +++ b/test/controllers/products_controller_test.rb @@ -0,0 +1,34 @@ +require "test_helper" + +describe ProductsController do + it "should get index" do + get products_index_url + value(response).must_be :success? + end + + it "should get show" do + get products_show_url + value(response).must_be :success? + end + + it "should get new" do + get products_new_url + value(response).must_be :success? + end + + it "should get create" do + get products_create_url + value(response).must_be :success? + end + + it "should get edit" do + get products_edit_url + value(response).must_be :success? + end + + it "should get update" do + get products_update_url + value(response).must_be :success? + end + +end From 56f6457d4f25fbcaa44b8fbe19f54ccf3ce3da6c Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 16:04:46 -0700 Subject: [PATCH 004/283] added orders and merchants controllers for baseline --- app/assets/javascripts/merchants.js | 2 ++ app/assets/javascripts/orders.js | 2 ++ app/assets/stylesheets/merchants.scss | 3 ++ app/assets/stylesheets/orders.scss | 3 ++ app/controllers/merchants_controller.rb | 10 ++++++ app/controllers/orders_controller.rb | 19 +++++++++++ app/helpers/merchants_helper.rb | 2 ++ app/helpers/orders_helper.rb | 2 ++ app/views/merchants/account_page.html.erb | 2 ++ .../merchants/order_fulfillment.html.erb | 2 ++ app/views/merchants/products_manager.html.erb | 2 ++ app/views/orders/checkout.html.erb | 2 ++ app/views/orders/create.html.erb | 2 ++ app/views/orders/destroy.html.erb | 2 ++ app/views/orders/paid.html.erb | 2 ++ app/views/orders/show.html.erb | 2 ++ app/views/orders/update.html.erb | 2 ++ config/routes.rb | 18 ++++++++++ test/controllers/merchants_controller_test.rb | 19 +++++++++++ test/controllers/orders_controller_test.rb | 34 +++++++++++++++++++ 20 files changed, 132 insertions(+) create mode 100644 app/assets/javascripts/merchants.js create mode 100644 app/assets/javascripts/orders.js create mode 100644 app/assets/stylesheets/merchants.scss create mode 100644 app/assets/stylesheets/orders.scss create mode 100644 app/controllers/merchants_controller.rb create mode 100644 app/controllers/orders_controller.rb create mode 100644 app/helpers/merchants_helper.rb create mode 100644 app/helpers/orders_helper.rb create mode 100644 app/views/merchants/account_page.html.erb create mode 100644 app/views/merchants/order_fulfillment.html.erb create mode 100644 app/views/merchants/products_manager.html.erb create mode 100644 app/views/orders/checkout.html.erb create mode 100644 app/views/orders/create.html.erb create mode 100644 app/views/orders/destroy.html.erb create mode 100644 app/views/orders/paid.html.erb create mode 100644 app/views/orders/show.html.erb create mode 100644 app/views/orders/update.html.erb create mode 100644 test/controllers/merchants_controller_test.rb create mode 100644 test/controllers/orders_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/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/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/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/merchants_controller.rb b/app/controllers/merchants_controller.rb new file mode 100644 index 0000000000..fef6f1e091 --- /dev/null +++ b/app/controllers/merchants_controller.rb @@ -0,0 +1,10 @@ +class MerchantsController < ApplicationController + def account_page + end + + def order_fulfillment + end + + def products_manager + end +end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb new file mode 100644 index 0000000000..aafd486043 --- /dev/null +++ b/app/controllers/orders_controller.rb @@ -0,0 +1,19 @@ +class OrdersController < ApplicationController + def show + end + + def create + end + + def update + end + + def checkout + end + + def paid + end + + def destroy + end +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/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/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb new file mode 100644 index 0000000000..673c3d4eed --- /dev/null +++ b/app/views/merchants/account_page.html.erb @@ -0,0 +1,2 @@ +

Merchants#account_page

+

Find me in app/views/merchants/account_page.html.erb

diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb new file mode 100644 index 0000000000..a10d5a7221 --- /dev/null +++ b/app/views/merchants/order_fulfillment.html.erb @@ -0,0 +1,2 @@ +

Merchants#order_fulfillment

+

Find me in app/views/merchants/order_fulfillment.html.erb

diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb new file mode 100644 index 0000000000..c338c1fae7 --- /dev/null +++ b/app/views/merchants/products_manager.html.erb @@ -0,0 +1,2 @@ +

Merchants#products_manager

+

Find me in app/views/merchants/products_manager.html.erb

diff --git a/app/views/orders/checkout.html.erb b/app/views/orders/checkout.html.erb new file mode 100644 index 0000000000..e8a98e51dc --- /dev/null +++ b/app/views/orders/checkout.html.erb @@ -0,0 +1,2 @@ +

Orders#checkout

+

Find me in app/views/orders/checkout.html.erb

diff --git a/app/views/orders/create.html.erb b/app/views/orders/create.html.erb new file mode 100644 index 0000000000..295bd84094 --- /dev/null +++ b/app/views/orders/create.html.erb @@ -0,0 +1,2 @@ +

Orders#create

+

Find me in app/views/orders/create.html.erb

diff --git a/app/views/orders/destroy.html.erb b/app/views/orders/destroy.html.erb new file mode 100644 index 0000000000..d14d0a3508 --- /dev/null +++ b/app/views/orders/destroy.html.erb @@ -0,0 +1,2 @@ +

Orders#destroy

+

Find me in app/views/orders/destroy.html.erb

diff --git a/app/views/orders/paid.html.erb b/app/views/orders/paid.html.erb new file mode 100644 index 0000000000..5e7277a5dc --- /dev/null +++ b/app/views/orders/paid.html.erb @@ -0,0 +1,2 @@ +

Orders#paid

+

Find me in app/views/orders/paid.html.erb

diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb new file mode 100644 index 0000000000..22eb495f6f --- /dev/null +++ b/app/views/orders/show.html.erb @@ -0,0 +1,2 @@ +

Orders#show

+

Find me in app/views/orders/show.html.erb

diff --git a/app/views/orders/update.html.erb b/app/views/orders/update.html.erb new file mode 100644 index 0000000000..21caac1f70 --- /dev/null +++ b/app/views/orders/update.html.erb @@ -0,0 +1,2 @@ +

Orders#update

+

Find me in app/views/orders/update.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 787824f888..cf4499a8bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,21 @@ Rails.application.routes.draw do + get 'merchants/account_page' + + get 'merchants/order_fulfillment' + + get 'merchants/products_manager' + + get 'orders/show' + + get 'orders/create' + + get 'orders/update' + + get 'orders/checkout' + + get 'orders/paid' + + get 'orders/destroy' + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb new file mode 100644 index 0000000000..094e153542 --- /dev/null +++ b/test/controllers/merchants_controller_test.rb @@ -0,0 +1,19 @@ +require "test_helper" + +describe MerchantsController do + it "should get account_page" do + get merchants_account_page_url + value(response).must_be :success? + end + + it "should get order_fulfillment" do + get merchants_order_fulfillment_url + value(response).must_be :success? + end + + it "should get products_manager" do + get merchants_products_manager_url + value(response).must_be :success? + end + +end diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb new file mode 100644 index 0000000000..7c06f0978f --- /dev/null +++ b/test/controllers/orders_controller_test.rb @@ -0,0 +1,34 @@ +require "test_helper" + +describe OrdersController do + it "should get show" do + get orders_show_url + value(response).must_be :success? + end + + it "should get create" do + get orders_create_url + value(response).must_be :success? + end + + it "should get update" do + get orders_update_url + value(response).must_be :success? + end + + it "should get checkout" do + get orders_checkout_url + value(response).must_be :success? + end + + it "should get paid" do + get orders_paid_url + value(response).must_be :success? + end + + it "should get destroy" do + get orders_destroy_url + value(response).must_be :success? + end + +end From 9e2dc693c0c47b2b6d689ac6ef29528c1882cf44 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 19 Apr 2018 16:11:36 -0700 Subject: [PATCH 005/283] adds homepages, sessions, and orderproducts controllers --- app/assets/javascripts/homepages.js | 2 ++ app/assets/javascripts/order_products.js | 2 ++ app/assets/javascripts/sessions.js | 2 ++ app/assets/stylesheets/homepages.scss | 3 +++ app/assets/stylesheets/order_products.scss | 3 +++ app/assets/stylesheets/sessions.scss | 3 +++ app/controllers/homepages_controller.rb | 4 ++++ app/controllers/order_products_controller.rb | 7 +++++++ app/controllers/sessions_controller.rb | 7 +++++++ app/helpers/homepages_helper.rb | 2 ++ app/helpers/order_products_helper.rb | 2 ++ app/helpers/sessions_helper.rb | 2 ++ app/views/homepages/index.html.erb | 2 ++ app/views/order_products/edit.html.erb | 2 ++ app/views/order_products/update.html.erb | 2 ++ app/views/sessions/login.html.erb | 2 ++ app/views/sessions/logout.html.erb | 2 ++ config/routes.rb | 10 ++++++++++ test/controllers/homepages_controller_test.rb | 9 +++++++++ test/controllers/order_products_controller_test.rb | 14 ++++++++++++++ test/controllers/sessions_controller_test.rb | 14 ++++++++++++++ 21 files changed, 96 insertions(+) create mode 100644 app/assets/javascripts/homepages.js create mode 100644 app/assets/javascripts/order_products.js create mode 100644 app/assets/javascripts/sessions.js create mode 100644 app/assets/stylesheets/homepages.scss create mode 100644 app/assets/stylesheets/order_products.scss create mode 100644 app/assets/stylesheets/sessions.scss create mode 100644 app/controllers/homepages_controller.rb create mode 100644 app/controllers/order_products_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/helpers/homepages_helper.rb create mode 100644 app/helpers/order_products_helper.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 app/views/homepages/index.html.erb create mode 100644 app/views/order_products/edit.html.erb create mode 100644 app/views/order_products/update.html.erb create mode 100644 app/views/sessions/login.html.erb create mode 100644 app/views/sessions/logout.html.erb create mode 100644 test/controllers/homepages_controller_test.rb create mode 100644 test/controllers/order_products_controller_test.rb create mode 100644 test/controllers/sessions_controller_test.rb diff --git a/app/assets/javascripts/homepages.js b/app/assets/javascripts/homepages.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/homepages.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/javascripts/order_products.js b/app/assets/javascripts/order_products.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/order_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/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/homepages.scss b/app/assets/stylesheets/homepages.scss new file mode 100644 index 0000000000..2305c36d10 --- /dev/null +++ b/app/assets/stylesheets/homepages.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Homepages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/order_products.scss b/app/assets/stylesheets/order_products.scss new file mode 100644 index 0000000000..4e38cdae9b --- /dev/null +++ b/app/assets/stylesheets/order_products.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the OrderProducts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 0000000000..7bef9cf826 --- /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/homepages_controller.rb b/app/controllers/homepages_controller.rb new file mode 100644 index 0000000000..f200c8ac2e --- /dev/null +++ b/app/controllers/homepages_controller.rb @@ -0,0 +1,4 @@ +class HomepagesController < ApplicationController + def index + end +end diff --git a/app/controllers/order_products_controller.rb b/app/controllers/order_products_controller.rb new file mode 100644 index 0000000000..1b2bd9c75f --- /dev/null +++ b/app/controllers/order_products_controller.rb @@ -0,0 +1,7 @@ +class OrderProductsController < ApplicationController + def edit + end + + def update + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..5cb7fba4f1 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,7 @@ +class SessionsController < ApplicationController + def login + end + + def logout + end +end diff --git a/app/helpers/homepages_helper.rb b/app/helpers/homepages_helper.rb new file mode 100644 index 0000000000..4bd8098f37 --- /dev/null +++ b/app/helpers/homepages_helper.rb @@ -0,0 +1,2 @@ +module HomepagesHelper +end diff --git a/app/helpers/order_products_helper.rb b/app/helpers/order_products_helper.rb new file mode 100644 index 0000000000..fb2828b523 --- /dev/null +++ b/app/helpers/order_products_helper.rb @@ -0,0 +1,2 @@ +module OrderProductsHelper +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/app/views/homepages/index.html.erb b/app/views/homepages/index.html.erb new file mode 100644 index 0000000000..37d3ce7099 --- /dev/null +++ b/app/views/homepages/index.html.erb @@ -0,0 +1,2 @@ +

Homepages#index

+

Find me in app/views/homepages/index.html.erb

diff --git a/app/views/order_products/edit.html.erb b/app/views/order_products/edit.html.erb new file mode 100644 index 0000000000..6586085a0d --- /dev/null +++ b/app/views/order_products/edit.html.erb @@ -0,0 +1,2 @@ +

OrderProducts#edit

+

Find me in app/views/order_products/edit.html.erb

diff --git a/app/views/order_products/update.html.erb b/app/views/order_products/update.html.erb new file mode 100644 index 0000000000..76388f9ccd --- /dev/null +++ b/app/views/order_products/update.html.erb @@ -0,0 +1,2 @@ +

OrderProducts#update

+

Find me in app/views/order_products/update.html.erb

diff --git a/app/views/sessions/login.html.erb b/app/views/sessions/login.html.erb new file mode 100644 index 0000000000..6fbfe54fd5 --- /dev/null +++ b/app/views/sessions/login.html.erb @@ -0,0 +1,2 @@ +

Sessions#login

+

Find me in app/views/sessions/login.html.erb

diff --git a/app/views/sessions/logout.html.erb b/app/views/sessions/logout.html.erb new file mode 100644 index 0000000000..42c4d77134 --- /dev/null +++ b/app/views/sessions/logout.html.erb @@ -0,0 +1,2 @@ +

Sessions#logout

+

Find me in app/views/sessions/logout.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 787824f888..55020bf9ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,13 @@ Rails.application.routes.draw do + get 'order_products/edit' + + get 'order_products/update' + + get 'sessions/login' + + get 'sessions/logout' + + get 'homepages/index' + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/test/controllers/homepages_controller_test.rb b/test/controllers/homepages_controller_test.rb new file mode 100644 index 0000000000..7395af3dec --- /dev/null +++ b/test/controllers/homepages_controller_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe HomepagesController do + it "should get index" do + get homepages_index_url + value(response).must_be :success? + end + +end diff --git a/test/controllers/order_products_controller_test.rb b/test/controllers/order_products_controller_test.rb new file mode 100644 index 0000000000..ddb0efcb06 --- /dev/null +++ b/test/controllers/order_products_controller_test.rb @@ -0,0 +1,14 @@ +require "test_helper" + +describe OrderProductsController do + it "should get edit" do + get order_products_edit_url + value(response).must_be :success? + end + + it "should get update" do + get order_products_update_url + value(response).must_be :success? + end + +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000000..93a7e9ca5e --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,14 @@ +require "test_helper" + +describe SessionsController do + it "should get login" do + get sessions_login_url + value(response).must_be :success? + end + + it "should get logout" do + get sessions_logout_url + value(response).must_be :success? + end + +end From a1d16daad35b6a79d11c92f1972f27a2bc1ac649 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 16:16:19 -0700 Subject: [PATCH 006/283] adds add_to_order method to product controllers --- app/controllers/products_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 76b732e5d5..56805a4fd2 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -16,4 +16,8 @@ def edit def update end + + def add_to_order + end + end From 7cb1e699af9e1f2a748f11c011bd85bb89944132 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 16:37:43 -0700 Subject: [PATCH 007/283] adds merchant model skeleton --- app/models/merchant.rb | 2 ++ db/migrate/20180419233429_create_merchants.rb | 12 ++++++++++++ test/fixtures/merchants.yml | 13 +++++++++++++ test/models/merchant_test.rb | 9 +++++++++ 4 files changed, 36 insertions(+) create mode 100644 app/models/merchant.rb create mode 100644 db/migrate/20180419233429_create_merchants.rb create mode 100644 test/fixtures/merchants.yml create mode 100644 test/models/merchant_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/db/migrate/20180419233429_create_merchants.rb b/db/migrate/20180419233429_create_merchants.rb new file mode 100644 index 0000000000..4fd5cfdd38 --- /dev/null +++ b/db/migrate/20180419233429_create_merchants.rb @@ -0,0 +1,12 @@ +class CreateMerchants < ActiveRecord::Migration[5.1] + 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/test/fixtures/merchants.yml b/test/fixtures/merchants.yml new file mode 100644 index 0000000000..19e7fb5362 --- /dev/null +++ b/test/fixtures/merchants.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + username: MyString + email: MyString + uid: 1 + provider: MyString + +two: + username: MyString + email: MyString + uid: 1 + provider: MyString 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 From ffd568ee5e89a805663a6ff335229de5faf22887 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 19 Apr 2018 16:37:46 -0700 Subject: [PATCH 008/283] Generate Product Model --- app/models/product.rb | 2 ++ db/migrate/20180419233104_create_products.rb | 14 ++++++++++++++ test/fixtures/products.yml | 15 +++++++++++++++ test/models/product_test.rb | 9 +++++++++ 4 files changed, 40 insertions(+) create mode 100644 app/models/product.rb create mode 100644 db/migrate/20180419233104_create_products.rb create mode 100644 test/fixtures/products.yml create mode 100644 test/models/product_test.rb 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/db/migrate/20180419233104_create_products.rb b/db/migrate/20180419233104_create_products.rb new file mode 100644 index 0000000000..a49df86d69 --- /dev/null +++ b/db/migrate/20180419233104_create_products.rb @@ -0,0 +1,14 @@ +class CreateProducts < ActiveRecord::Migration[5.1] + def change + create_table :products do |t| + t.string :name + t.integer :price + t.boolean :product_active + t.integer :inventory + t.string :photo_url + t.string :description + + t.timestamps + end + end +end diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml new file mode 100644 index 0000000000..412026ac6a --- /dev/null +++ b/test/fixtures/products.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + price: 1 + product_active: false + inventory: 1 + photo_url: MyString + +two: + name: MyString + price: 1 + product_active: false + inventory: 1 + photo_url: MyString 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 From 2f34e3c150f57a524b5c26a80fda197dfdb2c630 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 19 Apr 2018 16:37:56 -0700 Subject: [PATCH 009/283] adds cagetory model and corresponding test files --- app/models/category.rb | 2 ++ db/migrate/20180419233428_create_categories.rb | 9 +++++++++ test/fixtures/categories.yml | 7 +++++++ test/models/category_test.rb | 9 +++++++++ 4 files changed, 27 insertions(+) create mode 100644 app/models/category.rb create mode 100644 db/migrate/20180419233428_create_categories.rb create mode 100644 test/fixtures/categories.yml create mode 100644 test/models/category_test.rb diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 0000000000..54cb6aee3f --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,2 @@ +class Category < ApplicationRecord +end diff --git a/db/migrate/20180419233428_create_categories.rb b/db/migrate/20180419233428_create_categories.rb new file mode 100644 index 0000000000..6e136ce0ec --- /dev/null +++ b/db/migrate/20180419233428_create_categories.rb @@ -0,0 +1,9 @@ +class CreateCategories < ActiveRecord::Migration[5.1] + def change + create_table :categories do |t| + t.string :category_name + + t.timestamps + end + end +end diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml new file mode 100644 index 0000000000..bbb1bce1e4 --- /dev/null +++ b/test/fixtures/categories.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + category_name: MyString + +two: + category_name: MyString diff --git a/test/models/category_test.rb b/test/models/category_test.rb new file mode 100644 index 0000000000..781320ad8e --- /dev/null +++ b/test/models/category_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Category do + let(:category) { Category.new } + + it "must be valid" do + value(category).must_be :valid? + end +end From b92a1f139a68bb04ad1410a1ba8fadf1ea76a5d9 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 16:38:02 -0700 Subject: [PATCH 010/283] generated Order model with all attributes --- app/models/order.rb | 2 ++ db/migrate/20180419233431_create_orders.rb | 16 ++++++++++++++++ test/fixtures/orders.yml | 21 +++++++++++++++++++++ test/models/order_test.rb | 9 +++++++++ 4 files changed, 48 insertions(+) create mode 100644 app/models/order.rb create mode 100644 db/migrate/20180419233431_create_orders.rb create mode 100644 test/fixtures/orders.yml create mode 100644 test/models/order_test.rb 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/db/migrate/20180419233431_create_orders.rb b/db/migrate/20180419233431_create_orders.rb new file mode 100644 index 0000000000..15b62af2f3 --- /dev/null +++ b/db/migrate/20180419233431_create_orders.rb @@ -0,0 +1,16 @@ +class CreateOrders < ActiveRecord::Migration[5.1] + def change + create_table :orders do |t| + t.string :status + t.string :billing_email + t.string :billing_address + t.string :billing_name + t.integer :billing_num + t.string :billing_exp + t.integer :billing_cvv + t.integer :billing_zipcode + + t.timestamps + end + end +end diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml new file mode 100644 index 0000000000..fc4aa2bc1f --- /dev/null +++ b/test/fixtures/orders.yml @@ -0,0 +1,21 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + status: MyString + billing_email: MyString + billing_address: MyString + billing_name: MyString + billing_num: 1 + billing_exp: MyString + billing_cvv: 1 + billing_zipcode: 1 + +two: + status: MyString + billing_email: MyString + billing_address: MyString + billing_name: MyString + billing_num: 1 + billing_exp: MyString + billing_cvv: 1 + billing_zipcode: 1 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 From 7a7060a8f77e43fd60d95848b2fb68cff79dcf45 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 17:12:48 -0700 Subject: [PATCH 011/283] finished generated models and migrations for foreign keys, product category join table, review model, and order_product model --- app/models/order_product.rb | 2 + app/models/review.rb | 2 + ...20180419234524_add_reference_to_product.rb | 5 + db/migrate/20180419234956_create_reviews.rb | 10 ++ .../20180419235132_add_reference_to_review.rb | 5 + .../20180419235644_create_join_table.rb | 9 ++ .../20180420000442_create_order_products.rb | 10 ++ ...0000601_add_references_to_order_product.rb | 6 ++ db/schema.rb | 92 +++++++++++++++++++ test/fixtures/order_products.yml | 9 ++ test/fixtures/reviews.yml | 9 ++ test/models/order_product_test.rb | 9 ++ test/models/review_test.rb | 9 ++ 13 files changed, 177 insertions(+) create mode 100644 app/models/order_product.rb create mode 100644 app/models/review.rb create mode 100644 db/migrate/20180419234524_add_reference_to_product.rb create mode 100644 db/migrate/20180419234956_create_reviews.rb create mode 100644 db/migrate/20180419235132_add_reference_to_review.rb create mode 100644 db/migrate/20180419235644_create_join_table.rb create mode 100644 db/migrate/20180420000442_create_order_products.rb create mode 100644 db/migrate/20180420000601_add_references_to_order_product.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/order_products.yml create mode 100644 test/fixtures/reviews.yml create mode 100644 test/models/order_product_test.rb create mode 100644 test/models/review_test.rb diff --git a/app/models/order_product.rb b/app/models/order_product.rb new file mode 100644 index 0000000000..5a1d864dff --- /dev/null +++ b/app/models/order_product.rb @@ -0,0 +1,2 @@ +class OrderProduct < 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/20180419234524_add_reference_to_product.rb b/db/migrate/20180419234524_add_reference_to_product.rb new file mode 100644 index 0000000000..a4bad91317 --- /dev/null +++ b/db/migrate/20180419234524_add_reference_to_product.rb @@ -0,0 +1,5 @@ +class AddReferenceToProduct < ActiveRecord::Migration[5.1] + def change + add_reference :products, :merchant, foreign_key: true + end +end diff --git a/db/migrate/20180419234956_create_reviews.rb b/db/migrate/20180419234956_create_reviews.rb new file mode 100644 index 0000000000..6952d5ad07 --- /dev/null +++ b/db/migrate/20180419234956_create_reviews.rb @@ -0,0 +1,10 @@ +class CreateReviews < ActiveRecord::Migration[5.1] + def change + create_table :reviews do |t| + t.integer :rating + t.string :description + + t.timestamps + end + end +end diff --git a/db/migrate/20180419235132_add_reference_to_review.rb b/db/migrate/20180419235132_add_reference_to_review.rb new file mode 100644 index 0000000000..67cd0ff9e8 --- /dev/null +++ b/db/migrate/20180419235132_add_reference_to_review.rb @@ -0,0 +1,5 @@ +class AddReferenceToReview < ActiveRecord::Migration[5.1] + def change + add_reference :reviews, :product, foreign_key: true + end +end diff --git a/db/migrate/20180419235644_create_join_table.rb b/db/migrate/20180419235644_create_join_table.rb new file mode 100644 index 0000000000..8b1eb2b8f0 --- /dev/null +++ b/db/migrate/20180419235644_create_join_table.rb @@ -0,0 +1,9 @@ +class CreateJoinTable < ActiveRecord::Migration[5.1] + def change + create_table :products_categories do |t| + t.belongs_to :product, index: true + t.belongs_to :category, index: true + t.timestamps + end + end +end diff --git a/db/migrate/20180420000442_create_order_products.rb b/db/migrate/20180420000442_create_order_products.rb new file mode 100644 index 0000000000..e71bed2d08 --- /dev/null +++ b/db/migrate/20180420000442_create_order_products.rb @@ -0,0 +1,10 @@ +class CreateOrderProducts < ActiveRecord::Migration[5.1] + def change + create_table :order_products do |t| + t.integer :quantity + t.string :status + + t.timestamps + end + end +end diff --git a/db/migrate/20180420000601_add_references_to_order_product.rb b/db/migrate/20180420000601_add_references_to_order_product.rb new file mode 100644 index 0000000000..d88e63e18a --- /dev/null +++ b/db/migrate/20180420000601_add_references_to_order_product.rb @@ -0,0 +1,6 @@ +class AddReferencesToOrderProduct < ActiveRecord::Migration[5.1] + def change + add_reference :order_products, :order, foreign_key: true + add_reference :order_products, :product, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..5522d42369 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,92 @@ +# 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: 20180420000601) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "categories", force: :cascade do |t| + t.string "category_name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "merchants", force: :cascade do |t| + t.string "username" + t.string "email" + t.integer "uid" + t.string "provider" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "order_products", force: :cascade do |t| + t.integer "quantity" + t.string "status" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "order_id" + t.bigint "product_id" + t.index ["order_id"], name: "index_order_products_on_order_id" + t.index ["product_id"], name: "index_order_products_on_product_id" + end + + create_table "orders", force: :cascade do |t| + t.string "status" + t.string "billing_email" + t.string "billing_address" + t.string "billing_name" + t.integer "billing_num" + t.string "billing_exp" + t.integer "billing_cvv" + t.integer "billing_zipcode" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "products", force: :cascade do |t| + t.string "name" + t.integer "price" + t.boolean "product_active" + t.integer "inventory" + t.string "photo_url" + t.string "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "merchant_id" + t.index ["merchant_id"], name: "index_products_on_merchant_id" + end + + create_table "products_categories", force: :cascade do |t| + t.bigint "product_id" + t.bigint "category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["category_id"], name: "index_products_categories_on_category_id" + t.index ["product_id"], name: "index_products_categories_on_product_id" + end + + create_table "reviews", force: :cascade do |t| + t.integer "rating" + t.string "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "product_id" + t.index ["product_id"], name: "index_reviews_on_product_id" + end + + add_foreign_key "order_products", "orders" + add_foreign_key "order_products", "products" + add_foreign_key "products", "merchants" + add_foreign_key "reviews", "products" +end diff --git a/test/fixtures/order_products.yml b/test/fixtures/order_products.yml new file mode 100644 index 0000000000..dc6f57259e --- /dev/null +++ b/test/fixtures/order_products.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + quantity: 1 + status: MyString + +two: + quantity: 1 + status: MyString diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml new file mode 100644 index 0000000000..41c2fd15d3 --- /dev/null +++ b/test/fixtures/reviews.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + rating: 1 + description: MyString + +two: + rating: 1 + description: MyString diff --git a/test/models/order_product_test.rb b/test/models/order_product_test.rb new file mode 100644 index 0000000000..47c6ee2a98 --- /dev/null +++ b/test/models/order_product_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe OrderProduct do + let(:order_product) { OrderProduct.new } + + it "must be valid" do + value(order_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 2d9b3fbce45f2668568a489258a08503d7b74423 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 19 Apr 2018 17:27:10 -0700 Subject: [PATCH 012/283] adds validation for username and email to merchant model --- app/models/merchant.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index 0440407160..a4743c4768 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -1,2 +1,4 @@ class Merchant < ApplicationRecord + validates :username, uniqueness: true, presence: true + validates :email, uniqueness: true, presence: true end From 55550103118b01faf23322159a8b4b593fff2284 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 17:33:25 -0700 Subject: [PATCH 013/283] adds validations for review model --- app/models/review.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/review.rb b/app/models/review.rb index b2ca4935ed..8e43c9c113 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,2 +1,7 @@ class Review < ApplicationRecord + + validates :rating, presence: true + validates :rating, numericality: { only_integer: true, in: 1..5 } + + end From 03dd116d5978fad038937349f7c2ddca1f7df8ff Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 17:34:36 -0700 Subject: [PATCH 014/283] added validations for quantity in order_product to model --- app/models/order_product.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/order_product.rb b/app/models/order_product.rb index 5a1d864dff..754c36f5df 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,2 +1,3 @@ class OrderProduct < ApplicationRecord + validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } end From cd26fdbabae8299e1634b40eea760d6f31f07cda Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 19 Apr 2018 17:34:48 -0700 Subject: [PATCH 015/283] Initialize Validations for Product Model --- app/models/product.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/product.rb b/app/models/product.rb index 35a85acab3..85f9e97b7d 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,2 +1,7 @@ class Product < ApplicationRecord + + validates :name, presence: true, uniqueness: true + validates :price, presence: true, format: { with: /\A\d+(?:\.\d{2})?\z/ }, numericality: { greater_than: 0, less_than: 1000000 } + validates_numericality_of :inventory, :only_integer => true, :greater_than_or_equal_to => 0 + end From b922f8ca0b8f987ec188ba052b8950abc92cabe7 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 17:39:52 -0700 Subject: [PATCH 016/283] added validaton for name of category attribute --- app/models/category.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/category.rb b/app/models/category.rb index 54cb6aee3f..c9d32ff2a7 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,2 +1,3 @@ class Category < ApplicationRecord + validates :category_name, presence: true end From 46b71dac1f5fddd3f1c619e225e34d65eb3b6789 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 19 Apr 2018 17:49:03 -0700 Subject: [PATCH 017/283] define relationships in Product Model --- app/models/product.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/product.rb b/app/models/product.rb index 85f9e97b7d..960cd5870e 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,7 +1,11 @@ class Product < ApplicationRecord + has_many :order_products + has_and_belongs_to_many :catergories + has_many :reviews + belongs_to :merchant validates :name, presence: true, uniqueness: true - validates :price, presence: true, format: { with: /\A\d+(?:\.\d{2})?\z/ }, numericality: { greater_than: 0, less_than: 1000000 } + validates :price, presence: true, format: { with: /\A\d+(?:\.\d{0,2})?\z/ }, numericality: { greater_than: 0, less_than: 1000000 } validates_numericality_of :inventory, :only_integer => true, :greater_than_or_equal_to => 0 end From 40e1ad5f164165f6171a7d1b8c2e822d95b66ef6 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 17:49:16 -0700 Subject: [PATCH 018/283] adds review model relationship to product --- app/models/review.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/review.rb b/app/models/review.rb index 8e43c9c113..fdbf6af986 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,4 +1,5 @@ class Review < ApplicationRecord + belongs_to :product validates :rating, presence: true validates :rating, numericality: { only_integer: true, in: 1..5 } From 26d809d43acb9fb19f5a20f67a0a9b93b9682951 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 19 Apr 2018 17:50:22 -0700 Subject: [PATCH 019/283] added relationships to category, order_product, and order model --- app/models/category.rb | 4 ++++ app/models/order.rb | 1 + app/models/order_product.rb | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/app/models/category.rb b/app/models/category.rb index c9d32ff2a7..61ebbe9e00 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,3 +1,7 @@ class Category < ApplicationRecord + + has_and_belongs_to_many :products + validates :category_name, presence: true + end diff --git a/app/models/order.rb b/app/models/order.rb index 10281b3450..732f18c63e 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,2 +1,3 @@ class Order < ApplicationRecord + has_many :order_products end diff --git a/app/models/order_product.rb b/app/models/order_product.rb index 754c36f5df..a21823a817 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,3 +1,8 @@ class OrderProduct < ApplicationRecord + + belongs_to :order + belongs_to :product + validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } + end From 37a5d9c75bb1259948f36c8b9baf194e8edaf900 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 19 Apr 2018 17:50:40 -0700 Subject: [PATCH 020/283] adds hasmany products relationship to merchant model --- app/models/merchant.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index a4743c4768..1f350dcb3f 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -1,4 +1,6 @@ class Merchant < ApplicationRecord + has_many :products + validates :username, uniqueness: true, presence: true validates :email, uniqueness: true, presence: true end From c8d6197c904f62c6f3cae1bb37db79c741d7df54 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 18:54:43 -0700 Subject: [PATCH 021/283] adds routes --- app/controllers/orders_controller.rb | 8 +++---- config/routes.rb | 32 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index aafd486043..a76f0ee877 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -5,15 +5,15 @@ def show def create end - def update + def update #when dealing with cart before checkout end - def checkout + def checkout #edit to enter billing info end - def paid + def paid #submit after checkout end - def destroy + def destroy #this clears the cart before order has gone into paid status end end diff --git a/config/routes.rb b/config/routes.rb index c21cbd01e0..9bc6c67c7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,31 +1,31 @@ Rails.application.routes.draw do - get 'order_products/edit' - get 'order_products/update' + root 'homepages#index' - get 'sessions/login' + resources :merchants do + resources :products, only: [:index, :new, :create, :edit, :update] + end - get 'sessions/logout' + get '/merchant/account_page', to: 'merchants#account_page', as: 'account_page_path' - get 'homepages/index' + get 'merchant/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' - get 'merchants/account_page' + get 'merchant/products_manager', to: 'merchants#products_manager', as: 'products_manager' - get 'merchants/order_fulfillment' + resources :products, only: [:index, :show] - get 'merchants/products_manager' + get '/product/product_id/add_to_order', to: 'products#add_to_order', as: 'add_to_order' - get 'orders/show' + resources :orders, only: [:show, :create, :update, :destroy] - get 'orders/create' + get 'order/checkout', to: 'orders#checkout', as: 'checkout' + patch 'order/paid', to: 'orders#paid', as: 'order_paid' - get 'orders/update' + get '/login', to: 'sessions#login_form', as: 'login' + post '/login', to: 'sessions#login' + delete '/logout', to: 'sessions#logout', as: 'logout' - get 'orders/checkout' - - get 'orders/paid' - - get 'orders/destroy' + resources :order_products, only: [:edit, :update] # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html From 88174b943c025bcccf98dad4f27fbfbdd82e8f54 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 19:15:21 -0700 Subject: [PATCH 022/283] edits routes --- app/controllers/merchants_controller.rb | 5 ++++- config/routes.rb | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index fef6f1e091..a149d442b6 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,5 +1,8 @@ class MerchantsController < ApplicationController - def account_page + def index + end + + def account_page #show - only visible by OAuth end def order_fulfillment diff --git a/config/routes.rb b/config/routes.rb index 9bc6c67c7f..1034a86120 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,15 +2,15 @@ root 'homepages#index' - resources :merchants do + resources :merchants, except: [:index, :create, :new, :edit, :update, :destroy] do resources :products, only: [:index, :new, :create, :edit, :update] end - get '/merchant/account_page', to: 'merchants#account_page', as: 'account_page_path' + get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page_path' - get 'merchant/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' + get 'merchants/:id/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' - get 'merchant/products_manager', to: 'merchants#products_manager', as: 'products_manager' + get 'merchants/:id/products_manager', to: 'merchants#products_manager', as: 'products_manager' resources :products, only: [:index, :show] @@ -18,8 +18,8 @@ resources :orders, only: [:show, :create, :update, :destroy] - get 'order/checkout', to: 'orders#checkout', as: 'checkout' - patch 'order/paid', to: 'orders#paid', as: 'order_paid' + get 'orders/:id/checkout', to: 'orders#checkout', as: 'checkout' + patch 'orders/:id/paid', to: 'orders#paid', as: 'order_paid' get '/login', to: 'sessions#login_form', as: 'login' post '/login', to: 'sessions#login' From 945138fb1982b48a48122b38ce6003427ad327e5 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 19 Apr 2018 19:19:02 -0700 Subject: [PATCH 023/283] edits login/logout routes to OAuth type --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 1034a86120..6e3e5a28ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,8 +21,8 @@ get 'orders/:id/checkout', to: 'orders#checkout', as: 'checkout' patch 'orders/:id/paid', to: 'orders#paid', as: 'order_paid' - get '/login', to: 'sessions#login_form', as: 'login' - post '/login', to: 'sessions#login' + get '/auth/:provider/callback', to: 'sessions#login', as: 'auth_callback' + get '/auth/github', as: 'github_login' delete '/logout', to: 'sessions#logout', as: 'logout' resources :order_products, only: [:edit, :update] From c752a68c4d0f79bda59686e9826868ee128e6273 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 19 Apr 2018 22:35:04 -0700 Subject: [PATCH 024/283] corrects typo on review.rb --- app/models/product.rb | 2 +- app/models/review.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/product.rb b/app/models/product.rb index 960cd5870e..c8b4747fc9 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,6 +1,6 @@ class Product < ApplicationRecord has_many :order_products - has_and_belongs_to_many :catergories + has_and_belongs_to_many :categories has_many :reviews belongs_to :merchant diff --git a/app/models/review.rb b/app/models/review.rb index fdbf6af986..ee93045ad3 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -4,5 +4,4 @@ class Review < ApplicationRecord validates :rating, presence: true validates :rating, numericality: { only_integer: true, in: 1..5 } - end From b11817dd26d8b728d64dde51b1fea7d737d146cd Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 10:35:39 -0700 Subject: [PATCH 025/283] moved root to products, changed root path, and deleted all info related to homepages controller --- app/controllers/homepages_controller.rb | 4 ---- app/controllers/products_controller.rb | 6 +++++- app/views/homepages/index.html.erb | 2 -- app/views/products/root.html.erb | 0 config/routes.rb | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 app/controllers/homepages_controller.rb delete mode 100644 app/views/homepages/index.html.erb create mode 100644 app/views/products/root.html.erb diff --git a/app/controllers/homepages_controller.rb b/app/controllers/homepages_controller.rb deleted file mode 100644 index f200c8ac2e..0000000000 --- a/app/controllers/homepages_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class HomepagesController < ApplicationController - def index - end -end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 56805a4fd2..257938f51e 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -1,4 +1,8 @@ class ProductsController < ApplicationController + + def root + end + def index end @@ -19,5 +23,5 @@ def update def add_to_order end - + end diff --git a/app/views/homepages/index.html.erb b/app/views/homepages/index.html.erb deleted file mode 100644 index 37d3ce7099..0000000000 --- a/app/views/homepages/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Homepages#index

-

Find me in app/views/homepages/index.html.erb

diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/config/routes.rb b/config/routes.rb index 6e3e5a28ef..c58d2eafc4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Rails.application.routes.draw do - root 'homepages#index' + root 'products#root' resources :merchants, except: [:index, :create, :new, :edit, :update, :destroy] do resources :products, only: [:index, :new, :create, :edit, :update] From 6a677844ed8c17fc79763772c88022d81c688312 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 11:50:38 -0700 Subject: [PATCH 026/283] adds omniauth gem, initializer, login method in progress --- .gitignore | 1 + Gemfile | 4 ++++ Gemfile.lock | 28 ++++++++++++++++++++++++++ app/controllers/sessions_controller.rb | 1 + config/initializers/omniauth.rb | 3 +++ 5 files changed, 37 insertions(+) create mode 100644 config/initializers/omniauth.rb diff --git a/.gitignore b/.gitignore index 82701fedc8..fd7861badf 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ /yarn-error.log .byebug_history +.env diff --git a/Gemfile b/Gemfile index 8490d0efb5..254c66e458 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,9 @@ gem 'jbuilder', '~> 2.5' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +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] @@ -48,6 +51,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 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index d528acb17a..436e28411f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,8 +68,14 @@ GEM concurrent-ruby (1.0.5) crass (1.0.4) debug_inspector (0.0.3) + dotenv (2.2.2) + dotenv-rails (2.2.2) + dotenv (= 2.2.2) + railties (>= 3.2, < 6.0) erubi (1.7.1) execjs (2.7.0) + faraday (0.12.2) + multipart-post (>= 1.2, < 3) ffi (1.9.23) foundation-rails (6.4.3.0) railties (>= 3.1.0) @@ -77,6 +83,7 @@ GEM sprockets-es6 (>= 0.9.0) globalid (0.4.1) activesupport (>= 4.2.0) + hashie (3.5.7) i18n (1.0.1) concurrent-ruby (~> 1.0) jbuilder (2.7.0) @@ -89,6 +96,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + jwt (1.5.6) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -111,10 +119,27 @@ GEM minitest (>= 5.0) ruby-progressbar multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) nio4r (2.3.0) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) normalize-rails (4.1.1) + oauth2 (1.4.0) + faraday (>= 0.8, < 0.13) + jwt (~> 1.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.0.0) pry (0.11.3) coderay (~> 1.1.0) @@ -211,6 +236,7 @@ DEPENDENCIES binding_of_caller byebug capybara (~> 2.13) + dotenv-rails foundation-rails jbuilder (~> 2.5) jquery-rails @@ -219,6 +245,8 @@ DEPENDENCIES minitest-rails minitest-reporters normalize-rails + omniauth + omniauth-github pg (>= 0.18, < 2.0) pry-rails puma (~> 3.7) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 5cb7fba4f1..81b5b7a263 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,6 @@ class SessionsController < ApplicationController def login + auth_hash = request.env['omniauth.auth'] end def logout 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 12a19ad81c2b0eb7e8c0a8d79f5f13f3699516dd Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 20 Apr 2018 13:12:35 -0700 Subject: [PATCH 027/283] added sessions controller login/logout method and helper method in merchant user model --- app/controllers/sessions_controller.rb | 28 ++++++++++++++++++++++++++ app/models/merchant.rb | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 81b5b7a263..c607e00550 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,8 +1,36 @@ class SessionsController < ApplicationController def login auth_hash = request.env['omniauth.auth'] + + if auth_hash['uid'] + @merchant = Merchant.find_by(uid: auth_hash[:uid], provider: 'github') + + if @merchant.nil? + #its a new user, we need to MAKE a new user + @merchant = Merchant.build_from_github(auth_hash) + successful_save = @merchant.save + if successful_save + flash[:success] = "Logged in Successfully. Welcome #{@merchant.username}" + session[:merchant_id] = @merchant.id + redirect_to root_path + else + flash[:error] = "Some error happened in Merchant creation" + redirect_to root_path + end + else + flash[:success] = "Logged in successfully" + session[:merchant_id] = @merchant.id + redirect_to root_path + end + else + flash[:error] = "Logging in through Github not successful" + redirect_to root_path end def logout + session[:merchant_id] = nil + flash[:status] = :success + flash[:result_text] = "Successfully logged out" + redirect_to root_path end end diff --git a/app/models/merchant.rb b/app/models/merchant.rb index 1f350dcb3f..bd38ef54d9 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -3,4 +3,9 @@ class Merchant < ApplicationRecord validates :username, uniqueness: true, presence: true validates :email, uniqueness: true, presence: true + + def self.build_from_github(auth_hash) + return Merchant.new(provider: auth_hash[:provider], uid: auth_hash[:uid], email: auth_hash[:info][:email], username: auth_hash[:info][:nickname]) + end + end From 6b2090c602b15da4f967de04349fa7e5c5c61a1f Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 13:57:00 -0700 Subject: [PATCH 028/283] adds seed_data directory and csv seed files --- db/seed_data/category-seeds.csv | 1 + db/seed_data/merchant-seeds.csv | 1 + db/seed_data/order-product-seeds.csv | 1 + db/seed_data/orders-seeds.csv | 1 + db/seed_data/product-seeds.csv | 1 + db/seed_data/review-seeds.csv | 1 + 6 files changed, 6 insertions(+) create mode 100644 db/seed_data/category-seeds.csv create mode 100644 db/seed_data/merchant-seeds.csv create mode 100644 db/seed_data/order-product-seeds.csv create mode 100644 db/seed_data/orders-seeds.csv create mode 100644 db/seed_data/product-seeds.csv create mode 100644 db/seed_data/review-seeds.csv diff --git a/db/seed_data/category-seeds.csv b/db/seed_data/category-seeds.csv new file mode 100644 index 0000000000..b4f7d9e672 --- /dev/null +++ b/db/seed_data/category-seeds.csv @@ -0,0 +1 @@ +id,category_name 1,clothing & shoes 2,accessories 3,home 4,food 5,beverage 6,kitchen 7,spiritual af 8,you probably haven't heard of it \ No newline at end of file diff --git a/db/seed_data/merchant-seeds.csv b/db/seed_data/merchant-seeds.csv new file mode 100644 index 0000000000..73da7b223d --- /dev/null +++ b/db/seed_data/merchant-seeds.csv @@ -0,0 +1 @@ +id,username,email,uid,provider 1,npeters5,norapeters5@gmail.com,23266268,github 2,kcforsman,kcforsman@outlook.com,21271703,github 3,madaleines,maddiev.shields@gmail.com,19227879,github 4,AngelaPoland,angelalpoland@gmail.com,25715122,github \ No newline at end of file diff --git a/db/seed_data/order-product-seeds.csv b/db/seed_data/order-product-seeds.csv new file mode 100644 index 0000000000..bb89ec3a7b --- /dev/null +++ b/db/seed_data/order-product-seeds.csv @@ -0,0 +1 @@ +order_id,product_id,quantity,status 3,23,2,complete 3,22,1,complete 3,16,1,cancelled 2,11,1,pending 2,12,1,paid 1,6,1,complete 1,7,3,complete 1,4,10,pending 1,5,1,paid 4,27,1,complete 4,4,1,cancelled 4,9,1,pending 4,2,1,paid 5,8,1,complete 5,4,1,complete 5,12,1,pending 6,20,1,complete 6,27,1,complete \ No newline at end of file diff --git a/db/seed_data/orders-seeds.csv b/db/seed_data/orders-seeds.csv new file mode 100644 index 0000000000..472abf400a --- /dev/null +++ b/db/seed_data/orders-seeds.csv @@ -0,0 +1 @@ +id,status,billing_email,billing_address,billing_name,billing_num,billing_exp,billing_cvv,billing_zipcode 1,pending,janelle@haley.net,3016 Hills Spur,Will B. Back,1.7385E+15,5/19/18,655,79224 2,paid,alfredo@ortiz.biz,9729 Ernser Landing,Emma Ghost,1.67577E+15,10/21/18,224,70842 3,paid,myrtie_kutch@marvin.org,61675 Anya Trail,Rustin Peece,5.97557E+15,6/18/18,427,63381 4,paid,jaqueline_cole@littel.co,5414 Swift Ramp,Cuthbert Binns,5.97557E+15,6/21/18,640,67894 5,complete,tristin_lemke@feilkshlerin.name,942 Clementina Burg,Michael Corner,9.3036E+15,6/21/19,282,47801 6,complete,coy@purdymckenzie.co,48144 Hackett Wells,Rowena Ravenclaw,9.3036E+15,6/21/18,333,95176 \ No newline at end of file diff --git a/db/seed_data/product-seeds.csv b/db/seed_data/product-seeds.csv new file mode 100644 index 0000000000..9e826c1cdd --- /dev/null +++ b/db/seed_data/product-seeds.csv @@ -0,0 +1 @@ +id,name,price,inventory,description,product_active,merchant_id,photo_url 1,1 dozen locally-sourced grass-fed organic cage-free eggs,37,6,"Lorem ipsum dolor amet pok pok bicycle rights 8-bit man braid, kinfolk humblebrag shabby chic.",TRUE,1, 2,single-origin shade-grown fair-trade coffee,20,30,Mumblecore coloring book DIY YOLO chia farm-to-table leggings man bun glossier trust fund.,TRUE,4, 3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1, 4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3, 5,PBR,52,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2, 6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial. ,TRUE,1, 7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4, 8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2, 9,cold-pressed green juice,24,6,"Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice.",TRUE,3, 10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1, 11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2, 12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard. ,TRUE,3, 13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3, 14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4, 15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1, 16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1, 17,tiny house made from reclaimed wood,23,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1, 18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3, 19,crystal collection,20,28,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,2, 20,ukelele banjo hybrid,40,5,"Hell flames. In willow trees, killer dolls are rotten teeth bite, sheep children virus nibh, in zombies brains unknown ghost creepy. Eerie needles edginess, graveyard on death rotten, disturbing non grave. Drenched scream scared dark. Cat at decapitated guns. Undead obsession tear horrifying, a devil fiendish tense in. Haunt tearin.",TRUE,2, 21,beard oil,25,10,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled.,TRUE,3, 22,plaid flannel,30,11,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a, psychotic ashes ghost. Eyeball cat silent, morbid in damp torture, 666 at brains. Haunt suicide silent, gory as demonic alarming, burie.",TRUE,1, 23,hoodie,23,22,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. Creep cold graves, shadow non fear a, psychotic ashes ghost. Trapped flesh grotesque squeal, bloodcurdling chilling hair-raising spooky hazardous daring. Creep serial killer, bury a scourge menacing, pai.",TRUE,3, 24,skinny jeans,54,28,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights.,TRUE,2, 25,vans,56,30,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings.,TRUE,1, 26,neon fanny pack,40,20,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh.",TRUE,3, 27,macrame wall hanging,24,40,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,4, 28,chemex,23,22,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up.,TRUE,3, 29,fixie bike,54,28,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut",TRUE,4, 30,wooden bowtie,56,30,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam.,TRUE,1, 31,man bun,40,20,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. ",TRUE,1, 32,air plant terrarium,24,40,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo.",TRUE,4, 33,turntable & vinyl,85,2,Fingerstache meh you probably haven't heard of them chia 90's put a bird on it adaptogen everyday carry before they sold out umami affogato gentrify trust fund keffiyeh echo park. taiyaki vice.,,, \ No newline at end of file diff --git a/db/seed_data/review-seeds.csv b/db/seed_data/review-seeds.csv new file mode 100644 index 0000000000..ce33c9de88 --- /dev/null +++ b/db/seed_data/review-seeds.csv @@ -0,0 +1 @@ +rating,product_id,nickname,description 2,15,,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. 1,15,,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh." 5,15,,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. 1,11,,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights. 4,2,,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. 1,2,,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh." 4,6,,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics." 5,13,,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. 2,18,,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut" 5,23,,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam. 3,16,,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. " 3,6,,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo." 3,3,,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. 5,12,,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. 1,9,,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights. 3,12,,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights. 2,22,,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. 2,24,,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh." 4,13,,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. " 3,13,,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. 5,16,,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut" 1,13,,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam. 3,10,,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. " 5,29,,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo." 4,29,,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. 2,11,,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a," 4,1,,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. " 2,8,,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights. \ No newline at end of file From 1ae943b7c2e83429dcb6f054b2ed60f0e2289f58 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 13:57:36 -0700 Subject: [PATCH 029/283] adds placeholder header to root html --- app/views/products/root.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb index e69de29bb2..fc4b51b3e2 100644 --- a/app/views/products/root.html.erb +++ b/app/views/products/root.html.erb @@ -0,0 +1 @@ +

Root view!

From 94f2caaa9384d0c84eceb7c7737125ea00bacb69 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 14:13:41 -0700 Subject: [PATCH 030/283] adds categories routes and nested product route --- config/routes.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index c58d2eafc4..b53caa03e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,10 @@ resources :products, only: [:index, :new, :create, :edit, :update] end + resources :categories, only: [:new, :create] do + resources :products, only: [:index] + end + get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page_path' get 'merchants/:id/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' From d64aff050e9b47db66ae2f5127a98328598d5de9 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 20 Apr 2018 14:17:55 -0700 Subject: [PATCH 031/283] initialize controller filters for User Auth --- app/controllers/application_controller.rb | 13 +++++++++++++ app/controllers/sessions_controller.rb | 2 ++ 2 files changed, 15 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c07694e9d..94017ba3a6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,16 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + + before_action :require_login + + def current_merchant + @current_merchant ||= Merchant.find(session[:merchant_id]) if session[:merchant_id] + end + + def require_login + if current_user.nil? + flash[:error] = "You must be logged in to view this section" + redirect_to session_path + end + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 81b5b7a263..e733594f4a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,4 +1,6 @@ class SessionsController < ApplicationController + skip_before_action :require_login, only: [:create] + def login auth_hash = request.env['omniauth.auth'] end From cd796bc08406aa0c28adc9c6db01c0aaeb39fb9a Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 14:20:59 -0700 Subject: [PATCH 032/283] added categories controller with new and create action, deleted update and create views from categories and products --- app/assets/javascripts/categories.js | 2 ++ app/assets/stylesheets/categories.scss | 3 +++ app/controllers/categories_controller.rb | 7 +++++++ app/controllers/products_controller.rb | 2 +- app/helpers/categories_helper.rb | 2 ++ app/views/categories/new.html.erb | 2 ++ app/views/products/create.html.erb | 2 -- app/views/products/update.html.erb | 2 -- config/routes.rb | 4 ++++ test/controllers/categories_controller_test.rb | 14 ++++++++++++++ 10 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/categories.js create mode 100644 app/assets/stylesheets/categories.scss create mode 100644 app/controllers/categories_controller.rb create mode 100644 app/helpers/categories_helper.rb create mode 100644 app/views/categories/new.html.erb delete mode 100644 app/views/products/create.html.erb delete mode 100644 app/views/products/update.html.erb create mode 100644 test/controllers/categories_controller_test.rb diff --git a/app/assets/javascripts/categories.js b/app/assets/javascripts/categories.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/categories.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/categories.scss b/app/assets/stylesheets/categories.scss new file mode 100644 index 0000000000..42976cbc11 --- /dev/null +++ b/app/assets/stylesheets/categories.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Categories 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/categories_controller.rb b/app/controllers/categories_controller.rb new file mode 100644 index 0000000000..0e3d845f08 --- /dev/null +++ b/app/controllers/categories_controller.rb @@ -0,0 +1,7 @@ +class CategoriesController < ApplicationController + def new + end + + def create + end +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 257938f51e..10e896b406 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -2,7 +2,7 @@ class ProductsController < ApplicationController def root end - + def index end diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb new file mode 100644 index 0000000000..e06f31554c --- /dev/null +++ b/app/helpers/categories_helper.rb @@ -0,0 +1,2 @@ +module CategoriesHelper +end diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb new file mode 100644 index 0000000000..7e5c27307e --- /dev/null +++ b/app/views/categories/new.html.erb @@ -0,0 +1,2 @@ +

Categories#new

+

Find me in app/views/categories/new.html.erb

diff --git a/app/views/products/create.html.erb b/app/views/products/create.html.erb deleted file mode 100644 index d546021001..0000000000 --- a/app/views/products/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Products#create

-

Find me in app/views/products/create.html.erb

diff --git a/app/views/products/update.html.erb b/app/views/products/update.html.erb deleted file mode 100644 index 039889ac02..0000000000 --- a/app/views/products/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Products#update

-

Find me in app/views/products/update.html.erb

diff --git a/config/routes.rb b/config/routes.rb index b53caa03e6..a08f0ad396 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Rails.application.routes.draw do + get 'categories/new' + + get 'categories/create' + root 'products#root' resources :merchants, except: [:index, :create, :new, :edit, :update, :destroy] do diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb new file mode 100644 index 0000000000..f50efa8fb0 --- /dev/null +++ b/test/controllers/categories_controller_test.rb @@ -0,0 +1,14 @@ +require "test_helper" + +describe CategoriesController do + it "should get new" do + get categories_new_url + value(response).must_be :success? + end + + it "should get create" do + get categories_create_url + value(response).must_be :success? + end + +end From 5ed2e25d59652dbb7b2ace5251956d9c255166ad Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 14:34:40 -0700 Subject: [PATCH 033/283] added form to new view for categories, added basic action method to category controller, deleted rails generated routes for routes.rb from creation of the category controller --- app/controllers/categories_controller.rb | 1 + app/models/category.rb | 4 ++-- app/views/categories/new.html.erb | 8 ++++++-- config/routes.rb | 4 ---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 0e3d845f08..8fcd83c3d1 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,5 +1,6 @@ class CategoriesController < ApplicationController def new + @category = Category.new end def create diff --git a/app/models/category.rb b/app/models/category.rb index 61ebbe9e00..6f438fbc09 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,7 +1,7 @@ class Category < ApplicationRecord has_and_belongs_to_many :products - - validates :category_name, presence: true + + validates :category_name, presence: true, uniqueness: true end diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb index 7e5c27307e..05954b86a2 100644 --- a/app/views/categories/new.html.erb +++ b/app/views/categories/new.html.erb @@ -1,2 +1,6 @@ -

Categories#new

-

Find me in app/views/categories/new.html.erb

+

Add a Category

+<%= form_for @category do |f| %> + <%= f.label :category_name, 'Category' %> + <%= f.text_field :category_name %> + <%= f.submit %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index a08f0ad396..b53caa03e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,5 @@ Rails.application.routes.draw do - get 'categories/new' - - get 'categories/create' - root 'products#root' resources :merchants, except: [:index, :create, :new, :edit, :update, :destroy] do From 7731003ae8965892171df7771e3a2c3aeb1197bc Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 20 Apr 2018 14:49:17 -0700 Subject: [PATCH 034/283] initialize merchants controller --- app/controllers/merchants_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index a149d442b6..19c5b733d6 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -3,11 +3,20 @@ def index end def account_page #show - only visible by OAuth + if !@current_merchant + flash[:alert] = "You do not have access to this Merchant's account" + end end def order_fulfillment + if !@current_merchant + flash[:alert] = "You do not have access to this Merchant's order page" + end end def products_manager + if !@current_merchant + flash[:alert] = "You do not have access to this Merchant's product management" + end end end From 300391584051ec3b7702f47eb3c4b205ae3ba35c Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 20 Apr 2018 15:14:07 -0700 Subject: [PATCH 035/283] adds application view for header and nav bar --- app/controllers/sessions_controller.rb | 4 +- app/views/layouts/application.html.erb | 82 +++++++++++++++++++++++++- config/routes.rb | 2 +- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index c607e00550..8f71357101 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -14,7 +14,7 @@ def login session[:merchant_id] = @merchant.id redirect_to root_path else - flash[:error] = "Some error happened in Merchant creation" + flash[:alert] = "Some error happened in Merchant creation" redirect_to root_path end else @@ -23,7 +23,7 @@ def login redirect_to root_path end else - flash[:error] = "Logging in through Github not successful" + flash[:alert] = "Logging in through Github not successful" redirect_to root_path end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cd60004891..6dba53b48d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,7 @@ - <%= content_for?(:title) ? yield(:title) : "Untitled" %> + Hipsty <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> @@ -13,7 +13,85 @@ - <%= yield %> + + + + #this is going to be the sometimes hidden 2nd nav +
+
    +
  • <%= link_to "Shop All Products", products_path %> +
  • +
  • + + +
  • +
  • + + +
  • +
+
+ + + + + + + + + <% if flash[:result_text] or flash[:messages] %> +
+

<%= flash[:status] == :failure ? "A problem occurred: " : "" %><%= flash[:result_text] %>

+ <% if flash[:messages] %> +
    + <% flash[:messages].each do |name, problems| %> + <% problems.each do |problem| %> +
  • <%= name %>: <%= problem %>
  • + <% end %> + <% end %> +
+ <% end %> +
+ <% end %> + +
+ <%= yield %> +
diff --git a/config/routes.rb b/config/routes.rb index c58d2eafc4..c31463f985 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ resources :products, only: [:index, :new, :create, :edit, :update] end - get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page_path' + get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page' get 'merchants/:id/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' From 5aa08b59cbd4e2d6047cb4e850eb43c69d984cf8 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 15:27:11 -0700 Subject: [PATCH 036/283] adds render_404 custom method to category model --- app/models/category.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/category.rb b/app/models/category.rb index 61ebbe9e00..5021599ee8 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,7 +1,12 @@ class Category < ApplicationRecord has_and_belongs_to_many :products - + validates :category_name, presence: true + def render_404 + # DPR: this will actually render a 404 page in production + raise ActionController::RoutingError.new('Not Found') + end + end From a364fa36380e25342aaf2e71583f3c8c6eace81d Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 15:28:57 -0700 Subject: [PATCH 037/283] migration to rename products_categories join table to categories_products per convention --- .../20180420221243_rename_products_categories_join_table.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20180420221243_rename_products_categories_join_table.rb diff --git a/db/migrate/20180420221243_rename_products_categories_join_table.rb b/db/migrate/20180420221243_rename_products_categories_join_table.rb new file mode 100644 index 0000000000..53b1ab927a --- /dev/null +++ b/db/migrate/20180420221243_rename_products_categories_join_table.rb @@ -0,0 +1,5 @@ +class RenameProductsCategoriesJoinTable < ActiveRecord::Migration[5.1] + def change + rename_table :products_categories, :categories_products + end +end From c7f55697feb5d1b763b55f46fa6b99956625ee67 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 20 Apr 2018 15:32:49 -0700 Subject: [PATCH 038/283] add views for merchant --- app/views/merchants/account_page.html.erb | 18 +++++++++++++-- .../merchants/order_fulfillment.html.erb | 15 ++++++++++-- app/views/merchants/products_manager.html.erb | 23 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index 673c3d4eed..b316087b6a 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -1,2 +1,16 @@ -

Merchants#account_page

-

Find me in app/views/merchants/account_page.html.erb

+

<%= @merchant.username%>

+
+

Account Options:

+ +
diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index a10d5a7221..f0dceff387 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -1,2 +1,13 @@ -

Merchants#order_fulfillment

-

Find me in app/views/merchants/order_fulfillment.html.erb

+

<%= @merchant.username%>

+
+

All Orders:

+
    + <% @order_products.each do |order_product| %> +
  • + + <%= link_to order_product.order_id, order_product_path(order_product.order_id), class: 'order-link' %> + +
  • + <% end %> +
+
diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index c338c1fae7..8ad624dadf 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -1,2 +1,21 @@ -

Merchants#products_manager

-

Find me in app/views/merchants/products_manager.html.erb

+

<%= @merchant.username%>

+
+

Product Management:

+ +
    +
  • + <%= link_to "Add a Product", new_merchant_product_path(merchant.id) %> +
  • +
  • + <%= link_to "Add a category", new_catgory(merchant.id) %> +
  • + <% @order_products.each do |order_product| %> +
  • + + <%= link_to product.name, product_path(product.order_id), class: 'product-link' %> + +
  • + <% end %> +
+ +
From 477d9d605d1f4b8816514fab778dbc9572629403 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 15:39:24 -0700 Subject: [PATCH 039/283] adds products#index --- app/controllers/products_controller.rb | 21 ++++++++++++++++++++- db/schema.rb | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 257938f51e..ea5b59c877 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -2,8 +2,27 @@ class ProductsController < ApplicationController def root end - + def index + @categories = Category.order(:category_name) + + if params[:category_id] + if Category.find_by(id: params[:category_id]).nil? + render_404 + else + @products = Product.includes(:categories).where(product_active: true, categories: { id: params[:category_id]}) + end + elsif params[:merchant_id] + if Merchant.find_by(id: params[:merchant_id]) == nil + render_404 + else + @products = Product.includes(:merchant).where(product_active: true, products: {merchant_id: params[:merchant_id]}) + end + # elsif params[:search] + # @products = Product.search(params[:search]).order(:name) + else + @products = Product.where(product_active: true).order(:id) + end end def show diff --git a/db/schema.rb b/db/schema.rb index 5522d42369..0492ec3109 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: 20180420000601) do +ActiveRecord::Schema.define(version: 20180420221243) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -21,6 +21,15 @@ t.datetime "updated_at", null: false end + create_table "categories_products", force: :cascade do |t| + t.bigint "product_id" + t.bigint "category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["category_id"], name: "index_categories_products_on_category_id" + t.index ["product_id"], name: "index_categories_products_on_product_id" + end + create_table "merchants", force: :cascade do |t| t.string "username" t.string "email" @@ -67,15 +76,6 @@ t.index ["merchant_id"], name: "index_products_on_merchant_id" end - create_table "products_categories", force: :cascade do |t| - t.bigint "product_id" - t.bigint "category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["category_id"], name: "index_products_categories_on_category_id" - t.index ["product_id"], name: "index_products_categories_on_product_id" - end - create_table "reviews", force: :cascade do |t| t.integer "rating" t.string "description" From 7ddd8feab0a1b0b27ba72b65fee156722e436978 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 16:06:08 -0700 Subject: [PATCH 040/283] readded category related routes --- config/routes.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index c31463f985..12d568680d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,10 @@ resources :products, only: [:index, :new, :create, :edit, :update] end + resources :categories, only: [:new, :create] do + resources :products, only: [:index] + end + get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page' get 'merchants/:id/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' From 7676802c7d0fbe74c262bc767f1fb2d0c79d94a1 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 16:07:09 -0700 Subject: [PATCH 041/283] filled out category action methods --- app/controllers/categories_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 8fcd83c3d1..6fcb6f601a 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -4,5 +4,17 @@ def new end def create + @category = Category.new + # needs to validate that a current merchant is present + # add if statement for Merchant + @category.category_name = params[:category][:category_name] + if @category.save + flash[:success] = "created new category" + # needs a different path when we are further along + redirect_to products_path + else + flash[:error] = @category.errors + render :new + end end end From 4e1e336401a0b39ad2efea0eda031b948bb74c51 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 20 Apr 2018 16:19:55 -0700 Subject: [PATCH 042/283] messing with application view --- app/controllers/application_controller.rb | 4 ++-- app/views/layouts/application.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 94017ba3a6..ab60300dd2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,14 +1,14 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - before_action :require_login + # before_action :require_login def current_merchant @current_merchant ||= Merchant.find(session[:merchant_id]) if session[:merchant_id] end def require_login - if current_user.nil? + if current_merchant.nil? flash[:error] = "You must be logged in to view this section" redirect_to session_path end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 175af179dd..15c537674e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -30,8 +30,8 @@
  • <%= link_to "Hipsty", root_path %>

  • -
  • <%= link_to "Log In", auth_callback_path %>
  • -
  • <%= link_to "Become a Merchant", auth_callback_path %>
  • +
  • <%= link_to "Log In", github_login_path %>
  • +
  • <%= link_to "Become a Merchant", github_login_path %>
  • <%= link_to "Cart", order_path %>
  • <% end %> From 6151443465d9d89fb6b92e011db6314f0c926501 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 16:42:44 -0700 Subject: [PATCH 043/283] adjusted nav link to work with temporary paths --- app/controllers/sessions_controller.rb | 2 +- app/views/layouts/application.html.erb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 0ed669d56b..36112e6ec4 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,5 @@ class SessionsController < ApplicationController - skip_before_action :require_login, only: [:create] + # skip_before_action :require_login, only: [:create] def login auth_hash = request.env['omniauth.auth'] diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 15c537674e..054519a931 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,7 +24,7 @@
  • <%= link_to "Account", account_page_path %>
  • <%= link_to "Log Out", logout_path %>
  • -
  • <%= link_to "Cart", order_path %>
  • +
  • <%= link_to "Cart: Needs Path", root_path %>
  • <% else %>
  • <%= "Welcome Guest" %>
  • @@ -32,7 +32,7 @@

  • <%= link_to "Log In", github_login_path %>
  • <%= link_to "Become a Merchant", github_login_path %>
  • -
  • <%= link_to "Cart", order_path %>
  • +
  • <%= link_to "Cart: Path Needed", root_path %>
  • <% end %> @@ -47,7 +47,7 @@
  • @@ -55,7 +55,7 @@
  • From bd90550352ed538a2cc15cb6eba60acb706dc2b7 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 20 Apr 2018 16:59:30 -0700 Subject: [PATCH 044/283] edit merchant controller --- app/controllers/merchants_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 19c5b733d6..1e7660fa30 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,4 +1,5 @@ class MerchantsController < ApplicationController + def index end @@ -19,4 +20,8 @@ def products_manager flash[:alert] = "You do not have access to this Merchant's product management" end end + + def current_merchant + @current_merchant ||= Merchant.find(session[:merchant_id]) if session[:merchant_id] + end end From 43d5da03de06ad99ca974b1fda6cbbac8e0482a5 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 20 Apr 2018 17:01:39 -0700 Subject: [PATCH 045/283] added end to login action method. whoot we have a nav bar --- app/controllers/sessions_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 36112e6ec4..965fb4658e 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -27,6 +27,7 @@ def login else flash[:alert] = "Logging in through Github not successful" redirect_to root_path + end end def logout From 0b915872b1ab0ae46f00929164a9e24ef678fda1 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 20 Apr 2018 17:13:41 -0700 Subject: [PATCH 046/283] tweaks application_controller#current_merchant, & app html erb conditionals & paths --- app/controllers/application_controller.rb | 3 ++- app/views/layouts/application.html.erb | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab60300dd2..3d535eb590 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,9 +2,10 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception # before_action :require_login + before_action :current_merchant def current_merchant - @current_merchant ||= Merchant.find(session[:merchant_id]) if session[:merchant_id] + @current_merchant = Merchant.find_by(id: session[:merchant_id]) end def require_login diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 054519a931..c09b7b7c22 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,14 +16,13 @@ - #this is going to be the sometimes hidden 2nd nav -
    -
      -
    • <%= link_to "Shop All Products", products_path %> -
    • -
    • - - -
    • -
    • - - -
    • -
    -
    - - - - - + -
      - <% flash.each do | name, message | %> -
    • - <%= name %>: <%= message %> -
    • - <% end %> -
    +
      + <% flash.each do | name, message | %> +
    • + <%= name %>: <%= message %> +
    • + <% end %> +
    -
    - <%= yield %> -
    +
    + <%= yield %> +
    From b64905e2059b7bc36751b4fd1040b2b0f26b754e Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Sun, 22 Apr 2018 13:19:14 -0700 Subject: [PATCH 067/283] create table for order_fulfillment page --- app/controllers/merchants_controller.rb | 7 ++++ .../merchants/order_fulfillment.html.erb | 41 ++++++++++++++----- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 9c9d4aab6f..f094f3d568 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -12,6 +12,13 @@ def account_page #show - only visible by OAuth def order_fulfillment if !@current_merchant flash[:alert] = "You do not have access to this Merchant's order page" + else + @order_products = [] + @current_merchant.products.each do |product| + product.order_products.each do |order_product| + @order_products << order_product + end + end end end diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index e1d6e4fc95..a431fd1aba 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -1,15 +1,36 @@

    <%= @current_merchant.username %>

    All Orders:

    -
      - <% @current_merchant.products.each do |product| %> - <% product.order_products.each do |order_product| %> -
    • - - <%= link_to order_product.order_id, order_product_path(order_product.order_id), class: 'order-link' %> - -
    • + + + + + + + + + + + + + + + <% @order_products.each do | order_product | %> + + + + + + + <% end %> - <% end %> - + +
      Order IDPurchase DateTotalOrder StatusOptions
      + <%= link_to order_product.order_id, order_product_path(order_product.order_id), class: 'order-link' %> + <%= order_product.order.created_at %><%= "NEED TOTAL METHOD" %><%= "NEED TO PUT ORDER STATUS" %> + <%= link_to "NEED SHIP PATH" %> + <%= link_to "NEED CANCEL PATH" %> +
      + +
    From 7d1aceda63bddb8f0f9a64754c44b21c827657d6 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 13:28:42 -0700 Subject: [PATCH 068/283] adds photo url randomize to product seeds and updates status options for order-product-seeds --- db/seed-data/order-product-seeds.csv | 20 +------------------- db/seed-data/product-seeds.csv | 2 +- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/db/seed-data/order-product-seeds.csv b/db/seed-data/order-product-seeds.csv index 8d49c9ae23..ddf6b4b076 100644 --- a/db/seed-data/order-product-seeds.csv +++ b/db/seed-data/order-product-seeds.csv @@ -1,19 +1 @@ -order_id,product_id,quantity,status -3,23,2,complete -3,22,1,complete -3,16,1,cancelled -2,11,1,pending -2,12,1,paid -1,6,1,complete -1,7,3,complete -1,4,10,pending -1,5,1,paid -4,27,1,complete -4,4,1,cancelled -4,9,1,pending -4,2,1,paid -5,8,2,complete -5,4,1,complete -5,12,1,pending -6,20,1,complete -6,27,1,complete \ No newline at end of file +order_id,product_id,quantity,status 3,23,2,paid 3,22,1,paid 3,16,1,cancelled 2,11,1,shipped 2,12,1,paid 1,6,1,shipped 1,7,3,cancelled 1,4,10,paid 1,5,1,paid 4,27,1,paid 4,4,1,shipped 4,9,1,paid 4,2,1,paid 5,8,2,paid 5,4,1,paid 5,12,1,shipped 6,20,1,paid 6,27,1,paid \ No newline at end of file diff --git a/db/seed-data/product-seeds.csv b/db/seed-data/product-seeds.csv index 43a5240b7d..b32def3f0c 100644 --- a/db/seed-data/product-seeds.csv +++ b/db/seed-data/product-seeds.csv @@ -1 +1 @@ -id,name,price,inventory,description,product_active,merchant_id,photo_url 1,1 dozen locally-sourced grass-fed organic cage-free eggs,37,6,"Lorem ipsum dolor amet pok pok bicycle rights 8-bit man braid, kinfolk humblebrag shabby chic.",TRUE,1,https://picsum.photos/200 2,single-origin shade-grown fair-trade coffee,20,30,Mumblecore coloring book DIY YOLO chia farm-to-table leggings man bun glossier trust fund.,TRUE,4,https://picsum.photos/200 3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1,https://picsum.photos/200 4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3,https://picsum.photos/200 5,PBR,52,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://picsum.photos/200 6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial. ,TRUE,1,https://picsum.photos/200 7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4,https://picsum.photos/200 8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2,https://picsum.photos/200 9,cold-pressed green juice,24,6,"Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice.",TRUE,3,https://picsum.photos/200 10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1,https://picsum.photos/200 11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2,https://picsum.photos/200 12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard. ,TRUE,3,https://picsum.photos/200 13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3,https://picsum.photos/200 14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4,https://picsum.photos/200 15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://picsum.photos/200 16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1,https://picsum.photos/200 17,tiny house made from reclaimed wood,23,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1,https://picsum.photos/200 18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3,https://picsum.photos/200 19,crystal collection,20,28,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,2,https://picsum.photos/200 20,ukelele banjo hybrid,40,5,"Hell flames. In willow trees, killer dolls are rotten teeth bite, sheep children virus nibh, in zombies brains unknown ghost creepy. Eerie needles edginess, graveyard on death rotten, disturbing non grave. Drenched scream scared dark. Cat at decapitated guns. Undead obsession tear horrifying, a devil fiendish tense in. Haunt tearin.",TRUE,2,https://picsum.photos/200 21,beard oil,25,10,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled.,TRUE,3,https://picsum.photos/200 22,plaid flannel,30,11,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a, psychotic ashes ghost. Eyeball cat silent, morbid in damp torture, 666 at brains. Haunt suicide silent, gory as demonic alarming, burie.",TRUE,1,https://picsum.photos/200 23,hoodie,23,22,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. Creep cold graves, shadow non fear a, psychotic ashes ghost. Trapped flesh grotesque squeal, bloodcurdling chilling hair-raising spooky hazardous daring. Creep serial killer, bury a scourge menacing, pai.",TRUE,3,https://picsum.photos/200 24,skinny jeans,54,28,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights.,TRUE,2,https://picsum.photos/200 25,vans,56,30,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings.,TRUE,1,https://picsum.photos/200 26,neon fanny pack,40,20,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh.",TRUE,3,https://picsum.photos/200 27,macrame wall hanging,24,40,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,4,https://picsum.photos/200 28,chemex,23,22,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up.,TRUE,3,https://picsum.photos/200 29,fixie bike,54,28,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut",TRUE,4,https://picsum.photos/200 30,wooden bowtie,56,30,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam.,TRUE,1,https://picsum.photos/200 31,man bun,40,20,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. ",TRUE,1,https://picsum.photos/200 32,air plant terrarium,24,40,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo.",TRUE,4,https://picsum.photos/200 33,turntable & vinyl,85,2,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,1,https://picsum.photos/200 \ No newline at end of file +id,name,price,inventory,description,product_active,merchant_id,photo_url 1,1 dozen locally-sourced grass-fed organic cage-free eggs,37,6,"Lorem ipsum dolor amet pok pok bicycle rights 8-bit man braid, kinfolk humblebrag shabby chic.",TRUE,1,https://picsum.photos/200/?random 2,single-origin shade-grown fair-trade coffee,20,30,Mumblecore coloring book DIY YOLO chia farm-to-table leggings man bun glossier trust fund.,TRUE,4,https://picsum.photos/200/?random 3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1,https://picsum.photos/200/?random 4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3,https://picsum.photos/200/?random 5,PBR,52,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://picsum.photos/200/?random 6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial. ,TRUE,1,https://picsum.photos/200/?random 7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4,https://picsum.photos/200/?random 8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2,https://picsum.photos/200/?random 9,cold-pressed green juice,24,6,"Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice.",TRUE,3,https://picsum.photos/200/?random 10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1,https://picsum.photos/200/?random 11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2,https://picsum.photos/200/?random 12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard. ,TRUE,3,https://picsum.photos/200/?random 13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3,https://picsum.photos/200/?random 14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4,https://picsum.photos/200/?random 15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://picsum.photos/200/?random 16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1,https://picsum.photos/200/?random 17,tiny house made from reclaimed wood,23,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1,https://picsum.photos/200/?random 18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3,https://picsum.photos/200/?random 19,crystal collection,20,28,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,2,https://picsum.photos/200/?random 20,ukelele banjo hybrid,40,5,"Hell flames. In willow trees, killer dolls are rotten teeth bite, sheep children virus nibh, in zombies brains unknown ghost creepy. Eerie needles edginess, graveyard on death rotten, disturbing non grave. Drenched scream scared dark. Cat at decapitated guns. Undead obsession tear horrifying, a devil fiendish tense in. Haunt tearin.",TRUE,2,https://picsum.photos/200/?random 21,beard oil,25,10,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled.,TRUE,3,https://picsum.photos/200/?random 22,plaid flannel,30,11,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a, psychotic ashes ghost. Eyeball cat silent, morbid in damp torture, 666 at brains. Haunt suicide silent, gory as demonic alarming, burie.",TRUE,1,https://picsum.photos/200/?random 23,hoodie,23,22,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. Creep cold graves, shadow non fear a, psychotic ashes ghost. Trapped flesh grotesque squeal, bloodcurdling chilling hair-raising spooky hazardous daring. Creep serial killer, bury a scourge menacing, pai.",TRUE,3,https://picsum.photos/200/?random 24,skinny jeans,54,28,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights.,TRUE,2,https://picsum.photos/200/?random 25,vans,56,30,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings.,TRUE,1,https://picsum.photos/200/?random 26,neon fanny pack,40,20,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh.",TRUE,3,https://picsum.photos/200/?random 27,macrame wall hanging,24,40,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,4,https://picsum.photos/200/?random 28,chemex,23,22,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up.,TRUE,3,https://picsum.photos/200/?random 29,fixie bike,54,28,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut",TRUE,4,https://picsum.photos/200/?random 30,wooden bowtie,56,30,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam.,TRUE,1,https://picsum.photos/200/?random 31,man bun,40,20,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. ",TRUE,1,https://picsum.photos/200/?random 32,air plant terrarium,24,40,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo.",TRUE,4,https://picsum.photos/200/?random 33,turntable & vinyl,85,2,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,1,https://picsum.photos/200/?random \ No newline at end of file From 3d37041fe05e45c62bc5e46c14cae205793783fd Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Sun, 22 Apr 2018 13:31:26 -0700 Subject: [PATCH 069/283] Link order_fulfillment page to invidiual order page --- app/views/merchants/order_fulfillment.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index a431fd1aba..e841128f93 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -18,7 +18,7 @@ <% @order_products.each do | order_product | %> - <%= link_to order_product.order_id, order_product_path(order_product.order_id), class: 'order-link' %> + <%= link_to order_product.order_id, order_path(order_product.order_id), class: 'order-link' %> <%= order_product.order.created_at %> <%= "NEED TOTAL METHOD" %> From 9b4489d40fd85ee1ac0a517b1c2dc586b1b4e57a Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 13:32:03 -0700 Subject: [PATCH 070/283] adds format_price helper to app helper --- app/helpers/application_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945c..016d1bb717 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,7 @@ module ApplicationHelper + + def format_price + sprintf('%.2f', (self.price)) + end + end From d0560585b45d961e8ac945da4c23873730600e0b Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 13:32:26 -0700 Subject: [PATCH 071/283] adds products#index view --- app/views/products/index.html.erb | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index f8eeb82674..53a50ca80c 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -1,2 +1,29 @@ -

    Products#index

    -

    Find me in app/views/products/index.html.erb

    +
    + <% if params[:category_id] %> +
    Category: <%= Category.find(params[:category_id]).category_name %>
    + <% elsif params[:merchant_id] %> +
    Merchant: <%= Merchant.find(params[:merchant_id]).username %>
    + <% else %> +
    All Products
    + <% end %> + + <% if @products.where(product_active: true).count == 0 %> +
    +

    Sorry, these products may not be available...

    +
    + <% end %> + + <% @products.each do |p| %> + <% if p.product_active %> + <%= link_to product_path(p.id) do %> +
    + product image +

    <%= p.name.capitalize %>

    +

    $<%= p.format_price %>

    +
    + <% end %> + <% end %> + <% end %> +
    +
    +
    From b9d79284fd4784dd97da645231a961d2673a2025 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 13:47:40 -0700 Subject: [PATCH 072/283] fixes format_price method and product index view --- app/helpers/application_helper.rb | 6 +++--- app/views/products/index.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 016d1bb717..e5d6657f88 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ module ApplicationHelper - def format_price - sprintf('%.2f', (self.price)) - end + def format_price(price) + sprintf('%.2f', price) + end end diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 53a50ca80c..c04ed487d1 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -19,7 +19,7 @@
    product image

    <%= p.name.capitalize %>

    -

    $<%= p.format_price %>

    +

    $<%= format_price(p.price) %>

    <% end %> <% end %> From 57b1ba72467c88ceec9b775a08250309b4801374 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Sun, 22 Apr 2018 14:01:16 -0700 Subject: [PATCH 073/283] added product show method and started to get product show view up and running --- app/assets/stylesheets/application.css | 5 +++++ .../stylesheets/foundation_and_overrides.scss | 2 -- app/controllers/products_controller.rb | 1 + app/views/products/show.html.erb | 21 +++++++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 735f44f648..b8a9f6b808 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -17,6 +17,11 @@ *= require foundation_and_overrides */ + /*.custom-dropdown-container-class { + @include dropdown-container(); + + li { @include dropdown-style; } + }*/ .page-header li { display: inline; diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss index ed4c5a0ecf..f184f5ca99 100644 --- a/app/assets/stylesheets/foundation_and_overrides.scss +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -57,5 +57,3 @@ @import 'motion-ui/motion-ui'; @include motion-ui-transitions; @include motion-ui-animations; - - diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index d9910db9f4..1ba77689c5 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -26,6 +26,7 @@ def index end def show + @product = Product.find_by(id: params[:id]) end def new diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 5f44ec44d2..2a3b3ca997 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -1,2 +1,19 @@ -

    Products#show

    -

    Find me in app/views/products/show.html.erb

    + +
    +

    Product: <%= @product.name %>

    + + product-image +

    Merchant: <%= link_to @product.merchant.username, merchant_path(@product.merchant) %>

    +

    Description: <%=@product.description %>

    +

    Cost: $<%= format_price(@product.price) %>

    +

    <%= @product.inventory %> in stock

    +

    Categories: <% @product.categories.each do |c| %> <%= link_to c.category_name, category_products_path(c.id) %> + <% end %>

    +

    Quantity:

    + <%= form_for :order_products, url: order_product_path, method: :post do |f| %> + <%= f.hidden_field :product_id, value: @product.id %> + <%= f.select(:inventory, (1..@product.inventory)) %> + + <%= f.submit "Add to Cart", class: "button" %> + <% end %> +
    From 7926e5fdd1b0cd7f10cbd258a83165274e26ee6d Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 14:27:52 -0700 Subject: [PATCH 074/283] adds reviews controller, nested review#new route within product#show --- app/assets/javascripts/reviews.js | 2 ++ app/assets/stylesheets/reviews.scss | 3 +++ app/controllers/reviews_controller.rb | 7 +++++++ app/helpers/reviews_helper.rb | 2 ++ app/views/reviews/create.html.erb | 2 ++ app/views/reviews/new.html.erb | 2 ++ config/routes.rb | 4 ++++ test/controllers/reviews_controller_test.rb | 14 ++++++++++++++ 8 files changed, 36 insertions(+) create mode 100644 app/assets/javascripts/reviews.js create mode 100644 app/assets/stylesheets/reviews.scss create mode 100644 app/controllers/reviews_controller.rb create mode 100644 app/helpers/reviews_helper.rb create mode 100644 app/views/reviews/create.html.erb create mode 100644 app/views/reviews/new.html.erb create mode 100644 test/controllers/reviews_controller_test.rb diff --git a/app/assets/javascripts/reviews.js b/app/assets/javascripts/reviews.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/reviews.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/reviews.scss b/app/assets/stylesheets/reviews.scss new file mode 100644 index 0000000000..6ea2454d26 --- /dev/null +++ b/app/assets/stylesheets/reviews.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the reviews 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/reviews_controller.rb b/app/controllers/reviews_controller.rb new file mode 100644 index 0000000000..102b3bb888 --- /dev/null +++ b/app/controllers/reviews_controller.rb @@ -0,0 +1,7 @@ +class ReviewsController < ApplicationController + def new + end + + def create + end +end diff --git a/app/helpers/reviews_helper.rb b/app/helpers/reviews_helper.rb new file mode 100644 index 0000000000..682b7b1abc --- /dev/null +++ b/app/helpers/reviews_helper.rb @@ -0,0 +1,2 @@ +module ReviewsHelper +end diff --git a/app/views/reviews/create.html.erb b/app/views/reviews/create.html.erb new file mode 100644 index 0000000000..44bf11c2ed --- /dev/null +++ b/app/views/reviews/create.html.erb @@ -0,0 +1,2 @@ +

    Reviews#create

    +

    Find me in app/views/reviews/create.html.erb

    diff --git a/app/views/reviews/new.html.erb b/app/views/reviews/new.html.erb new file mode 100644 index 0000000000..9cc9d7f56b --- /dev/null +++ b/app/views/reviews/new.html.erb @@ -0,0 +1,2 @@ +

    Reviews#new

    +

    Find me in app/views/reviews/new.html.erb

    diff --git a/config/routes.rb b/config/routes.rb index 9efb72fc9a..b617ee84fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,10 @@ resources :products, only: [:index, :show] + resources :products, only: [:show] do + resources :reviews, only: [:new] + end + get '/product/product_id/add_to_order', to: 'products#add_to_order', as: 'add_to_order' resources :orders, only: [:show, :create, :update, :destroy] diff --git a/test/controllers/reviews_controller_test.rb b/test/controllers/reviews_controller_test.rb new file mode 100644 index 0000000000..a0a226d82d --- /dev/null +++ b/test/controllers/reviews_controller_test.rb @@ -0,0 +1,14 @@ +require "test_helper" + +describe ReviewsController do + it "should get new" do + get reviews_new_url + value(response).must_be :success? + end + + it "should get create" do + get reviews_create_url + value(response).must_be :success? + end + +end From 835d328753f05a3f42c4ea34bb94818e6483e0c1 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 14:28:23 -0700 Subject: [PATCH 075/283] messed with custom route for add_to_order in product paths, filled out basic add_to_order action in product controller logic, and created @current_cart helper controller filter to store a browser's active cart --- app/controllers/application_controller.rb | 5 +++++ app/controllers/products_controller.rb | 22 ++++++++++++++++++++++ config/routes.rb | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5e780b0d6c..256ed2ef81 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,11 +2,16 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :current_merchant + before_action :current_cart def current_merchant @current_merchant ||= Merchant.find(session[:merchant_id]) if session[:merchant_id] end + def current_cart + @current_cart ||= Order.find(session[:order_id]) if session[:order_id] + end + def render_404 # DPR: this will actually render a 404 page in production raise ActionController::RoutingError.new('Not Found') diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index d9910db9f4..5c912890bf 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -64,6 +64,28 @@ def update end def add_to_order + if @current_cart + product = Product.find_by(id: params[:id]) + @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: 1, status: 'pending') + if @order_product.save + flash[:success] = "Successfully added product to cart" + redirect_to order_path(@current_cart.id) + else + flash[:alert] = "Failed to add to cart" + render :show + end + else + session[:order_id] = Order.create.id + product = Product.find_by(id: params[:id]) + @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: 1, status: 'pending') + if @order_product.save + flash[:success] = "Successfully added product to cart" + redirect_to order_path(session[:order_id]) + else + flash[:alert] = "Failed to add to cart" + render :show + end + end end def active diff --git a/config/routes.rb b/config/routes.rb index 9efb72fc9a..4df5524e39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ resources :products, only: [:index, :show] - get '/product/product_id/add_to_order', to: 'products#add_to_order', as: 'add_to_order' + get '/product/:id/add_to_order', to: 'products#add_to_order', as: 'add_to_order' resources :orders, only: [:show, :create, :update, :destroy] From c8994aa42a7b1f853c4787858b10690d1ceaab3e Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Sun, 22 Apr 2018 14:56:42 -0700 Subject: [PATCH 076/283] refactor changing status for product --- app/controllers/merchants_controller.rb | 2 +- app/controllers/products_controller.rb | 17 ++++++----------- app/views/merchants/products_manager.html.erb | 4 ++-- config/routes.rb | 5 +---- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index f094f3d568..dc385e92c8 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,4 +1,4 @@ -class MerchantsController < ApplicationController + class MerchantsController < ApplicationController def index end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 71a4f72bdc..e752b0d1b1 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -18,8 +18,8 @@ def index else @products = Product.includes(:merchant).where(product_active: true, products: {merchant_id: params[:merchant_id]}) end - # elsif params[:search] - # @products = Product.search(params[:search]).order(:name) + # elsif params[:search] + # @products = Product.search(params[:search]).order(:name) else @products = Product.where(product_active: true).order(:id) end @@ -89,16 +89,11 @@ def add_to_order end end - def active + def status + status = params[:status] @product = Product.find_by(id: params[:id]) - @product.update_attributes(product_active: false) - redirect_to products_manager_path - end - - def retire - @product = Product.find_by(id: params[:id]) - @product.update_attributes(product_active: true) - redirect_to products_manager_path + @product.update_attributes(product_active: status) + redirect_to products_manager_path end private diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index 285cb7a08e..3b45dd4b01 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -33,9 +33,9 @@ <%= product.product_active == true ? "Active" : "Retired" %> <% if product.product_active == true %> - <%= link_to "Retire Product?", active_path(@current_merchant.id, product.id), method: :patch %> + <%= link_to "Retire Product?", status_path(@current_merchant.id, product.id, status: false), method: :patch %> <% else %> - <%= link_to "Activate Product?", retire_path(@current_merchant.id, product.id), method: :patch %> + <%= link_to "Activate Product?", status_path(@current_merchant.id, product.id, status: true), method: :patch %> <% end %> <%= link_to 'edit', edit_merchant_product_path(@current_merchant.id, product.id), class: 'product-link' %> diff --git a/config/routes.rb b/config/routes.rb index 00b3ae41ca..0f51194ae9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,10 +35,7 @@ resources :order_products, only: [:edit, :update] - patch 'merchant/:merchant_id/products/:id/active', to: 'products#active', as: 'active' - - patch 'merchant/:merchant_id/products/:id/retired', to: 'products#retire', as: 'retire' - + patch 'merchant/:merchant_id/products/:id/status', to: 'products#status', as: 'status' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end From 1e390283540ed82d2f9bb879ba402293f03bc652 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Sun, 22 Apr 2018 15:09:42 -0700 Subject: [PATCH 077/283] average rating method in product model --- app/models/product.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/product.rb b/app/models/product.rb index c8b4747fc9..7ff76f5506 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -8,4 +8,14 @@ class Product < ApplicationRecord validates :price, presence: true, format: { with: /\A\d+(?:\.\d{0,2})?\z/ }, numericality: { greater_than: 0, less_than: 1000000 } validates_numericality_of :inventory, :only_integer => true, :greater_than_or_equal_to => 0 + def average_rating + num_of_ratings = 0 + total = 0.0 + self.reviews.each do |review| + total += review.rating + num_of_ratings += 1 + end + average = (total/num_of_ratings) + return average + end end From 86fb9d747114c6d8c0a5046539d822eea9c8c5af Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 15:16:57 -0700 Subject: [PATCH 078/283] accounted for no inventory, invalid product id, and retired product in the add_to_order action method logic --- app/controllers/products_controller.rb | 46 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 5c912890bf..d854132065 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -64,26 +64,36 @@ def update end def add_to_order - if @current_cart - product = Product.find_by(id: params[:id]) - @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: 1, status: 'pending') - if @order_product.save - flash[:success] = "Successfully added product to cart" - redirect_to order_path(@current_cart.id) - else - flash[:alert] = "Failed to add to cart" - render :show - end + product = Product.find_by(id: params[:id]) + if product.nil? + flash[:alert] = "That product does not exist" + redirect_to products_path + elsif product.product_active == false + flash[:alert] = "That product is currently retired" + redirect_to products_path + elsif product.inventory < 1 + flash[:alert] = "That product is out of stock." + redirect_to products_path else - session[:order_id] = Order.create.id - product = Product.find_by(id: params[:id]) - @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: 1, status: 'pending') - if @order_product.save - flash[:success] = "Successfully added product to cart" - redirect_to order_path(session[:order_id]) + if @current_cart + @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: 1, status: 'pending') + if @order_product.save + flash[:success] = "Successfully added product to cart" + redirect_to order_path(@current_cart.id) + else + flash[:alert] = "Failed to add to cart" + render :show + end else - flash[:alert] = "Failed to add to cart" - render :show + session[:order_id] = Order.create.id + @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: 1, status: 'pending') + if @order_product.save + flash[:success] = "Successfully added product to cart" + redirect_to order_path(session[:order_id]) + else + flash[:alert] = "Failed to add to cart" + render :show + end end end end From ab88dff6da13ea69ab8f15e369ca41115ad405b2 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 15:23:56 -0700 Subject: [PATCH 079/283] adds 'write a review' link to product show view --- 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 2a3b3ca997..7c7cb67892 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -17,3 +17,7 @@ <%= f.submit "Add to Cart", class: "button" %> <% end %> + +
    +

    <%= link_to "Write a Review", new_product_review_path(@product.id) %>

    +
    From 3ee65aaac4588a177abf30c7ba2d699b4dfa0fb4 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 15:32:45 -0700 Subject: [PATCH 080/283] added logic to add_to_order action to prevent merchant from add their own product to their cart --- app/controllers/products_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index c8e93f9bcf..ad98cbf5cf 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -69,6 +69,9 @@ def add_to_order if product.nil? flash[:alert] = "That product does not exist" redirect_to products_path + elsif product.merchant == @current_merchant + flash[:alert] = "This is your product" + redirect_to products_path elsif product.product_active == false flash[:alert] = "That product is currently retired" redirect_to products_path From 1046a41221e7c30f5f2a35b5b4bac469fc7bf961 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Sun, 22 Apr 2018 15:39:20 -0700 Subject: [PATCH 081/283] adds review average and shows reviews on product show page --- app/views/products/show.html.erb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 7c7cb67892..ea9fc5995f 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -18,6 +18,31 @@ <% end %> +
    +

    Reviews

    +

    + Average rating: + <% if @product.reviews.count == 0 %> + + No Reviews Yet + + <%else%> + <%= @product.average_rating %> + <%end%> +

    + +

    +
      + <% @product.reviews.each do |r| %> +

      +

    • Rating: <%= r.rating %>
    • +
    • + <%= r.description %>
    • +

      + <% end %> +
    +
    +

    <%= link_to "Write a Review", new_product_review_path(@product.id) %>

    From adf1a37b75e7ae66aae1470aedbbbd65415344f4 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Sun, 22 Apr 2018 15:43:11 -0700 Subject: [PATCH 082/283] rename variables for product manager --- app/controllers/products_controller.rb | 4 ++-- app/views/merchants/products_manager.html.erb | 4 ++-- config/routes.rb | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index e752b0d1b1..57d063c7bb 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -89,8 +89,8 @@ def add_to_order end end - def status - status = params[:status] + def product_status + status = params[:product_active] @product = Product.find_by(id: params[:id]) @product.update_attributes(product_active: status) redirect_to products_manager_path diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index 3b45dd4b01..340f04e3bb 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -33,9 +33,9 @@ <%= product.product_active == true ? "Active" : "Retired" %> <% if product.product_active == true %> - <%= link_to "Retire Product?", status_path(@current_merchant.id, product.id, status: false), method: :patch %> + <%= link_to "Retire Product?", product_status_path(@current_merchant.id, product.id, product_active: false), method: :patch %> <% else %> - <%= link_to "Activate Product?", status_path(@current_merchant.id, product.id, status: true), method: :patch %> + <%= link_to "Activate Product?", product_status_path(@current_merchant.id, product.id, product_active: true), method: :patch %> <% end %> <%= link_to 'edit', edit_merchant_product_path(@current_merchant.id, product.id), class: 'product-link' %> diff --git a/config/routes.rb b/config/routes.rb index 0f51194ae9..078369e23b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,7 +35,11 @@ resources :order_products, only: [:edit, :update] - patch 'merchant/:merchant_id/products/:id/status', to: 'products#status', as: 'status' + patch 'merchant/:merchant_id/products/:id/active', to: 'products#active', as: 'active' + + patch 'merchant/:merchant_id/products/:id/retired', to: 'products#retire', as: 'retire' + + patch 'merchant/:merchant_id/products/:id/status', to: 'products#product_status', as: 'product_status' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end From 09f2e04d9135c920808f7b72ab3b8e3e29d9fc2c Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 15:44:32 -0700 Subject: [PATCH 083/283] adds nested route for product review --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 0f51194ae9..34928606f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,7 @@ resources :products, only: [:index, :show] resources :products, only: [:show] do - resources :reviews, only: [:new] + resources :reviews, only: [:new, :create] end get '/product/:id/add_to_order', to: 'products#add_to_order', as: 'add_to_order' From 1aefee87243d02b2da3e94cafdc3a35c0045dbd4 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 15:54:01 -0700 Subject: [PATCH 084/283] adds review#new and review#create, with strong params --- app/controllers/reviews_controller.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index 102b3bb888..a6e964aed4 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -1,7 +1,24 @@ class ReviewsController < ApplicationController def new + @review = Review.new + @review.product = Product.find(params[:product_id]) end def create + @review = Review.new(review_params) + @review.product = Product.find(params[:product_id]) + if @review.save + flash[:success] = "Thanks for your review!" + redirect_to product_path(@review.product) + else + flash.now[:alert] = @review.errors + render :new + end + end + + private + + def review_params + params.require(:review).permit(:product_id, :rating, :description) end end From 8536d4d43d9aa7945c9df63c93412eb044f5199e Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 15:54:06 -0700 Subject: [PATCH 085/283] added form to checkout view to add billing information to order and finish the buyers side of the order --- app/controllers/orders_controller.rb | 1 + app/views/orders/checkout.html.erb | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index a76f0ee877..1c398fb459 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -12,6 +12,7 @@ def checkout #edit to enter billing info end def paid #submit after checkout + end def destroy #this clears the cart before order has gone into paid status diff --git a/app/views/orders/checkout.html.erb b/app/views/orders/checkout.html.erb index e8a98e51dc..0e751cf255 100644 --- a/app/views/orders/checkout.html.erb +++ b/app/views/orders/checkout.html.erb @@ -1,2 +1,19 @@ -

    Orders#checkout

    -

    Find me in app/views/orders/checkout.html.erb

    +

    Checkout your Order:

    +

    Please fill out your billing info.

    +<%= form_for @current_cart do |f| %> +<%= f.label :billing_email, "Email" %> +<%= f.text_field :billing_email %> +<%= f.label :billing_address, "Shipping Address" %> +<%= f.text_field :billing_address %> +<%= f.label :billing_name, "Name on Card" %> +<%= f.text_field :billing_name %> +<%= f.label :billing_num, "Credit Card Number" %> +<%= f.text_field :billing_num %> +<%= f.label :billing_exp, "Credit Card Expiration" %> +<%= f.text_field :billing_exp, placeholder: "mm/yy" %> +<%= f.label :billing_cvv, "Credit Card CVV" %> +<%= f.text_field :billing_cvv %> +<%= f.label :billing_zipcode, "Credit Card Zipcode" %> +<%= f.text_field :billing_zipcode %> +<%= f.submit 'Place Order'%> +<% end %> From 54181f1924921f68acf0d55138a59c8bbb2828f6 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 15:54:53 -0700 Subject: [PATCH 086/283] adds form for new review --- app/views/reviews/new.html.erb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/views/reviews/new.html.erb b/app/views/reviews/new.html.erb index 9cc9d7f56b..8245f86c7b 100644 --- a/app/views/reviews/new.html.erb +++ b/app/views/reviews/new.html.erb @@ -1,2 +1,13 @@ -

    Reviews#new

    -

    Find me in app/views/reviews/new.html.erb

    +

    Add a Review

    +<%= form_for @review, url: product_reviews_path(params[:product_id]) do |f| %> + + Product: <%= @review.product.name %> + + <%= f.label :rating, "Rate this product" %> + <%= f.select :rating, (1..5).to_a, :include_blank => true %> + + <%= f.label :description, "Review" %> + <%= f.text_area :description, placeholder: "Write your review here. What did you like the most? What did you like the least?" %> + + <%= f.submit "Submit Review", class: "button" %> +<% end %> From 9867666caa26de5084718cecb25bbd768dd7d0e1 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Sun, 22 Apr 2018 16:33:48 -0700 Subject: [PATCH 087/283] still messing with dropdown menu bullshit --- app/assets/javascripts/application.js | 4 ++ app/controllers/products_controller.rb | 2 +- app/views/layouts/application.html.erb | 65 ++++++++++++++------------ app/views/products/show.html.erb | 4 ++ 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f04673be81..f9e464900e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,3 +18,7 @@ //= require_tree . $(function(){ $(document).foundation(); }); + +$(document).on('ready page:load', function () { +$(document).foundation(); +}); diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 57d063c7bb..c9a556e096 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -56,7 +56,7 @@ def update @product = Product.find_by(id: params[:id]) if @product.update(product_params) - flash[:success] = "Successfully update your product, #{@product.id}" + flash[:success] = "Successfully updated your product: #{@product.name}" redirect_to product_path(@product.id) else flash[:error] = @product.errors diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9681e2cea6..8bedaadc8e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -43,38 +43,41 @@
    • <%= link_to "Shop All Products", products_path %>
    • -
    • - - -
    • -
    • - - -
    • -
    - - -
      - <% flash.each do | name, message | %> -
    • - <%= name %>: <%= message %> -
    • - <% end %> -
    + +
  • + Shop By Category + +
      + <% Category.all.each do |category| %> +
    • <%= link_to category.category_name, category_products_path(category.id) %>
    • + <% end %> +
    +
  • +
  • + + +
  • + + + + +
      + <% flash.each do | name, message | %> +
    • + <%= name %>: <%= message %> +
    • + <% end %> +
    -
    - <%= yield %> -
    +
    + <%= yield %> +
    - - + + diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index ea9fc5995f..ca28e90a72 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -6,7 +6,11 @@

    Merchant: <%= link_to @product.merchant.username, merchant_path(@product.merchant) %>

    Description: <%=@product.description %>

    Cost: $<%= format_price(@product.price) %>

    + <% if @product.inventory == 0 %> +

    Out of Stock

    + <%else%>

    <%= @product.inventory %> in stock

    + <%end%>

    Categories: <% @product.categories.each do |c| %> <%= link_to c.category_name, category_products_path(c.id) %> <% end %>

    Quantity:

    From 00a8e1251a07d5cc484fa4db4fb7d10aabbc0406 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Sun, 22 Apr 2018 16:34:04 -0700 Subject: [PATCH 088/283] adds conditional logic to disallow merchant from reviewing her own products --- app/controllers/reviews_controller.rb | 5 ++++- app/views/products/show.html.erb | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index a6e964aed4..401b32804d 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -7,7 +7,10 @@ def new def create @review = Review.new(review_params) @review.product = Product.find(params[:product_id]) - if @review.save + if @current_merchant == @review.product.merchant + flash[:message] = "You cannot review your own products" + redirect_to product_path(@review.product) + elsif @review.save flash[:success] = "Thanks for your review!" redirect_to product_path(@review.product) else diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index ea9fc5995f..68bba548de 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -44,5 +44,7 @@
    -

    <%= link_to "Write a Review", new_product_review_path(@product.id) %>

    + <% if @current_merchant != @product.merchant %> +

    <%= link_to "Write a Review", new_product_review_path(@product.id) %>

    + <% end %>
    From 0ccfe8d5431fd4ef3f6ccece7047c49d36f69628 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 16:52:51 -0700 Subject: [PATCH 089/283] added logic to the paid action in the order controller, updated the paid view as the confirmation page and added temporary content to test the results, and update the form path in checkout view --- app/controllers/orders_controller.rb | 28 +++++++++++++++++++++++- app/views/orders/checkout.html.erb | 32 ++++++++++++++-------------- app/views/orders/paid.html.erb | 11 ++++++++-- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 1c398fb459..21201f89bc 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -12,9 +12,35 @@ def checkout #edit to enter billing info end def paid #submit after checkout - + if @current_cart.update(billing_params) + @current_cart.order_products.each do |order_product| + order_product.update_attributes(status: "paid") + end + @current_cart.update_attributes(status: "paid") + flash[:success] = "Order received! Thank you for your purchase." + session[:order_id] = nil + elsif @current_cart.errors.any? + flash.now[:error] = @current_cart.errors + render :checkout + else + flash[:alert] = "Something went wrong, and we couldn't process your order." + render :checkout + end end def destroy #this clears the cart before order has gone into paid status end + + private + + def billing_params + params.require(:order).permit( + :billing_address, + :billing_name, + :billing_num, + :billing_exp, + :billing_cvv, + :billing_zipcode + ) + end end diff --git a/app/views/orders/checkout.html.erb b/app/views/orders/checkout.html.erb index 0e751cf255..1577906cb8 100644 --- a/app/views/orders/checkout.html.erb +++ b/app/views/orders/checkout.html.erb @@ -1,19 +1,19 @@

    Checkout your Order:

    Please fill out your billing info.

    -<%= form_for @current_cart do |f| %> -<%= f.label :billing_email, "Email" %> -<%= f.text_field :billing_email %> -<%= f.label :billing_address, "Shipping Address" %> -<%= f.text_field :billing_address %> -<%= f.label :billing_name, "Name on Card" %> -<%= f.text_field :billing_name %> -<%= f.label :billing_num, "Credit Card Number" %> -<%= f.text_field :billing_num %> -<%= f.label :billing_exp, "Credit Card Expiration" %> -<%= f.text_field :billing_exp, placeholder: "mm/yy" %> -<%= f.label :billing_cvv, "Credit Card CVV" %> -<%= f.text_field :billing_cvv %> -<%= f.label :billing_zipcode, "Credit Card Zipcode" %> -<%= f.text_field :billing_zipcode %> -<%= f.submit 'Place Order'%> +<%= form_for @current_cart, url: url_for(controller: 'orders', action: 'paid') do |f| %> + <%= f.label :billing_email, "Email" %> + <%= f.text_field :billing_email %> + <%= f.label :billing_address, "Shipping Address" %> + <%= f.text_field :billing_address %> + <%= f.label :billing_name, "Name on Card" %> + <%= f.text_field :billing_name %> + <%= f.label :billing_num, "Credit Card Number" %> + <%= f.text_field :billing_num %> + <%= f.label :billing_exp, "Credit Card Expiration" %> + <%= f.text_field :billing_exp, placeholder: "mm/yy" %> + <%= f.label :billing_cvv, "Credit Card CVV" %> + <%= f.text_field :billing_cvv %> + <%= f.label :billing_zipcode, "Credit Card Zipcode" %> + <%= f.text_field :billing_zipcode %> + <%= f.submit 'Place Order'%> <% end %> diff --git a/app/views/orders/paid.html.erb b/app/views/orders/paid.html.erb index 5e7277a5dc..e9dacb90c3 100644 --- a/app/views/orders/paid.html.erb +++ b/app/views/orders/paid.html.erb @@ -1,2 +1,9 @@ -

    Orders#paid

    -

    Find me in app/views/orders/paid.html.erb

    +

    Confirmation of Order

    +

    Order Sucessfully!

    +<%= @current_cart.id %> +<% if session[:order_id].nil? %> +

    Cart Empty

    +<% end %> +<% @current_cart.order_products.each do |order_product| %> +

    <%= order_product.product.name %>

    +<% end %> From ecb67f04b8f446cca5b5e230f08037eaf1bbed24 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Sun, 22 Apr 2018 17:11:33 -0700 Subject: [PATCH 090/283] Show total price and options link in order-fulfillment --- app/controllers/order_products_controller.rb | 4 ++++ app/models/order_product.rb | 6 +++++- app/views/merchants/order_fulfillment.html.erb | 12 ++++++++---- config/application.rb | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/order_products_controller.rb b/app/controllers/order_products_controller.rb index 1b2bd9c75f..0dbef621a4 100644 --- a/app/controllers/order_products_controller.rb +++ b/app/controllers/order_products_controller.rb @@ -3,5 +3,9 @@ def edit end def update + order_status = params[:status] + @order_product = OrderProduct.find_by(id: params[:id]) + @order_product.update_attributes(status: order_status) + redirect_to order_fulfillment_path end end diff --git a/app/models/order_product.rb b/app/models/order_product.rb index a21823a817..0d6d623751 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,8 +1,12 @@ class OrderProduct < ApplicationRecord - + belongs_to :order belongs_to :product validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } + def calculate_cost + self.product.price * self.quantity + end + end diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index e841128f93..5926f51154 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -21,11 +21,15 @@ <%= link_to order_product.order_id, order_path(order_product.order_id), class: 'order-link' %> <%= order_product.order.created_at %> - <%= "NEED TOTAL METHOD" %> - <%= "NEED TO PUT ORDER STATUS" %> + <%= "$#{format_price(order_product.calculate_cost)}" %> + <%= order_product.status %> + - <%= link_to "NEED SHIP PATH" %> - <%= link_to "NEED CANCEL PATH" %> + <% if order_product.status == "paid" %> + <%= link_to "Ship", order_product_path(order_product.id, status: "shipped"), method: :patch %> + <%= link_to "Cancel", + order_product_path(order_product.id, status: "cancelled"), method: :patch %> + <% end %> <% end %> diff --git a/config/application.rb b/config/application.rb index 5f6ca0f9b2..ec02e2594e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require_relative 'boot' + require_relative 'boot' require 'rails/all' From dbc61f40dec2e7bfefa79feb238b39ac3b83ba22 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Sun, 22 Apr 2018 22:47:39 -0700 Subject: [PATCH 091/283] updated nav link in application.html.erb to direct to cart, still need to actually fill out that view --- app/views/layouts/application.html.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8bedaadc8e..62b18cc9aa 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -31,7 +31,14 @@
  • <%= link_to "Log In", github_login_path %>
  • <%= link_to "Become a Merchant", github_login_path %>
  • -
  • <%= link_to "Cart: Path Needed", root_path %>
  • +
  • + <% if @current_cart.nil? %> + Cart Empty + <% else %> + <% count = @current_cart.order_products.count %> + <%= link_to "Cart(#{count})", order_path(@current_cart.id) %> + <% end %> +
  • <% end %> From f213502559e0da6b8c4a4bca20ab42952c251c2a Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 09:32:13 -0700 Subject: [PATCH 092/283] small application.html changes git pull origin master --- app/assets/javascripts/application.js | 8 +------- app/views/layouts/application.html.erb | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f9e464900e..f8d766545e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,11 +14,5 @@ // //= require rails-ujs //= require foundation -//= require turbolinks -//= require_tree . - -$(function(){ $(document).foundation(); }); -$(document).on('ready page:load', function () { -$(document).foundation(); -}); +//= require_tree . diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8bedaadc8e..07cf09c6ec 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -46,7 +46,7 @@
  • - Shop By Category + Shop By Category
      <% Category.all.each do |category| %> From 92a4d2c381807a278028f50cfae9c7405e90b1dc Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 10:02:51 -0700 Subject: [PATCH 093/283] adds fixtures for orders --- test/fixtures/orders.yml | 56 +++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index fc4aa2bc1f..f9396c5ab4 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -1,21 +1,41 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - status: MyString - billing_email: MyString - billing_address: MyString - billing_name: MyString - billing_num: 1 - billing_exp: MyString - billing_cvv: 1 - billing_zipcode: 1 +order_one: + status: pending + billing_email: test@test.com + billing_address: 123 Street + billing_name: Ada Lovelace + billing_num: 123456789123 + billing_exp: 12/18 + billing_cvv: 123 + billing_zipcode: 12345 -two: - status: MyString - billing_email: MyString - billing_address: MyString - billing_name: MyString - billing_num: 1 - billing_exp: MyString - billing_cvv: 1 - billing_zipcode: 1 +order_two: + status: paid + billing_email: alfredo@ortiz.biz + billing_address: 9729 Ernser Landing + billing_name: Emma Ghost + billing_num: 1234123412341234 + billing_exp: 10/21/18 + billing_cvv: 224 + billing_zipcode: 70842 + +order_three: + status: complete + billing_email: coy@purdymckenzie.co + billing_address: 48144 Hackett Wells + billing_name: Rowena Ravenclaw + billing_num: 987654321098 + billing_exp: 6/18 + billing_cvv: 333 + billing_zipcode: 95176 + +order_four: + status: paid + billing_email: jaqueline_cole@littel.co + billing_address: 5414 Swift Ramp + billing_name: Cuthbert Binns + billing_num: 567890123456 + billing_exp: 6/18 + billing_cvv: 640 + billing_zipcode: 67894 From 008fda4a7f4a661c2e1a0f182ffad479393171f0 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Mon, 23 Apr 2018 10:06:47 -0700 Subject: [PATCH 094/283] added fixtures for category.yml in test directory --- test/fixtures/categories.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml index bbb1bce1e4..1b964b747e 100644 --- a/test/fixtures/categories.yml +++ b/test/fixtures/categories.yml @@ -1,7 +1,20 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - category_name: MyString - -two: - category_name: MyString +clothes: + category_name: Clothing +extra: + category_name: So Extra +home: + category_name: Home +food: + category_name: food +beverage: + category_name: Beverage +kitchen: + category_name: Kitchen +spiritual: + category_name: Spiritual AF +heard: + category_name: You probably haven't heard of it +health: + category_name: Health From 7b996960c3717b98e240cbf85e1c037a0ca511c0 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 10:06:54 -0700 Subject: [PATCH 095/283] adds product fixtures --- test/fixtures/products.yml | 75 +++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 412026ac6a..036c5c7f58 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -1,15 +1,64 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - name: MyString - price: 1 - product_active: false - inventory: 1 - photo_url: MyString - -two: - name: MyString - price: 1 - product_active: false - inventory: 1 - photo_url: MyString +kombucha: + name: kombucha + price: 39 + description: Subway tile hexagon letterpress austin cloud bread helvetica. + product_active: true + inventory: 31 + merchant: + photo_url: https://picsum.photos/200/?random + +sage: + name: sage + price: 43 + description: Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual. + product_active: true + inventory: 15 + merchant: + photo_url: https://picsum.photos/200/?random + +hoodie: + name: hoodie + price: 77 + description: Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. + product_active: true + inventory: 5 + merchant: + photo_url: https://picsum.photos/200/?random + +man bun: + name: man bun + price: 25 + description: Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. + product_active: true + inventory: 19 + merchant: + photo_url: https://picsum.photos/200/?random + +chemex: + name: chemex + price: 39 + description: Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. + product_active: true + inventory: 43 + merchant: + photo_url: https://picsum.photos/200/?random + +salt lamp: + name: salt lamp + price: 56 + description: Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice. + product_active: true + inventory: 16 + merchant: + photo_url: https://picsum.photos/200/?random + +kale chips: + name: kale chips + price: 9 + description: Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. + product_active: true + inventory: 34 + merchant: + photo_url: https://picsum.photos/200/?random From fd07019934ea504857c873c96e4ee54b72d92a5d Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 10:08:43 -0700 Subject: [PATCH 096/283] fixtures for merchant and order_products --- test/fixtures/merchants.yml | 40 +++++++++++++++++++++++--------- test/fixtures/order_products.yml | 26 +++++++++++++++++---- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/test/fixtures/merchants.yml b/test/fixtures/merchants.yml index 19e7fb5362..dbb1284fce 100644 --- a/test/fixtures/merchants.yml +++ b/test/fixtures/merchants.yml @@ -1,13 +1,31 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - username: MyString - email: MyString - uid: 1 - provider: MyString - -two: - username: MyString - email: MyString - uid: 1 - provider: MyString +mads: + username: mads + email: mads@mads.com + uid: 12345678 + provider: github + +ange: + username: ange + email: ang@ange.com + uid: 23456789 + provider: github + +nora: + username: nora + email: nora@nora.com + uid: 34567890 + provider: github + +kat: + username: kat + email: kat@kat.com + uid: 98765432 + provider: github + +user: + username: user123 + email: user@test.com + uid: 87654321 + provider: github diff --git a/test/fixtures/order_products.yml b/test/fixtures/order_products.yml index dc6f57259e..fd4ec10a10 100644 --- a/test/fixtures/order_products.yml +++ b/test/fixtures/order_products.yml @@ -1,9 +1,25 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: +order_01: quantity: 1 - status: MyString + status: paid -two: - quantity: 1 - status: MyString +order_02: + quantity: 2 + status: shipped + +order_03: + quantity: 3 + status: cancelled + +order_04: + quantity: 4 + status: paid + +order_05: + quantity: 5 + status: shipped + +order_06: + quantity: 6 + status: cancelled From e523615da0b20e3cc78aa0b8154c312a63e23619 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 10:10:23 -0700 Subject: [PATCH 097/283] minor edit to product fixtures --- test/fixtures/products.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 036c5c7f58..da37daa789 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -13,7 +13,7 @@ sage: name: sage price: 43 description: Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual. - product_active: true + product_active: false inventory: 15 merchant: photo_url: https://picsum.photos/200/?random From c64f6f938dbb16f9edd79d7a3e989b469d50977f Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 10:12:53 -0700 Subject: [PATCH 098/283] adds merchant fixture references to products yml file --- test/fixtures/products.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index da37daa789..4b8a22e35e 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -6,7 +6,7 @@ kombucha: description: Subway tile hexagon letterpress austin cloud bread helvetica. product_active: true inventory: 31 - merchant: + merchant: mads photo_url: https://picsum.photos/200/?random sage: @@ -15,7 +15,7 @@ sage: description: Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual. product_active: false inventory: 15 - merchant: + merchant: ange photo_url: https://picsum.photos/200/?random hoodie: @@ -24,7 +24,7 @@ hoodie: description: Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. product_active: true inventory: 5 - merchant: + merchant: nora photo_url: https://picsum.photos/200/?random man bun: @@ -33,7 +33,7 @@ man bun: description: Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. product_active: true inventory: 19 - merchant: + merchant: nora photo_url: https://picsum.photos/200/?random chemex: @@ -42,7 +42,7 @@ chemex: description: Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. product_active: true inventory: 43 - merchant: + merchant: kat photo_url: https://picsum.photos/200/?random salt lamp: @@ -51,7 +51,7 @@ salt lamp: description: Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice. product_active: true inventory: 16 - merchant: + merchant: user photo_url: https://picsum.photos/200/?random kale chips: @@ -60,5 +60,5 @@ kale chips: description: Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. product_active: true inventory: 34 - merchant: + merchant: user photo_url: https://picsum.photos/200/?random From 0a4d8ca6fbf75cec7165c151d19b49464ec9d603 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 10:16:03 -0700 Subject: [PATCH 099/283] adds review fixtures --- test/fixtures/reviews.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml index 41c2fd15d3..ba67ce8849 100644 --- a/test/fixtures/reviews.yml +++ b/test/fixtures/reviews.yml @@ -1,9 +1,21 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - rating: 1 - description: MyString +review1: + rating: 3 + product: man bun + description: Shoreditch migas cray knausgaard 90's, iPhone. -two: +review2: rating: 1 - description: MyString + product: chemex + description: Artisan brooklyn plaid woke yuccie flannel. + +review3: + rating: 4 + product: kombucha + description: Raclette marfa semiotics, put a bird on it. + +review4: + rating: 5 + product: salt lamp + description: Artisan brooklyn plaid woke. From 8e83a01262e178b2f0e52a2e4edde87e29abe58a Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 10:22:29 -0700 Subject: [PATCH 100/283] order_product fixtures with order & product --- test/fixtures/orders.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index f9396c5ab4..e34341629c 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -39,3 +39,13 @@ order_four: billing_exp: 6/18 billing_cvv: 640 billing_zipcode: 67894 + +order_five: + status: pending + billing_email: + billing_address: + billing_name: + billing_num: + billing_exp: + billing_cvv: + billing_zipcode: From 5985864dc33ce04f23a2171bea51095f824e461f Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 10:26:48 -0700 Subject: [PATCH 101/283] order_products fixtures with order & product --- test/fixtures/order_products.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/fixtures/order_products.yml b/test/fixtures/order_products.yml index fd4ec10a10..36f2d69529 100644 --- a/test/fixtures/order_products.yml +++ b/test/fixtures/order_products.yml @@ -1,25 +1,31 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html order_01: + order: order_one + product: kombucha quantity: 1 - status: paid + status: order_02: + order: order_two + product: kombucha quantity: 2 status: shipped order_03: + order: order_three + product: kombucha quantity: 3 status: cancelled order_04: + order: order_four + product: kombucha quantity: 4 status: paid order_05: - quantity: 5 - status: shipped - -order_06: + order: order_one + product: kombucha quantity: 6 - status: cancelled + status: From b115aaa103b6448f9ddbe3e96463731366c0b688 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 11:09:45 -0700 Subject: [PATCH 102/283] adds validation and relation tests for Review model. all tests passing --- app/models/review.rb | 2 +- test/fixtures/products.yml | 2 +- test/fixtures/reviews.yml | 2 +- test/models/review_test.rb | 50 ++++++++++++++++++++++++++++++++++++-- test/test_helper.rb | 22 +++++++++++++++++ 5 files changed, 73 insertions(+), 5 deletions(-) diff --git a/app/models/review.rb b/app/models/review.rb index ee93045ad3..4860af388f 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -2,6 +2,6 @@ class Review < ApplicationRecord belongs_to :product validates :rating, presence: true - validates :rating, numericality: { only_integer: true, in: 1..5 } + validates_inclusion_of :rating, numericality: true, in: (1..5) end diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 4b8a22e35e..38a9d59aec 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -27,7 +27,7 @@ hoodie: merchant: nora photo_url: https://picsum.photos/200/?random -man bun: +manbun: name: man bun price: 25 description: Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml index ba67ce8849..8f46bd46c0 100644 --- a/test/fixtures/reviews.yml +++ b/test/fixtures/reviews.yml @@ -2,7 +2,7 @@ review1: rating: 3 - product: man bun + product: manbun description: Shoreditch migas cray knausgaard 90's, iPhone. review2: diff --git a/test/models/review_test.rb b/test/models/review_test.rb index ce8378a033..04a4e184a7 100644 --- a/test/models/review_test.rb +++ b/test/models/review_test.rb @@ -3,7 +3,53 @@ describe Review do let(:review) { Review.new } - it "must be valid" do - value(review).must_be :valid? + describe "validations" do + it "must be valid" do + review1 = reviews(:review1) + review1.rating.class.must_equal Integer + review1.valid?.must_equal true + end + + it "must be invalid if rating is blank" do + review2 = reviews(:review2) + review2.rating = nil + review2.valid?.must_equal false + end + + it "must be invalid if rating is a string" do + review3 = reviews(:review3) + review3.rating = 'mystring' + review3.valid?.must_equal false + end + + it "must be invalid if rating is less than 1" do + review4 = reviews(:review4) + review4.rating = 0 + review4.valid?.must_equal false + end + + it "must be invalid if rating is greater than 5" do + review1 = reviews(:review1) + review1.rating = 6 + review1.valid?.must_equal false + end + + it "must be valid if description is nil" do + review2 = reviews(:review2) + review2.description = nil + review2.valid?.must_equal true + end + end + + describe 'relations' do + + it 'must have a Product' do + review1 = reviews(:review1) + review1.must_respond_to :product + review1.product.must_be_kind_of Product + review1.product.name.must_equal "man bun" + review1.product.must_equal products(:manbun) + end + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 10594a3248..6428132cec 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -23,4 +23,26 @@ class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... + def setup + # Once you have enabled test mode, all requests + # to OmniAuth will be short circuited to use the mock authentication hash. + # A request to /auth/provider will redirect immediately to /auth/provider/callback. + OmniAuth.config.test_mode = true + end + + def mock_auth_hash(merchant) + return { + provider: merchant.provider, + uid: merchant.uid, + info: { + email: merchant.email, + nickname: merchant.username + } + } + end + + def login(merchant) + OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(merchant)) + get auth_callback_path(:github) + end end From 0512354192f084b6c69ad47c3a16624640a99aa7 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 11:33:42 -0700 Subject: [PATCH 103/283] Write validations tests for order_test --- test/fixtures/orders.yml | 14 +++++++------- test/models/order_test.rb | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index e34341629c..d596a30d17 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -2,13 +2,13 @@ order_one: status: pending - billing_email: test@test.com - billing_address: 123 Street - billing_name: Ada Lovelace - billing_num: 123456789123 - billing_exp: 12/18 - billing_cvv: 123 - billing_zipcode: 12345 + billing_email: + billing_address: + billing_name: + billing_num: + billing_exp: + billing_cvv: + billing_zipcode: order_two: status: paid diff --git a/test/models/order_test.rb b/test/models/order_test.rb index df80f10fb6..aceea1956b 100644 --- a/test/models/order_test.rb +++ b/test/models/order_test.rb @@ -3,7 +3,36 @@ describe Order do let(:order) { Order.new } - it "must be valid" do - value(order).must_be :valid? + describe "validations" do + it "must be valid" do + order_one = orders(:order_one) + order_one.valid?.must_equal true + end + + it "must be valid when billing info is blank and status is pending" do + order_five = orders(:order_five) + order_five.valid?.must_equal true + end + + it "must be valid when billing info is filled and status is paid or complete" do + order_four = orders(:order_four) + order_four.valid?.must_equal true + end + + it "must be invalid when billing info is blank and status is paid or complete" do + order_five = orders(:order_five) + order_five.status = "paid" + order_five.valid?.must_equal false + end + + it "must be invalid when billing info is filled and status is pending" do + order_four = orders(:order_four) + order_four.status = "pending" + order_four.valid?.must_equal false + end + + end + + end From f9a5b92417ebad3922538de6220828b51612c10d Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 12:55:38 -0700 Subject: [PATCH 104/283] adds path to cart, adds path to all of merchants products from a product page --- app/views/layouts/application.html.erb | 3 +-- app/views/products/show.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1f2343663b..82db8da824 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,6 @@
    • <%= link_to "Account", account_page_path(@current_merchant.id) %>
    • <%= link_to "Log Out", logout_path, method: :delete %>
    • -
    • <%= link_to "Cart: Needs Path", root_path %>
    • <% else %>
    • <%= "Welcome Guest" %>
    • @@ -31,6 +30,7 @@

    • <%= link_to "Log In", github_login_path %>
    • <%= link_to "Become a Merchant", github_login_path %>
    • + <% end %>
    • <% if @current_cart.nil? %> Cart Empty @@ -39,7 +39,6 @@ <%= link_to "Cart(#{count})", order_path(@current_cart.id) %> <% end %>
    • - <% end %>
    diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index d615882890..1fd6c38e5a 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -3,7 +3,7 @@

    Product: <%= @product.name %>

    product-image -

    Merchant: <%= link_to @product.merchant.username, merchant_path(@product.merchant) %>

    +

    Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

    Description: <%=@product.description %>

    Cost: $<%= format_price(@product.price) %>

    <% if @product.inventory == 0 %> @@ -14,7 +14,7 @@

    Categories: <% @product.categories.each do |c| %> <%= link_to c.category_name, category_products_path(c.id) %> <% end %>

    Quantity:

    - <%= form_for :order_products, url: order_product_path, method: :post do |f| %> + <%= form_for :order_products, url: add_to_order_path(@product.id), method: :get do |f| %> <%= f.hidden_field :product_id, value: @product.id %> <%= f.select(:inventory, (1..@product.inventory)) %> From f1b8d2945f409592ca294ce986fb488b4bcb4ed4 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 13:34:38 -0700 Subject: [PATCH 105/283] adds show page for Order/current_cart --- app/views/orders/show.html.erb | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index 22eb495f6f..84a8e3411e 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -1,2 +1,27 @@ -

    Orders#show

    -

    Find me in app/views/orders/show.html.erb

    +

    Your Cart

    + + + + + + + + + + + + + + + <% @current_cart.order_products.each do | order_product | %> + + + + + + + + + <% end %> + +
    Product NameUnit PriceQuantityEdit QuantitySubtotalOptions
    <%= order_product.product.name %><%= order_product.product.price %><%= order_product.quantity %><%= link_to "ADD QUANTITY DROPDOWN"%><%= "$#{format_price(order_product.calculate_cost)}" %><%= link_to 'DELETE ORDERPRODUCT' %>
    From 8b012ef92c881bee372d526450c02c06696d34e1 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 13:35:20 -0700 Subject: [PATCH 106/283] refactoring products#add_to_cart --- app/controllers/products_controller.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 62541f05be..6585805089 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -27,6 +27,10 @@ def index def show @product = Product.find_by(id: params[:id]) + if @product.nil? + flash[:alert] = "That product does not exist" + redirect_to products_path + end end def new @@ -77,23 +81,29 @@ def add_to_order redirect_to products_path elsif product.inventory < 1 flash[:alert] = "That product is out of stock." - redirect_to products_path + render :show else if @current_cart - @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: 1, status: 'pending') + @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: params[:order_products][:inventory], status: 'pending') if @order_product.save + product.inventory -= params[:order_products][:inventory].to_i + product.save flash[:success] = "Successfully added product to cart" - redirect_to order_path(@current_cart.id) + redirect_to product_path(product.id) + # redirect_to order_path(@current_cart.id) else flash[:alert] = "Failed to add to cart" render :show end else session[:order_id] = Order.create.id - @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: 1, status: 'pending') + @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: params[:order_products][:inventory], status: 'pending') if @order_product.save + product.inventory -= params[:order_products][:inventory].to_i + product.save flash[:success] = "Successfully added product to cart" - redirect_to order_path(session[:order_id]) + redirect_to product_path(product.id) + # redirect_to order_path(session[:order_id]) else flash[:alert] = "Failed to add to cart" render :show From 1841e4f4780bca6630d7767095fa99a6786fc6f7 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:44:51 -0700 Subject: [PATCH 107/283] edits current_cart method to create new cart for each new session --- app/controllers/application_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 256ed2ef81..a3efa7cc80 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,7 +9,12 @@ def current_merchant end def current_cart - @current_cart ||= Order.find(session[:order_id]) if session[:order_id] + if session[:order_id] + @current_cart = Order.find(session[:order_id]) + else + @current_cart = Order.create + session[:order_id] = @current_cart.id + end end def render_404 From 7ef825fcaf5b2115b32b981d24fe2829d3c95de5 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:45:41 -0700 Subject: [PATCH 108/283] adds simplecov to Gemfile and coverage directory to gitignore --- .gitignore | 1 + Gemfile | 1 + Gemfile.lock | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index fd7861badf..b36cdf4968 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ .byebug_history .env +coverage diff --git a/Gemfile b/Gemfile index 254c66e458..e00c393af7 100644 --- a/Gemfile +++ b/Gemfile @@ -73,4 +73,5 @@ end group :test do gem 'minitest-rails' gem 'minitest-reporters' + gem 'simplecov', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 436e28411f..8330f49f9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM concurrent-ruby (1.0.5) crass (1.0.4) debug_inspector (0.0.3) + docile (1.1.5) dotenv (2.2.2) dotenv-rails (2.2.2) dotenv (= 2.2.2) @@ -96,6 +97,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + json (2.1.0) jwt (1.5.6) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -191,6 +193,11 @@ GEM selenium-webdriver (3.11.0) childprocess (~> 0.5) rubyzip (~> 1.2) + simplecov (0.15.1) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -253,6 +260,7 @@ DEPENDENCIES rails (~> 5.1.6) sass-rails (~> 5.0) selenium-webdriver + simplecov spring spring-watcher-listen (~> 2.0.0) turbolinks (~> 5) From 1030efe5a968beb75432341eb18333554127e2fa Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:46:27 -0700 Subject: [PATCH 109/283] creates new empty cart after payment is submitted --- app/controllers/orders_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 21201f89bc..cb5d57c70b 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -18,7 +18,7 @@ def paid #submit after checkout end @current_cart.update_attributes(status: "paid") flash[:success] = "Order received! Thank you for your purchase." - session[:order_id] = nil + session[:order_id] = Order.create.id elsif @current_cart.errors.any? flash.now[:error] = @current_cart.errors render :checkout From ba291d9a9364aa959c37ac935c86532f8a1e79e3 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:47:21 -0700 Subject: [PATCH 110/283] edits cart display to show num of items in session cart --- app/views/layouts/application.html.erb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 82db8da824..0c3ea81c75 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -32,12 +32,8 @@
  • <%= link_to "Become a Merchant", github_login_path %>
  • <% end %>
  • - <% if @current_cart.nil? %> - Cart Empty - <% else %> - <% count = @current_cart.order_products.count %> - <%= link_to "Cart(#{count})", order_path(@current_cart.id) %> - <% end %> + <% count = Order.find_by(id: session[:order_id]).order_products.count %> + <%= link_to "Cart(#{count})", order_path(@current_cart.id) %>
  • From 5f425d57093379b55ac0c802db5f07169fee4ae4 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:47:46 -0700 Subject: [PATCH 111/283] adds checkout link to order show page --- app/views/orders/show.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index 84a8e3411e..5e2ebdac26 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -25,3 +25,5 @@ <% end %> + +<%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> From 9514ef707e272a90758da9f380335c1947dbc991 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 14:48:20 -0700 Subject: [PATCH 112/283] adds simplecov to test_helper --- test/test_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 6428132cec..b2a565c6c7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start 'rails' + ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment", __FILE__) require "rails/test_help" From b953d3b01a4bd62449f4cb959c4af3686ab1fa58 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Mon, 23 Apr 2018 14:50:37 -0700 Subject: [PATCH 113/283] adjusted routes for custom merchant paths to not have a merchant id in the path --- app/views/layouts/application.html.erb | 2 +- config/routes.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 82db8da824..f3f1eab9ce 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,7 +21,7 @@
  • <%= link_to "Hipsty", root_path %>

  • -
  • <%= link_to "Account", account_page_path(@current_merchant.id) %>
  • +
  • <%= link_to "Account", account_page_path %>
  • <%= link_to "Log Out", logout_path, method: :delete %>
  • <% else %>
  • <%= "Welcome Guest" %>
  • diff --git a/config/routes.rb b/config/routes.rb index 87971f0896..d32998f11f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,11 +10,11 @@ resources :products, only: [:index] end - get '/merchants/:id/account_page', to: 'merchants#account_page', as: 'account_page' + get '/merchant/account_page', to: 'merchants#account_page', as: 'account_page' - get 'merchants/:id/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' + get '/merchant/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' - get 'merchants/:id/products_manager', to: 'merchants#products_manager', as: 'products_manager' + get '/merchant/products_manager', to: 'merchants#products_manager', as: 'products_manager' resources :products, only: [:index, :show] @@ -26,8 +26,8 @@ resources :orders, only: [:show, :create, :update, :destroy] - get 'orders/:id/checkout', to: 'orders#checkout', as: 'checkout' - patch 'orders/:id/paid', to: 'orders#paid', as: 'order_paid' + get '/orders/:id/checkout', to: 'orders#checkout', as: 'checkout' + patch '/orders/:id/paid', to: 'orders#paid', as: 'order_paid' get '/auth/:provider/callback', to: 'sessions#login', as: 'auth_callback' get '/auth/github', as: 'github_login' @@ -35,11 +35,11 @@ resources :order_products, only: [:edit, :update] - patch 'merchant/:merchant_id/products/:id/active', to: 'products#active', as: 'active' + patch '/merchant/:merchant_id/products/:id/active', to: 'products#active', as: 'active' - patch 'merchant/:merchant_id/products/:id/retired', to: 'products#retire', as: 'retire' + patch '/merchant/:merchant_id/products/:id/retired', to: 'products#retire', as: 'retire' - patch 'merchant/:merchant_id/products/:id/status', to: 'products#product_status', as: 'product_status' + patch '/merchant/:merchant_id/products/:id/status', to: 'products#product_status', as: 'product_status' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end From 032f9949d5665db8dcada87c93815351fd1b107c Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 15:44:39 -0700 Subject: [PATCH 114/283] adds order_products model tests --- app/models/order_product.rb | 5 +++ test/fixtures/order_products.yml | 4 +- test/models/order_product_test.rb | 73 +++++++++++++++++++++++++++++-- 3 files changed, 77 insertions(+), 5 deletions(-) diff --git a/app/models/order_product.rb b/app/models/order_product.rb index 0d6d623751..4896aa4552 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,10 +1,15 @@ class OrderProduct < ApplicationRecord + STATUS = ["pending", "paid", "cancelled", "shipped"] belongs_to :order belongs_to :product validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } + validates :status, presence: true, inclusion: {in: STATUS} + + + def calculate_cost self.product.price * self.quantity end diff --git a/test/fixtures/order_products.yml b/test/fixtures/order_products.yml index 36f2d69529..a5d6ad2e11 100644 --- a/test/fixtures/order_products.yml +++ b/test/fixtures/order_products.yml @@ -4,7 +4,7 @@ order_01: order: order_one product: kombucha quantity: 1 - status: + status: pending order_02: order: order_two @@ -28,4 +28,4 @@ order_05: order: order_one product: kombucha quantity: 6 - status: + status: pending diff --git a/test/models/order_product_test.rb b/test/models/order_product_test.rb index 47c6ee2a98..9fd38dc0d3 100644 --- a/test/models/order_product_test.rb +++ b/test/models/order_product_test.rb @@ -1,9 +1,76 @@ require "test_helper" describe OrderProduct do - let(:order_product) { OrderProduct.new } + let(:order_product) { order_products(:order_01) } - it "must be valid" do - value(order_product).must_be :valid? + describe "validations" do + it "must be valid" do + order_product.must_be :valid? + order_product.quantity.must_be_kind_of Integer + end + + it "must not be valid without a quantity" do + order_product.quantity = nil + order_product.valid?.must_equal false + end + + it "must not be valid with a non-integer quantity" do + order_product.quantity = "foo" + order_product.valid?.must_equal false + end + + it "will be invalid if quantity is less than 1" do + order_product.quantity = 0 + order_product.valid?.must_equal false + end + + it "must not be valid if it doesn't have a status" do + order_product.status = nil + order_product.valid?.must_equal false + + end + + it "must not be valid if it doesn't have a status of pending, paid, or complete" do + order_product.status = "someotherstatus" + order_product.valid?.must_equal false + end end + + describe "relationships" do + + it 'must belong to a product' do + order_product.must_respond_to :product + order_product.product.must_be_kind_of Product + order_product.product.name.must_equal "kombucha" + order_product.product.must_equal products(:kombucha) + end + + it 'must belong to a order' do + order_product.must_respond_to :order + order_product.order.must_be_kind_of Order + order_product.order.id.must_equal orders(:order_one).id + order_product.order.must_equal orders(:order_one) + end + + end + + describe "custom methods" do + + describe "calculate_cost method" do + let(:first_order) { order_products(:order_02) } + let(:second_order) { order_products(:order_03) } + + it "returns an integer" do + first_order.calculate_cost.must_be_kind_of Integer + end + + it "must calculate cost correctly" do + first_order.calculate_cost.must_equal 78 + second_order.calculate_cost.must_equal 117 + end + + end + + end + end From a175fddd16b96cf1402fe0603190e735c9da99a4 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 16:37:03 -0700 Subject: [PATCH 115/283] write validations for order model --- app/controllers/orders_controller.rb | 12 +++++++++--- app/models/order.rb | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index cb5d57c70b..18b22bebd8 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -16,9 +16,14 @@ def paid #submit after checkout @current_cart.order_products.each do |order_product| order_product.update_attributes(status: "paid") end - @current_cart.update_attributes(status: "paid") - flash[:success] = "Order received! Thank you for your purchase." - session[:order_id] = Order.create.id + @current_cart.status = "paid" + if @current_cart.save + flash[:success] = "Order received! Thank you for your purchase." + session[:order_id] = Order.create.id + else + flash.now[:error] = @current_cart.errors + render :checkout + end elsif @current_cart.errors.any? flash.now[:error] = @current_cart.errors render :checkout @@ -35,6 +40,7 @@ def destroy #this clears the cart before order has gone into paid status def billing_params params.require(:order).permit( + :billing_email, :billing_address, :billing_name, :billing_num, diff --git a/app/models/order.rb b/app/models/order.rb index 732f18c63e..f623e741ad 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,3 +1,19 @@ class Order < ApplicationRecord has_many :order_products + + validates :billing_email, presence: true, if: :paid? + validates :billing_address, presence: true, if: :paid? + validates :billing_name, presence: true, if: :paid? + validates :billing_num, presence: true, length: { in: 16..16 }, if: :paid? + validates :billing_exp, presence: true, if: :paid? + validates :billing_cvv, presence: true, format: { with: /^[0-9]{3,4}$/ + }, if: :paid? + validates :billing_zipcode, presence: true, length: { in: 5..5 }, if: :paid? + + def paid? + self.status == "paid" + end + + # validates_inclusion_of :rating, in: (1..5), allow_nil: true + end From 5e87f73f406ee5d22b52a21b9e10540549fc61c5 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 16:40:43 -0700 Subject: [PATCH 116/283] categories model tests for validations only --- test/models/category_test.rb | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/test/models/category_test.rb b/test/models/category_test.rb index 781320ad8e..a07c201da1 100644 --- a/test/models/category_test.rb +++ b/test/models/category_test.rb @@ -1,9 +1,35 @@ require "test_helper" describe Category do - let(:category) { Category.new } + let(:category) { categories(:clothes) } + + describe "validations" do + + it "must be valid" do + category.must_be :valid? + end + + it "must be invalid without a category_name" do + category.category_name = nil + category.valid?.must_equal false + end + + it "must be invalid if it has a duplicate name" do + category2 = categories(:extra) + category2.category_name = "Clothing" + category2.valid?.must_equal false + end + + end + + describe "relationships" do + + it "has and belongs to products" do + category.must_respond_to :product + + end - it "must be valid" do - value(category).must_be :valid? end + + end From 665656958ae0eafdd58b320fb38087b053afbb5e Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 16:45:47 -0700 Subject: [PATCH 117/283] remove regex from validations for order model --- app/models/order.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index f623e741ad..14fcfc86f8 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -6,8 +6,7 @@ class Order < ApplicationRecord validates :billing_name, presence: true, if: :paid? validates :billing_num, presence: true, length: { in: 16..16 }, if: :paid? validates :billing_exp, presence: true, if: :paid? - validates :billing_cvv, presence: true, format: { with: /^[0-9]{3,4}$/ - }, if: :paid? + validates :billing_cvv, presence: true, if: :paid? validates :billing_zipcode, presence: true, length: { in: 5..5 }, if: :paid? def paid? From e01c26effa4c42c24ea261970c5fa7dceff2b75a Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Mon, 23 Apr 2018 17:03:02 -0700 Subject: [PATCH 118/283] edit tests for order --- test/fixtures/orders.yml | 18 ++++-------------- test/models/order_test.rb | 13 ++----------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index d596a30d17..6497442b74 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -1,7 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html order_one: - status: pending + status: billing_email: billing_address: billing_name: @@ -10,22 +10,12 @@ order_one: billing_cvv: billing_zipcode: -order_two: - status: paid - billing_email: alfredo@ortiz.biz - billing_address: 9729 Ernser Landing - billing_name: Emma Ghost - billing_num: 1234123412341234 - billing_exp: 10/21/18 - billing_cvv: 224 - billing_zipcode: 70842 - order_three: status: complete billing_email: coy@purdymckenzie.co billing_address: 48144 Hackett Wells billing_name: Rowena Ravenclaw - billing_num: 987654321098 + billing_num: 1234567887654321 billing_exp: 6/18 billing_cvv: 333 billing_zipcode: 95176 @@ -35,13 +25,13 @@ order_four: billing_email: jaqueline_cole@littel.co billing_address: 5414 Swift Ramp billing_name: Cuthbert Binns - billing_num: 567890123456 + billing_num: 1234567887654321 billing_exp: 6/18 billing_cvv: 640 billing_zipcode: 67894 order_five: - status: pending + status: billing_email: billing_address: billing_name: diff --git a/test/models/order_test.rb b/test/models/order_test.rb index aceea1956b..f727b15886 100644 --- a/test/models/order_test.rb +++ b/test/models/order_test.rb @@ -1,4 +1,5 @@ require "test_helper" +require "pry" describe Order do let(:order) { Order.new } @@ -9,7 +10,7 @@ order_one.valid?.must_equal true end - it "must be valid when billing info is blank and status is pending" do + it "must be valid when billing info is blank and status is nil" do order_five = orders(:order_five) order_five.valid?.must_equal true end @@ -24,15 +25,5 @@ order_five.status = "paid" order_five.valid?.must_equal false end - - it "must be invalid when billing info is filled and status is pending" do - order_four = orders(:order_four) - order_four.status = "pending" - order_four.valid?.must_equal false - end - - end - - end From 753af122201d6bcee602799a7d3fbb71560e9e0a Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 17:42:21 -0700 Subject: [PATCH 119/283] deletes homepages controller test file. adds migration to categories_products table. edits product fixtures. adds tests to product_test.rb --- ...null_constraints_on_categories_products.rb | 6 ++ test/controllers/homepages_controller_test.rb | 9 --- test/fixtures/categories.yml | 2 +- test/fixtures/products.yml | 13 +++- test/models/product_test.rb | 77 ++++++++++++++++++- 5 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20180424001206_change_null_constraints_on_categories_products.rb delete mode 100644 test/controllers/homepages_controller_test.rb diff --git a/db/migrate/20180424001206_change_null_constraints_on_categories_products.rb b/db/migrate/20180424001206_change_null_constraints_on_categories_products.rb new file mode 100644 index 0000000000..896ec0b42d --- /dev/null +++ b/db/migrate/20180424001206_change_null_constraints_on_categories_products.rb @@ -0,0 +1,6 @@ +class ChangeNullConstraintsOnCategoriesProducts < ActiveRecord::Migration[5.1] + def change + change_column :categories_products, :created_at, :datetime, :null => true + change_column :categories_products, :updated_at, :datetime, :null => true + end +end diff --git a/test/controllers/homepages_controller_test.rb b/test/controllers/homepages_controller_test.rb deleted file mode 100644 index 7395af3dec..0000000000 --- a/test/controllers/homepages_controller_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "test_helper" - -describe HomepagesController do - it "should get index" do - get homepages_index_url - value(response).must_be :success? - end - -end diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml index 1b964b747e..59bc70cbc9 100644 --- a/test/fixtures/categories.yml +++ b/test/fixtures/categories.yml @@ -7,7 +7,7 @@ extra: home: category_name: Home food: - category_name: food + category_name: Food beverage: category_name: Beverage kitchen: diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 38a9d59aec..2d9afc92e1 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -1,6 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html kombucha: + id: 1 name: kombucha price: 39 description: Subway tile hexagon letterpress austin cloud bread helvetica. @@ -8,8 +9,10 @@ kombucha: inventory: 31 merchant: mads photo_url: https://picsum.photos/200/?random + categories: food, beverage sage: + id: 2 name: sage price: 43 description: Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual. @@ -17,8 +20,10 @@ sage: inventory: 15 merchant: ange photo_url: https://picsum.photos/200/?random + reviews: review2, review3 hoodie: + id: 3 name: hoodie price: 77 description: Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. @@ -28,6 +33,7 @@ hoodie: photo_url: https://picsum.photos/200/?random manbun: + id: 4 name: man bun price: 25 description: Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. @@ -37,6 +43,7 @@ manbun: photo_url: https://picsum.photos/200/?random chemex: + id: 5 name: chemex price: 39 description: Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. @@ -45,7 +52,8 @@ chemex: merchant: kat photo_url: https://picsum.photos/200/?random -salt lamp: +salt_lamp: + id: 6 name: salt lamp price: 56 description: Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice. @@ -54,7 +62,8 @@ salt lamp: merchant: user photo_url: https://picsum.photos/200/?random -kale chips: +kale_chips: + id: 7 name: kale chips price: 9 description: Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. diff --git a/test/models/product_test.rb b/test/models/product_test.rb index a618b0a156..4fcfa7c906 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -1,9 +1,82 @@ require "test_helper" +require 'pry' describe Product do let(:product) { Product.new } - it "must be valid" do - value(product).must_be :valid? + describe "validations" do + it "must be valid" do + kombucha = products(:kombucha) + kombucha.valid?.must_equal true + kombucha.inventory.class.must_equal Integer + end + + it "requires a product name" do + sage = products(:sage) + sage.name = nil + sage.valid?.must_equal false + end + + it "requires a unique product name" do + sage = products(:sage) + sage2 = Product.new(name: "sage", price: 9) + sage2.save + sage2.valid?.must_equal false + sage2.errors.messages.must_include :name + end + + it "requires a price" do + hoodie = products(:hoodie) + hoodie.price = nil + hoodie.valid?.must_equal false + end + + it "must be invalid if price is 0 or negative number" do + kale_chips = products(:kale_chips) + kale_chips.price = 0 + chemex = products(:chemex) + chemex.price = -43 + kale_chips.valid?.must_equal false + chemex.valid?.must_equal false + end + + it "must be invalid if price is 1000000 or greater" do + salt_lamp = products(:salt_lamp) + salt_lamp.price = 1000000 + salt_lamp.valid?.must_equal false + end + + it "requires inventory to be an integer greater than or equal to zero" do + chemex = products(:chemex) + chemex.inventory = -7 + chemex.valid?.must_equal false + end + end + + describe "relations" do + it "must have a merchant" do + kombucha = products(:kombucha) + kombucha.must_respond_to :merchant + kombucha.merchant.must_be_kind_of Merchant + kombucha.merchant.username.must_equal "mads" + kombucha.merchant.must_equal merchants(:mads) + end + + it "has a list of categories" do + kombucha = products(:kombucha) + food = categories(:food) + beverage = categories(:beverage) + kombucha.categories.must_include food + kombucha.categories.must_include beverage + kombucha.categories.length.must_equal 2 + end + + it "has a list of reviews" do + + end + + it "has a list of order_products" do + + end end end From 11b8f2739056e907c19b9ab4bf4e08e981603aa6 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 17:45:08 -0700 Subject: [PATCH 120/283] updated schema file --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 9e1d6d4e8e..d883ed417b 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: 20180421044914) do +ActiveRecord::Schema.define(version: 20180424001206) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,8 +24,8 @@ create_table "categories_products", force: :cascade do |t| t.bigint "product_id" t.bigint "category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.index ["category_id"], name: "index_categories_products_on_category_id" t.index ["product_id"], name: "index_categories_products_on_product_id" end From b21e20a3a5710d60889019c2031c9a5b88d955f7 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Mon, 23 Apr 2018 17:46:33 -0700 Subject: [PATCH 121/283] schema all good --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 9e1d6d4e8e..d883ed417b 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: 20180421044914) do +ActiveRecord::Schema.define(version: 20180424001206) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,8 +24,8 @@ create_table "categories_products", force: :cascade do |t| t.bigint "product_id" t.bigint "category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.index ["category_id"], name: "index_categories_products_on_category_id" t.index ["product_id"], name: "index_categories_products_on_product_id" end From f6fcfb595fa8d64e1a7dc3391cd0782e314ff447 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 17:49:47 -0700 Subject: [PATCH 122/283] these f-ing dropdown menus, man --- app/views/layouts/application.html.erb | 46 ++++++++++++-------------- db/schema.rb | 6 ++-- test/models/category_test.rb | 2 +- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 52e0f8d3a0..f9f983a6a0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -39,34 +39,30 @@ - -
      <% flash.each do | name, message | %> diff --git a/db/schema.rb b/db/schema.rb index 9e1d6d4e8e..d883ed417b 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: 20180421044914) do +ActiveRecord::Schema.define(version: 20180424001206) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,8 +24,8 @@ create_table "categories_products", force: :cascade do |t| t.bigint "product_id" t.bigint "category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.index ["category_id"], name: "index_categories_products_on_category_id" t.index ["product_id"], name: "index_categories_products_on_product_id" end diff --git a/test/models/category_test.rb b/test/models/category_test.rb index a07c201da1..6f4c00bce1 100644 --- a/test/models/category_test.rb +++ b/test/models/category_test.rb @@ -26,7 +26,7 @@ it "has and belongs to products" do category.must_respond_to :product - + skip end end From 762a9364a83d0d9e72a881b9f7c6c84e78a79ee3 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 18:22:53 -0700 Subject: [PATCH 123/283] adds/finished category model tests --- test/fixtures/categories.yml | 4 ++++ test/fixtures/products.yml | 1 - test/models/category_test.rb | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml index 59bc70cbc9..9dd1bc2d54 100644 --- a/test/fixtures/categories.yml +++ b/test/fixtures/categories.yml @@ -2,14 +2,18 @@ clothes: category_name: Clothing + products: extra: category_name: So Extra + products: sage home: category_name: Home food: category_name: Food + products: kombucha, sage beverage: category_name: Beverage + products: kombucha kitchen: category_name: Kitchen spiritual: diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 2d9afc92e1..21325c8ba2 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -20,7 +20,6 @@ sage: inventory: 15 merchant: ange photo_url: https://picsum.photos/200/?random - reviews: review2, review3 hoodie: id: 3 diff --git a/test/models/category_test.rb b/test/models/category_test.rb index 6f4c00bce1..dd29eaaa0e 100644 --- a/test/models/category_test.rb +++ b/test/models/category_test.rb @@ -25,8 +25,16 @@ describe "relationships" do it "has and belongs to products" do - category.must_respond_to :product - skip + category1 = categories(:food) + + product = Product.find_by(name: "kombucha") + category1.must_respond_to :products + category1.products.must_include product + category.products.length.must_equal 2 + end + + it "can have no products" do + category.valid?.must_equal true end end From efcbde90d8cab71bd8dff765267fd4c14abc62b4 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 18:26:03 -0700 Subject: [PATCH 124/283] adds calculate_total method to order model --- app/models/order.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/order.rb b/app/models/order.rb index 14fcfc86f8..3288a8af6f 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -15,4 +15,12 @@ def paid? # validates_inclusion_of :rating, in: (1..5), allow_nil: true + def calculate_total + total = 0 + self.order_products.each do |order_product| + total += order_product.calculate_cost + end + total + end + end From ccf7f57243bf3da6f0622dea0967437f1d05d942 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Mon, 23 Apr 2018 18:26:27 -0700 Subject: [PATCH 125/283] edits product fixture --- test/fixtures/products.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 2d9afc92e1..21325c8ba2 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -20,7 +20,6 @@ sage: inventory: 15 merchant: ange photo_url: https://picsum.photos/200/?random - reviews: review2, review3 hoodie: id: 3 From 4b7195abdf4b2598c0d8f6c3c7ed8c93fb97f48c Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Mon, 23 Apr 2018 18:59:43 -0700 Subject: [PATCH 126/283] THE F-ING DROPDOWN MENUS WORK NOW THANKS TO KATIE --- Gemfile | 1 + Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 4 ++-- app/views/layouts/application.html.erb | 12 ++++++------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index e00c393af7..8dc482472a 100644 --- a/Gemfile +++ b/Gemfile @@ -68,6 +68,7 @@ end group :development do gem 'better_errors' gem 'binding_of_caller' + gem 'rails_layout' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 8330f49f9f..c3de77ae03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,6 +170,7 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) + rails_layout (1.0.42) railties (5.1.6) actionpack (= 5.1.6) activesupport (= 5.1.6) @@ -258,6 +259,7 @@ DEPENDENCIES pry-rails puma (~> 3.7) rails (~> 5.1.6) + rails_layout sass-rails (~> 5.0) selenium-webdriver simplecov diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f8d766545e..261ce1b62e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,9 +10,9 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. //= require jquery - -// //= require rails-ujs //= require foundation //= require_tree . + +$(function(){ $(document).foundation(); }); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f9f983a6a0..5d0e57aa04 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,19 +40,19 @@ diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb new file mode 100644 index 0000000000..60c2e9c366 --- /dev/null +++ b/app/views/orders/index.html.erb @@ -0,0 +1,43 @@ +

      Your Cart

      + +<% if @current_cart.order_products.empty? %> +

      Your Cart is Empty :P

      +<% else %> + + + + + + + + + + + + + + <% @current_cart.order_products.each do | order_product | %> + <% product = order_product.product %> + + + + + + + + + <% end %> + +
      Product NameUnit PriceQuantityEdit QuantitySubtotalOptions
      <%= link_to product.name, product_path(product.id) %><%= product.price %><%= order_product.quantity %> + <%= form_for :order_product, url: order_path(@current_cart.id), method: :patch do |f| %> + <%= f.hidden_field :order_product_id, value: order_product.id %> + <%= f.select :quantity, (1..(order_product.product.inventory + order_product.quantity)), selected: order_product.quantity %> + + <%= f.submit "Update Quantity", class: "button" %> + <% end %> + <%= "$#{format_price(order_product.calculate_cost)}" %> + <%= link_to "Remove from Cart", order_product_path(order_product.id), method: :delete, class: "button", data: { confirm: "Are you sure you want to remove this product?"} %> +
      + <%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> + <%= link_to "Empty Cart", order_path(@current_cart.id), method: :delete, class: "button", data: { confirm: "Are you sure you want to empty your cart?"} %> +<% end %> diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index 60c2e9c366..e69de29bb2 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -1,43 +0,0 @@ -

      Your Cart

      - -<% if @current_cart.order_products.empty? %> -

      Your Cart is Empty :P

      -<% else %> - - - - - - - - - - - - - - <% @current_cart.order_products.each do | order_product | %> - <% product = order_product.product %> - - - - - - - - - <% end %> - -
      Product NameUnit PriceQuantityEdit QuantitySubtotalOptions
      <%= link_to product.name, product_path(product.id) %><%= product.price %><%= order_product.quantity %> - <%= form_for :order_product, url: order_path(@current_cart.id), method: :patch do |f| %> - <%= f.hidden_field :order_product_id, value: order_product.id %> - <%= f.select :quantity, (1..(order_product.product.inventory + order_product.quantity)), selected: order_product.quantity %> - - <%= f.submit "Update Quantity", class: "button" %> - <% end %> - <%= "$#{format_price(order_product.calculate_cost)}" %> - <%= link_to "Remove from Cart", order_product_path(order_product.id), method: :delete, class: "button", data: { confirm: "Are you sure you want to remove this product?"} %> -
      - <%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> - <%= link_to "Empty Cart", order_path(@current_cart.id), method: :delete, class: "button", data: { confirm: "Are you sure you want to empty your cart?"} %> -<% end %> diff --git a/config/routes.rb b/config/routes.rb index 8d3b7a1970..3b8e011344 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,7 @@ resources :orders, only: [:show, :create, :update, :destroy] + get '/cart', to: 'orders#index', as: 'cart' get '/orders/:id/checkout', to: 'orders#checkout', as: 'checkout' patch '/orders/:id/paid', to: 'orders#paid', as: 'order_paid' From a4115793359706df5e8f15b3d10bd70ee53b492e Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 15:02:25 -0700 Subject: [PATCH 146/283] edits render404 method in app controller --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a3efa7cc80..ddecce7a7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -18,8 +18,8 @@ def current_cart end def render_404 - # DPR: this will actually render a 404 page in production - raise ActionController::RoutingError.new('Not Found') + render file: "/public/404.html", status: 404 + # raise ActionController::RoutingError.new('Not Found') end end From ca77bbc1a42e547e1fded3e2ad2428b94352bbff Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 15:02:58 -0700 Subject: [PATCH 147/283] minor refactoring on product controller --- app/controllers/products_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index fc169e03c5..70990bf09b 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -6,7 +6,6 @@ def root end def index - @categories = Category.order(:category_name) if params[:category_id] if Category.find_by(id: params[:category_id]).nil? @@ -15,7 +14,7 @@ def index @products = Product.includes(:categories).where(product_active: true, categories: { id: params[:category_id]}) end elsif params[:merchant_id] - if Merchant.find_by(id: params[:merchant_id]) == nil + if Merchant.find_by(id: params[:merchant_id]).nil? render_404 else @products = Product.includes(:merchant).where(product_active: true, products: {merchant_id: params[:merchant_id]}) @@ -45,7 +44,7 @@ def create @product.merchant = Merchant.find_by(id: params[:merchant_id]) @product.product_active = true if @product.save - flash[:success] = "Successlfully created product!" + flash[:success] = "Successfully created product!" redirect_to product_path(@product.id) else flash.now[:error] = @product.errors From 7ce1fa31d14c858a67324c84c680fcb36f2b722f Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 15:06:08 -0700 Subject: [PATCH 148/283] adds product controller tests for index & show --- test/controllers/products_controller_test.rb | 49 +++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index edcff2a0d7..c2cee5faf7 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -1,6 +1,11 @@ require "test_helper" describe ProductsController do + let(:products) { Product.where(product_active: true) } + let(:sage) { products(:sage) } + let(:clothes) { categories(:clothes) } + let(:ange) { merchants(:ange) } + describe "root" do it "succeeds for active products" do get root_path @@ -8,7 +13,6 @@ end it "succeeds for no active products" do - products = Product.where(product_active: true) products.each do |product| product.update_attributes(product_active: false) end @@ -17,7 +21,6 @@ end it "succeeds if there are no products" do - products = Product.where(product_active: true) products.each do |product| product.destroy end @@ -27,10 +30,52 @@ end describe "index" do + it "gets the products index" do + get products_path + must_respond_with :success + end + it "succeeds when are no products" do + products.each do |product| + product.destroy + end + get products_path + must_respond_with :success + end + + it "gets a merchant's products index" do + get merchant_products_path(ange) + must_respond_with :success + end + + it "renders 404 if merchant doesn't exist" do + get merchant_products_path(888) + must_respond_with :not_found + end + + it "gets a category's products index" do + get category_products_path(clothes.id) + must_respond_with :success + end + + it "renders a 404 if category id doesn't exist" do + get category_products_path(888) + must_respond_with :not_found + end end describe "show" do + it "gets an individual product's page" do + get product_path(2) + must_respond_with :success + end + + it "redirects to all products index if specific product doesn't exist" do + get product_path(567) + must_respond_with :redirect + must_redirect_to products_path + end + end From fae52497ebf1946cb59cd9031ae52ad91409a793 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 15:06:36 -0700 Subject: [PATCH 149/283] adds category for hoodie fixture --- test/fixtures/products.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 21325c8ba2..fb7e0b1c9f 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -30,6 +30,7 @@ hoodie: inventory: 5 merchant: nora photo_url: https://picsum.photos/200/?random + categories: clothes manbun: id: 4 From 7428ce7fe9a4caa1c87735eba60ad1c0ad9c000e Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 16:20:10 -0700 Subject: [PATCH 150/283] adds placeholder image functionality to products controller --- app/controllers/products_controller.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index a73773a00d..c670564873 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -3,22 +3,16 @@ class ProductsController < ApplicationController def root active = Product.where(product_active: true) @staff_picks = active.sample(10) - sorted = active.sort_by {|p| p.average_rating} - @top_rated = [] - i = 0 10.times do @top_rated << sorted[i] i +=1 end - - end def index - if params[:category_id] if Category.find_by(id: params[:category_id]).nil? render_404 @@ -55,6 +49,9 @@ def create @product = Product.new(product_params) @product.merchant = Merchant.find_by(id: params[:merchant_id]) @product.product_active = true + if params[:product][:photo_url] == "" + @product.photo_url = valid_image + end if @product.save flash[:success] = "Successfully created product!" redirect_to product_path(@product.id) @@ -71,8 +68,14 @@ def edit def update @product = Product.find_by(id: params[:id]) + if @product.photo_url.empty? && params[:product][:photo_url].empty? + @product.photo_url = valid_image + elsif params[:product][:photo_url] != "" + @product.photo_url = params[:product][:photo_url] + else + @product.photo_url = @product.photo_url + end if @product.update(product_params) - flash[:success] = "Successfully updated your product: #{@product.name}" redirect_to product_path(@product.id) else @@ -138,4 +141,8 @@ def product_params params.require(:product).permit(:name, :price, :inventory, :photo_url, :description, categories: []) end + def valid_image + "placeholder.jpg" + end + end From e7906bb8b70b4ca9c06cc33f04664792afab5982 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 16:24:31 -0700 Subject: [PATCH 151/283] adds image_tag to product index view --- app/views/products/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index c04ed487d1..06bdad3efd 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -17,7 +17,7 @@ <% if p.product_active %> <%= link_to product_path(p.id) do %>
      - product image + <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %>

      <%= p.name.capitalize %>

      $<%= format_price(p.price) %>

      From f373b2e461ba586df679054e6a091f05614dd97a Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 16:31:28 -0700 Subject: [PATCH 152/283] adds image_tag to product show page and root --- app/views/products/root.html.erb | 4 ++-- app/views/products/show.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb index c1332bcea0..033dd20471 100644 --- a/app/views/products/root.html.erb +++ b/app/views/products/root.html.erb @@ -5,7 +5,7 @@
    • <% @staff_picks.each do |p| %>
      - product image + <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %>

      <%= link_to p.name.capitalize, product_path(p.id) %>

      $<%= format_price(p.price) %>

      @@ -20,7 +20,7 @@
    • <% @top_rated.each do |p| %>
      - product image + <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %>

      <%= link_to p.name.capitalize, product_path(p.id) %>

      $<%= format_price(p.price) %>

      diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 1fd6c38e5a..02cff9370a 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -2,7 +2,7 @@

      Product: <%= @product.name %>

      - product-image + <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %>

      Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

      Description: <%=@product.description %>

      Cost: $<%= format_price(@product.price) %>

      From 40f5c906edcad5dc86620454c3c94a916aeaf902 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Tue, 24 Apr 2018 17:08:19 -0700 Subject: [PATCH 153/283] view order page as authorized merchant or non-authorized user confirmation page --- app/models/order.rb | 17 ++++++++++ app/models/order_product.rb | 6 ++-- app/views/orders/show.html.erb | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 3288a8af6f..0eb7d2d521 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -23,4 +23,21 @@ def calculate_total total end + def find_order_merchants + find_order_merchants = [] + self.order_products.each do |order_product| + find_order_merchants << order_product.product.merchant + end + return find_order_merchants + end + + def completed_order? + self.order_products.each do |order_product| + if order_product.status != "shipped" + return false + end + end + return true + end + end diff --git a/app/models/order_product.rb b/app/models/order_product.rb index 4896aa4552..d30ba5fb42 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -8,10 +8,12 @@ class OrderProduct < ApplicationRecord validates :status, presence: true, inclusion: {in: STATUS} - - def calculate_cost self.product.price * self.quantity end + def pending_order? + return self.status == "paid" + end + end diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index e69de29bb2..2df94176db 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -0,0 +1,58 @@ +<% if @order.find_order_merchants.include?(@current_merchant) %> +

      Billing Info for Order <%= @order.id %>

      + + + + + + + + + + + + + + + + + + + + + + +
      Name: <%= @order.billing_name %>
      Email<%= @order.billing_email %>
      Address<%= @order.billing_address %>
      Last 4 of CC<%= @order.billing_num.last(4) %>
      CC Exp.<%= @order.billing_exp %>
      + +<% else %> +<% order_products = @order.order_products %> +

      Confirmation Order

      +<% if @order.completed_order? %> +

      Order Completed!

      +<% else %> +

      Status <%= @order.status %>

      +<% end %> + + + + + + + + + + + <% order_products.each do |order_product| %> + + + + <% end %> + + +
      Order ProductStatus
      <%= order_product.product.name %><% if order_product.pending_order? %> awaiting shipment + <% else %> + <%= order_product.status %> + <% end %> +
      + +<% end %> From f6b1142f497ad40880335d62704045573656dc91 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Tue, 24 Apr 2018 17:32:18 -0700 Subject: [PATCH 154/283] Reformat the orders show view --- app/views/orders/show.html.erb | 99 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index 2df94176db..cf27232ac0 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -1,58 +1,57 @@ <% if @order.find_order_merchants.include?(@current_merchant) %> -

      Billing Info for Order <%= @order.id %>

      +

      Billing Info for Order <%= @order.id %>

      - - - - - - - - - - - - - - - - - - - - - -
      Name: <%= @order.billing_name %>
      Email<%= @order.billing_email %>
      Address<%= @order.billing_address %>
      Last 4 of CC<%= @order.billing_num.last(4) %>
      CC Exp.<%= @order.billing_exp %>
      - -<% else %> -<% order_products = @order.order_products %> -

      Confirmation Order

      -<% if @order.completed_order? %> -

      Order Completed!

      -<% else %> -

      Status <%= @order.status %>

      -<% end %> - - - +
      - - + + - - - - <% order_products.each do |order_product| %> - - - <% end %> + + + + + + - -
      Order ProductStatusName: <%= @order.billing_name %>
      <%= order_product.product.name %><% if order_product.pending_order? %> awaiting shipment - <% else %> - <%= order_product.status %> - <% end %> - Email<%= @order.billing_email %>
      Address<%= @order.billing_address %>
      + + Last 4 of CC + <%= @order.billing_num.last(4) %> + + + CC Exp. + <%= @order.billing_exp %> + + +<% else %> + <% order_products = @order.order_products %> +

      Confirmation Order

      + <% if @order.completed_order? %> +

      Order Completed!

      + <% else %> +

      Status <%= @order.status %>

      + <% end %> + + + + + + + + + + + <% order_products.each do |order_product| %> + + + + <% end %> + + +
      Order ProductStatus
      <%= order_product.product.name %><% if order_product.pending_order? %> awaiting shipment + <% else %> + <%= order_product.status %> + <% end %> +
      <% end %> From 3b0f6a12641139a0f5294266e339fc56b61dad00 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 17:40:29 -0700 Subject: [PATCH 155/283] fixes image tag in product show page --- app/views/products/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 02cff9370a..49d21b8116 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -2,7 +2,7 @@

      Product: <%= @product.name %>

      - <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %> + <%= image_tag @product.photo_url, alt:"product image" unless @product.photo_url.blank? %>

      Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

      Description: <%=@product.description %>

      Cost: $<%= format_price(@product.price) %>

      From 8ad09eb729237a5bef136448be7c70d947fe83a6 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Tue, 24 Apr 2018 17:41:34 -0700 Subject: [PATCH 156/283] adds image assets and references in seed file --- app/assets/images/kale.jpg | Bin 0 -> 14914 bytes db/seed-data/product-seeds.csv | 35 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 app/assets/images/kale.jpg diff --git a/app/assets/images/kale.jpg b/app/assets/images/kale.jpg new file mode 100755 index 0000000000000000000000000000000000000000..9cc695a7a63eea09a25035a77d402be0015ed1ee GIT binary patch literal 14914 zcmb7q^;?u()b7yTAssSEBi-F0ISgG&cQ**4pdt(nf-urBL&wmKFob|Gbf?Hr(o*{I zp6{GL;H7U zjSD%&Ue!NtWW@Mi-2aFAf7D>(0C4dhCq*a#7}$?MxHwoi|Eu@E)fDX5!j#HJI4|F% z*8iq@>Q^{L-M5L$A@b@}^xqPI_)$3~1r`NB5rAxmc7WE|EiJ>G%$54sZVr~4`2wdx z;&MaR-Pp3Z3M^TEfB$%#^zpCEE$sMyTF_Kt@+^Glfl4>jjoyK9nVNaQt%63a`_KUz z59i(NoNt=N2~*^%O2rGU;cm5tbSH;<`~7joySwmn{ie9}d3xxu>1RVp+{R11GR*Sz zQj%pAfeCTJwLM^7Agk&cV}4}3^pjA<8LP@sJvZOWlsxj+WJq-m+rG1+)Xf3Hn)PMp z1oW>PC%jlqq@EW~fvZ<7Nul$kbP zS&CZZ7V9g&a7q(?nk;XGjuLgjn<*y{)TH~fFYM5^=6$WTQS_Wos}D07_?6i$O8!q| z&xmIkyvv$4No$o;hGe3cDF_4>6;p+nP49v9+ISVG416<#y#@D6;P5%{azTLceMKfg8k+s{VZ3)XJ=EW_9Q8)Lk@$7k6$ zMx}3OzwR`5l5aQ zEp?mop{-X3>WjFwY&O-IBtYS1Cw6&`4TUEw`dXZkiH>Oj^B!{+mu9{{VKdIU@(Jt0 z6_%1*R1Nm91?p}8BSwRTGZBLq=+Oh*uPE>ns<8M|gZAp0Tb0-(bW=MDIQ#C?8i+neGM=}cE~}xuBTTjJp{y`uxda|gk_DrQyobchPk5(lKG{PeUrB3stlUk?#tGTw zC9qI?sOu;_SYH%UZfEY|q0FbcTyMeEu!EZ>zyo0As7VMH&Xbh)C+t-^M?F!x0-1-9 z=J0yawuC#gg-@m^_Snf}nQ!_~LjWPQVfNnd=CZ_Cn_Oz+i_QKpyN?-c=${fAjRdy? zZEGZp5^??kpkEkRe+!fzoyuM7tbaG?b=Zi$Kfp9VGZXQP4#?UI!l=Pf5<68H_Rlz!fz88{_xKRif|78F|QvB z3TF0{8CIK;L6*-7*I;vTxhRreNRG+a26?H2sYUC;EkotBz5?$d`G{4>5p5C5{byQ) zV_@PSoX0wLVSB{@sdPKK7v1Cr#}m?4*Cyt!FV+zum6rNtxx3D*B^KFy9ch`&fnS@Yo?HMbQv|EQ}s1< zwtsikZ8ue8&oi%HA$rm}ce2h*MqcVtbe6vbZ{V|0&rx!VC7Hg54PWhAL{vkOpAi7p z(yho*>?ASr%`_Is<96&HAP|00O*x6(RAmfe<3rnT?+qg-EpI=t5=VN=shu+$vM>)B z;*`GtFTVrLW|^nH$Ep@zMxz-b)QrPNca^T*{$Ococp-KGLb4vnY(s?aFDg;gxoKHw zo?@t7+3C~cUZi?ibF21qPRZUwfhdED>L+y+#lUEJ z(G%Nv0`L9Z-qGi18hU^Wg3Ew$H7+W;SKJVJcqOR z?ryN3*&cO(ZKiwjXr$DEbV&QUStYO%Rw`C!V1Pk|?@ZA>Lz1U~4E8O_y2F&-E0grN zOLjbJjz|18(tjFKN@*$(=ncba?Ikp)9JO=3g8Jeu7f%T%)pNMtPe%8M#hebRz4Sfk zinb^h5WkY0O;S|`W_+9Lz&4M~0z&msDHw(WQp{{e4CqxGGinoXovs?O$QW@wJ*_H5 zIw3~y=&fVg0;9InX+Cq++*s`eViL3tmCPm6tu8P)9Zp0;vUJa|R=F>#aAopi98Q47q&kEi&zvVgaClA^0;ULM*g{0+D!`@j{zfo6EExcEARxuGEHnD!+^w1eXU^@ z^3`LaU~xJM>x#AKrj2~uK?E5}-=NVT?9{givh<-=RLiGCroR%G$|hf$o-npfJ^M13 zo5^54&1Y@M+jut`UVTh&T?Tlwy0iK|8-=Wy-4*T{i zuwI1&<~0-2@eh!r=~&YI{vIDqbOkNxFw^H*Tz;;F*ZO>N((**z+H^1`!?=J%k_dC=u zMC+va$fC|o8n5GZay8-tS8YtZeipj`qHgxfmyhT@daT&mIK~*Ew*0Bd8<)_g+U*1F zd25FFo)@~hn)%%g@Vb8hENBy#PY0q%oDl0}J80+`{cTh)d2|cX<~DS*=GhN?%VlYa zPu}gpBku1SrZtU3|0KrvhrjT!9ozqWiHRPmC@OAMXPM>gtet!_wdZf&uFToK=aWsL zwwSUP+eM<#5PRcYZJB67>(#9({}L^(hZ=S8@Ks)v$|KL7?_M5Qu~P4jNLtfj^gMj| zF*PibH7)Ye!t3aX*TpHUHKF5mv5qPAxOYuz1`OGjsX-t$K_(?{>~3Ryk$Lthb|Teq z$TG>*?kV{mc8dOw^+{D>cel%Xam3jYN!hCMekKf7V(1QZ?&CGU-e8FgGN!6X#zqNW zHl7rfM)ubo<5cSY@?Nk$VtDx@cQ1*hp?F<_hoOk%$$U zA#2jt6|syR7qDNbccH<-z4M=**>01sfb*8XOU+n2mdp ziYYA8PDx#(=HR=xq&yThoMpjUDHDWBSDjCCS$Bf0X#E?YfEtlT!-%Ev$HK;LAc z=91i&Z-4PuO{K>dv5N>1qf8}Z0zzFrG zSZZt))D*?Ch82E!#ZrMzy^hAdNMDx18>C(M`;N;eR}d0K>i!A=$$4$#dYrG(0<H-~ke1Ol}auIa)zH!Bo*l)UunO&;O8(q!Oz}T{Fm6=VReaF<|JY4I)pK-M13W4^3 zcaCScFQ*=QJM=>05pdp@FxFZSuMT)MwWVRCC6-`BHhc7K<~b_a9F2}LaLv+F)zx-J z7$Tof!Bf#A+{UG*L7Wx@cvwDp8xXS+_2w)nQQlfz2&p6`kfo5+uZ8KD3+T7E&Fs2w zZ}0H-eL{eQdPXjE`}NF7 z&1^N78Z~F7(Df#5(eYQ-#n1_{Yt#2{Lzc?~()Z!HghY8%Af(KE5#EDN=v6sev@Yeh zlrTD0?>NM>FCiblHJT0edbzm-3mr#@wN^dyO z{R6BkXEW+?*6LS__CI@5q?I4ynNbT%17Trrbus;Z_+W*VL! zIpbr(jCzsMayw~$lO{VK%YWiYv`$&Z%a$_VE`zjbYF4h7T-hxWXDG&B{9#6(h%VCcirk{_gjU~8qfK7`n38?1!NZ-Du0BH4D zifXSMnzUav>&CgD410+LPw=4eic}JpGe*WHmV&zC*su;%;yDC%JZ?Or0nHM)6gS3b zL*mQK+d#`ibt4&CQh zQwdqrp^yF*Z}D}5rSoqO0+E}QHF&mI)<_%_(V?mg`|HKh=vmChlxhObrpaXuEu=vS%a{Bz&x8Ob|-* zM9)GOtQXxfCy6;R9YUy;IOYmJVZ4t+L-B| z&7h2thR`&i@WcqmV2W-mE$7M#B;d{cMu;-nBkqe8cy@Y3%c(kU-<>o6A3%F^iCGDY zO~^^9Te?rqrIJK=`HoZX%K@B^vuVbTvS1oy>hnM!@;A>@BP1dtJ&(Ed9GVrr*2n64 zmruBc=3`l;pqe(gm}C;CLMHWkE9{uEIYv4Ff({EHl2}BN)iCnnxB>ygX&dNs4h^$-02i$|Qp< zKud1{FP6$}pL4ldZK>0GaLbjmxKo8#%nv13WY5S>p(G8gkiwz^vdTsMB3#vtJoc23 z6%(%6=gcZKKcZxYt9>UU?xTSWDRRl>UFP$XrO1C~xmLlUskzgw-~(BL7Y}H;y^qux z`&7xp9KtyvoLk1he87%36ConaQh*EgKPjmEf%%8w`o$xYW*HKm%b84*7M<;uA35Z= z^<(j}W1@A2)Q(43*tFdFUKw1UHfjIDU)^1nMveoF*?VV?kOd|io7pDyb2>~ys|PcoJ`4~!c<TN!J==<bYUl}(C(iewV_s$SPWFkYi;+^+euiv*hE6c@P;M<=kH?RhVUK|c|Ns! zu4VXPO9(aTk@fR?8Ln)C%#qjk(MXCE{7HU=y-N23ySC(3oBK4KBw@GnWQXG)Sq`{)`i@j5w6^cU# z?*zfKHnHaHcK5qttICSq@+OtFcbP(htO2l%+A)mDWRgjwX*fz{MJ%ov(!dKZ)b>kd zPgoaMtYl{G@bJ#8!}#v_;Rbo{P?rA;R@vz;;~`DlGRdJ ziHJ(7o=DTTBk-6s{iFh}=7O&h-Qf?0toWbJ!{XqgtZm8JV?o5h3o!V+tryRimC!HG zK7C~WV=dY(@IlYRfY@+)jC3gogGH2{FvR}On)w@(3uE*|UIRcXYMZEMmQP&247K_L zfztY+tBHMvIXyf^k(U^s?w%rqk3?QE>&L^ftoNUbHxKV`mHXHlX+M>G5cBMX8AuTV zSox0kkW`hP4(QKYm=aC?R<_I-RxYy=x%C(@t&(M4noXr&<;LjSO8H@*A_JWlZ%ocM zpFnVBe$6vLN^4*ORLl#{fx`aycmDv8Mx@`Ryk}+r2!)y%Q96IgJQ=H?^f=z_`BTwM z+@J2G-=eReoA>T(#Zh>5rW-W$*%y&;rK5jYwiPe~>q|_74}DzOJy{w=fc?GIASLKIpGE?o48+7^8f` z{yD7&@6SG^JHs`taK=;*=#Q~Fp_<6jNv4OP57B|fZ%u1j=g<{hMxVqyE`ChmB{Il+ zUIcFbv}GFPtBFU;2G#d>34DOX8%>bZ(OFtF^cbjc00}!sk?4iBfH< zrN{OksCDd=$cbIncDCS!)p#S~ayiZSvkZmkNR32W?^;>#ARon6hi1zh+blV&AbX)T zB?(9J5~fzM}(E zV7l*g;beL)QL;4BmTC&jTF32?rmUmXaz!GOUkKxM&L!08|_umQ5BN? zkvB}vdp@+%NSqc9I2;#z4An!tv%B1MvIxZzie%F##;~2}d%_ExqB>?pRO*Hd&KNRn z*4m9Y&o*D(=DHL?c)5#mi>EWWhByNaRb5ikW6EF4Z3K$jIazt-Zb#iOMI4uQESEq` zq4f;;ju{Qj)15iK27*p0E+mckJWp>DLEjVVRqJJsaXy{iI#Ju((7stKGrmRdB}M+J{eV zU+w9+fN{Ww52i`SF;kXn%gP|1+VUz`9E&UPBNjv4Lvp(c4Icj@+eSb#Hob=c=+%7l zr=k4DQqT%VP5(Cp57qn(pVu-ITGeHRj^ggk%eUv|YUXE)xc3j2XU6Kh%`YZ)r*-8HW>kO92w)bI5q*muO3vF*Mry&(rg!us~tg0o8?_Zh<+^W zbflQqi@ro?iN{llJn|P`G?aGiPh({+r@OM6mygmdJOsr}A2YjEmrsqW?6c@vWi>Re z9Dt6#`WS!1iSL!yJdRuLn31jzlrbFjf)a1`LlW$h(Gp>&LrL^ckK zDnBsI`U)z&FMmuS373zk)3o{PvPqA>C1TxwjTI7F3EMB%b7`CmYhI~1#xfYxG@#^E zDmS^X^V5h|?Q|4YDBw_Rfkr~iW+vuJ%F5bj7|>bn?K;giNlZ+bL|D640Mg*|SP@aP zlA7E2SqosTnO|*w?5z)&om_|JgD*|rD-9|feG>_xjs|+JZ#gZ4;IZnHc3Je7_U=Jl z(98Df+aeMHucWNzb-!ZZgF1+Jgg4wNvz7g!q!tqVy9?KSRhtCaI-n(Q#zR?zxthurlr9Tw`0YlsdiL z>|WCqMmG$I#>My+cg@@bvtPFut5(|ltjU0mZBf-X=H`#S)*=;AJsoeG5)UyfLzD5o zJwu=7dF9t;t(rKbowZ#}@Y(b~z>YH!nZcFe-JG=AX4)&3?BFsR z9vmrxyux|m-ChBpQOB6?Kb<`z@RLS1RdI$l@>d+N8&86SuC8C8#G&f~LGid;QJw*Y z6Ek-XB2v#|OGcyJfOSNDy}d&)R6Y93Bh?YrE3WQ@Sqc;Yw{sd;dX0-x3|V9+1`O{p zDH^~c@`tw1cE~Ug{&M56Ema2hhVjzfDtIeW&rIEK6qLESa#)ciWr>Af(e)<^O08a_gF5@Xa85|NOJ4sPJn=9^ z>po25?==~gilvY1KS8tmb6ST29vXklMm6)1=DH``d%Cge`JCLFSL(u$rBr_;4c zt~!?bt41>`HQ>xiJt|H;`F5x^4_7Msh`03`^E(~~QA!Aw!af@KUfXTCEVpHHe+bSk zXz1-$jJ3S4)w$y+4BUH!B1ZNqC=v;Y4kt!MJ{a0=68z;6U%k31KQz_R;f3+lT8|s> zC7a3@MkU@Utxj^KK4wXo@A(A6Dsma4m_5ygbv=t?LsJUq%`$ThT3_%G zu++^Wo>W_fNGz9j=V{Ztm<~6YZp0*%CTiV@h`E_eN9`d*+#X2Et1laK1VvWiSbFBE zw>qbB*zMeg--~DXCRwI62)vtILf@*r^zb(b8#!1tDf;C^zQErePw2)z<3BZR(%%@$el^9X$RV*N-m)H?*Ph{jkfFvHJ_xJW%DNhj;!4r2&c z}4*5Wyiq|9RtO z%3b5%NbD~T=36FLhXT9T#fgIYS6I-7g~dO4=G^24&ykr?(|xk=wGFFZwYLxM)$Q$j zWrBz)#Zs^GH~Efg*iD`)G5VowcP3cJ+srom9=P?W_Wt*VCbLsff&F&+5Gbd_x#m8% zs0chZxiftN<2SB;_+9mshAcArlWTvSq%b}Z%tJk)q)P7J>BdQHqb|z1H#llqA=>Qk9cY~imFTZ9wYhwBS3%5N{$lMGFdvf( zUn|qHQboQ5F(=+Z8oHOk8^oD(0;yS}F{ zylb-x}{SNs=@EUs00*lA8p%N(+DbqqNvz1he$2w3JuCPS;nv!O4vv+bJJ@ zr=s#s)cCIwf3YAGu00%~mv%_d z1U#dd(qfz^HYfgD=nyM?b%^JC65?g+`D|H7;8f#u+{l1q(1<;V7Z~klIw?IQd^98^ zG+6$z!z_3Xk^MysA<@nuJ_=cPuZ%7$Ps;dq`d(H$SLtI4UW_yyo3qwHnV^p(hK`3= zOwe2jtZ85B_-Pt zml}u*rDL6}CCZ%KX3hlA;x>RldML!~j%(r*x?`KubiQSBm9a56J4TJxrKrGV5{dmb z0}{`_Mue?c>?3Rhz8IrGvwc39Xn70p)K)I}vTBtJ8ALO2=jMDiiQkTeOKbh?$?JcB zuj0Lw1Oz?NC|a3%121^phZ8chi@UAv9>TKVKs}`|t?@3Mf z(8V1gfz(5Hw9ie8M_#f`qtH6EZVXVZ0ed9N_(U3JaY`q~*A@c?d3C>O$>zGXAWHWr zjixEir_~*cntX9#7)y#^dLb;PW~I>>e8uoJKKb0`%O^ykHSuvAEhf5ZQ4HaxDfJdn zAN);@u#?J>!1TGma2N+^+}6_32j@avV{D`43~bBn7NHCVEvXU5qRvY=o2x0FZl z^U}A6k@QF_A-BTJs=}V^-z7v(`=6n*(Vx)ff@XeRg%!nBZm%j~ISvce@3i_}MODX- z=H0WD>)K9Ti5$TZe&yXD1MkuzN)xcE84)ZfvAiN@+wDPp1ZXd$$RS!h51oux8nJV( zSEcz`I$o><*VRjKb4jR);WsQ78HehJ9ca8}xET68+wQ%s2N%5NRfBHE!HY~l3`mx( zgu?~FyBIo+(?rKdia#GUmn$HvuEX0uZYt41oauQpxd2IQn)l*oAk*qDu`0u(9%gEYdlzHJ2;%(01jUy|f4fbU3Q(3H6>j%9%@{1N{}m+w_cndN3+R}MQWu$_ zKX$FX7$4Q`as=aVG`x%%=1UrY+b)K<7_J6B9O%fm&YM@y){W3CC19t*ibYyrJQGB? z7#}=c6!gh-zQmzpYc5q_2P@G=*uRG=ndRD|`hx8RG5C&_TlgT#lbU9bJ)$qhi`{S; zooq5dV81T4mM+d3U7C5br0~!WX@EUS#+#4y$>4fR5AYLkDG;PyB5oJ3RkvORvkHl) zRfAO%HXV1~QpOa!t-R54K&Fs}qJJKg)H0Z2sC(CSUcu?cjGIU^@z1n$aqSsH$`rJ) zuvi|iEF#>y1?0h7{ldL0!w?9QFb7tgQuA(m>~00@y#8U~U*b|6rRO;VHgk-U1O{}N z@J}1E8P?NF{?u6NjiCn6#mX;?`6Fe_Lz&p{Fq5e2udj^Hq+H{??9(C!nH!Bk77k6O z15XEhVJ!r2DqUVxGqB^aE3vk9rYyG-dfye-u%X&*xt)`0GQ6X-oDD^*1j#S9sU_d+BjKcFpUGlfsK})@vXf}nWWz7v#qDUBU_};PYo64 zoy-b-D1Yg>`M1->+2l6hL1jjDV%&MC?>^By44NNV-@Dw!jzrmtn|WJqq#O1r6a53A z<~nG23qxM%AvxH4iDJT-m@eW^m`Q%7>sfEi&{~cKxhuSESK_d=>^fGC#MBy2!J5#= z)#}5$DGlrbcQ2Dv8cyO&z|#uhK+4%;QSN78c7v_~yy*JtjbsSIuJ}!_JF{9|P#x}r z47&iSx6aFbmZhQV(Vw^f0OQ6wJnnq%F-wjqqwuxdvtYI$dPOWbf1GEKqtxknw2aKB z2kaJxYm*RHsHJRX>LWPHqQU z(VN&e`T~ZOUg7_OPcDXTryrmZmWUs-UN!ID0!4<{A5<6&?!w0STzr8L42RFzP1tG; zn#tu|8NNFisa-3jvo;U2uL#@98mDQ>;zpL4HOoRoU;0)_Qf|CSbYOC*>GE67wIT3r za+gk%jT7&ecFc;0HPq7gAMRw~wA5Sk&|{sThI)RV;}+Lc&gjD7{22|~sH~t%dN937 znG&HYHz-#3WnI98$X;Y1Vp+wVF)`iL#MT*(sl!(iSj4SD@{N~VXU8w4LJigCC->GZB$qBm=*heySPI? zul%i{ZQxZN?UJl>MdH+mmDuv=OvbZ(dMiJYEGaO{kMWpRx{=im%dvUy+NO&-;Os<_ zEEou{Arg6$d8Rc+)=Y-9l>EK_vU_rQ0BltOB+!a*q?Z!f$tyO@x@Jy*9DRHIe+?v}6USFe3@WIbJinp&lGeyJ^&+D5R?A8*s4 zdSsNE(z$Vw+WneB(6X^T8-cq1e3<2WV9cP|Hgq7`7<>G2KdIb3UYb*RdtgkwA^`;m5tox|a+5F<6dCIEn62ldJ z0B5KSXnL2@l|qfF5zy*|EcY#Jy{7yJpb_w5-A(;A4$`*^j5YO3 zXY%Lf?QPiMmRebu(B99l?69hMPCMpELjcnAN^q%8I|0dz*~nH!ml(A$k%nSp;>C)_ z*ts{mRo1#zFZqD%NDErkEOQx7N^rGA+cLbRpQ@|I_TDhNjMTXNO>6br>tM7qz?PHl zD{1a>3vS!5;DNsiXZ$uXr5n&fSD4E!BqaCp>S&1WzHSc~)K`6YZDsql31ua45*%MQ zsA-Pim|jwm6>H-grOeseg9sU@o?XkNBa8=?%~UyG5J(oe9}xD@jcl|6JxTf|hr;$( zz2|9K1oU{j0{&X@s#0jFn!rax@@jr)gYH@=TCk*df(%C#^2fKIu;@pvcV7s29oM^r z{j4l>Lg;B<{2HaT;QZu)i!TJ+Ao(Mg7fIG*XZQXWTVeNr5nBa~m@zP8YC5f&-324t zcS4n$S95Wa)gyV3a|v>~dV9;myL~AzlhS7-lcmj-!YwV`2js&(O{1pTtMwjO1V*Z7{>`w!CF4kddZoh@4_;>0o&S;bfM=HO|1X=ohplX@7I3jRj zZp0iA&>$MKy?6Ip>#-)Iaa>j(CGJnM{rac%?`X&u3GdA)Jra>0>_rtHXIs?di~q<+ zkeI&TB>E(g`?Kun>d}*+wq^Tb;TJBVqlZyanf+96QhU!t)9-`!UrlG!qoq6?5GFQY zgIO^X7Y=?#5O_M8w<}h5KQe%5T4^$<4VAko5uZlfKe{CQtxJ z?VKAQL;5OBH1VDoYc^PugU&WsXM-tq5N8WXl9h|1$eNN5to+6IeVhyiEKsb#6)}4( zy59>{!rmF$_5G^rR%wYc*7Qmoo)M#>wSaY(ydxZE$M5U1;ADL9o)z}HoZ!KrNaIu0 z6J12@c}JkzuNh?n!>PllMN@2I2gU8$-Nv@LD0Krf9M{rfKE$u;^XC;(#>Kb3JLCba zEM(H?rr+`x_o?G}_?1NP#%4++XaDZ&S(1Qq7?FvGW2U;g92yXyPm=qfi)0-oO z@W!ex<+9q~Y6BZhrg^CvT|I$`91a38&o<)~s@sGid1TV47FVIdR)|8Bt~NcuP#|+|bphP`kHD-wlZM)g3j9}JOm=#>=%QL3 z^4>tIpd568e=tw7Kh5eZSuBON9F%}l&88A#o=w791P>YMIeoY3 zmz18?TVEh11_C;*X*_y_L`-H^>?`BS%eX%WLOA<3^Jx1wToRk7l5L18(v2*f5c?O@ z*F0MJ?($NLyu~W-{WGPuoh7z2&l9(cWJxnW>GFY>)Zz4A4YyAh+=k=XzCJ-`fCvDC?k6w8s`My*KWXlNs2C>YKW!ASxh742?+Tr3&d8#3y( zTLLsNo`U5Xxey8%m@%r@U@D09dO zpT?4Dk*?b!qGEI3YUvrsGl9ifU{x`mM*2i28Uih^>E8qIl!s(o7pk(VDg3K@tQ|T~ zW}pG?vU2#FR}iZ_XC%-Tj!29)PXVCq_9L_CZ_)AGNOjpgL9D}+ z5k7)j}VaIYS07P+!AGl9fX-l zoI0!KU_N1Cp=2N2u;WO+hU%4PP%k_Br0P`MX!X*`f@d!^RdPm?QP$hZUnJ>HQ<@I6 zja0Jy+SW811hS!Rj*t(mZm=BDtU6QqyNL+9CV6~|Bfm16?lYT7*J9G~`O6k4Uu$8`%@Lk6C?F7E zD%$rn>BD9whCo{PR=MAV|C+SCex(^m9aaJ7$ag@X%=$0vKqR7EwTv8%qay?4#F6C6 zH*BQkFHoa@7W)RlKbUXM@t5=G_Xc}rf&(oqp3t*JUaTFFK%ngd;<`xVMu%(Zanq_QN-cH1)zliebg?4psMejr#W7 z7BKS*9J&8K+7wpJ_u+F)nC$da3mMU5OV2%#u5)2UwIz3X+Q;t*{%PjJ>Nfh|!{q}e zVwMo9yqGEhzOYKm5ui@)yDH-hZK;f;@BM0&qs5qJAbtGR-%5W|!t?cE2e0k7!pXYP z3_iR+Av2dP+IluoFEUe9MfmG!Aabbj);hhCq&?tf>*Vluq3pv?nQGziPF>x902|K5 zqYKZ*k>(GBTWZ*O^$Q|$(Ez_0bdWxP<%ibZh1yg~*PV{r<@kW{@+DBj#&|X;D~l)b zdzv<((}TpziD?riK}FXIC8WCL@v=*go6f3*mD`7z*~PV;->42XEKPP^3>L=4JLJ05 z;k&E-hcL`eJ7GY<3uduVq_4npHe4fu#}VaFkqZEdJ6=q)5}>@{d}fI){ee z94o{pTvu?viY-4|;)XrY@9%?LX83%;ITrfDLvsF)zQ-FJ9XL7oG6p`u`lK%DW%Jzg zM2wb5Ue4s|AD~2o2p?Z*kImQbYwIu3Zsyq;8BsNJc-7@=$aJxn(q%FlQ=eex@qnH8 zYxF>t=k|FwWwMM$xYrgIXZ6K+{oh}EG5XR8iaOrHRKZJ z$~0=zJyv(paq#PhP^Iq;Y5fO9<|02iGdj=U&{)=pJvF) zkuM7=mak|itXgwU>t-%BqZ5DIxT3$qObAnSg;WURu;>&Nd)6O6f?wV@svhNV-mbfJ zke;j7<*s4;u8jz2NaST1rnum+w&#tlkPtrI Date: Tue, 24 Apr 2018 18:37:26 -0700 Subject: [PATCH 157/283] Add feature to find order by confirmation number --- app/controllers/orders_controller.rb | 8 ++++++++ app/views/layouts/application.html.erb | 7 ++++--- app/views/orders/enter_order.html.erb | 6 ++++++ config/routes.rb | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 app/views/orders/enter_order.html.erb diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 5e006d6234..fe011bcb48 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -66,6 +66,14 @@ def destroy #this clears the cart before order has gone into paid status redirect_to order_path(@current_cart.id) end + def enter_order + end + + def find_order + order = Order.find((params[:order][:id]).to_i) + redirect_to order_path(order.id) + end + private def billing_params diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 36ecffe969..8510bec38b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -61,9 +61,6 @@
    - - - + + <% unless action_name == ("index" || "show" || "root") && action_name != ("new" || "create" || "edit" || "update" || "checkout" || "paid") %> + <%end%> + + +
    <%= yield %>
    diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 9b9a9202d8..7033df043b 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -2,7 +2,7 @@

    Product: <%= @product.name %>

    - <%= image_tag @product.photo_url, alt:"product image" unless @product.photo_url.blank? %> + <%= image_tag @product.photo_url, :size => "400x400", alt:"product image" unless @product.photo_url.blank? %>

    Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

    Description: <%=@product.description %>

    Cost: $<%= format_price(@product.price) %>

    From 116d3e46a2953f673c91d1dda412816526d876d8 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Wed, 25 Apr 2018 16:42:40 -0700 Subject: [PATCH 185/283] finished categories controller tests --- app/controllers/categories_controller.rb | 2 +- .../controllers/categories_controller_test.rb | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 74df02dc94..5820165f28 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -13,7 +13,7 @@ def create redirect_to products_manager_path else flash.now[:error] = @category.errors - render :new + render :new, status: :error end end diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb index 1658526844..dd2efb80c2 100644 --- a/test/controllers/categories_controller_test.rb +++ b/test/controllers/categories_controller_test.rb @@ -2,12 +2,15 @@ describe CategoriesController do let(:category) { categories(:beverage) } + let(:ange) { merchants(:ange) } describe "new" do it "succeeds" do + login(ange) get new_category_path must_respond_with :success + end end @@ -15,14 +18,28 @@ describe "create" do it "creates a new category with valid data" do + login(ange) proc { - post categories_path, params: { category: { category_name: "libations" } } + post categories_path, params: { category: { category_name: "libations", + products: "kombucha" } } }.must_change 'Category.count', 1 must_respond_with :redirect - must_redirect_to categories_path + must_redirect_to products_manager_path end + it "will not create a new category with bogus data" do + login(ange) + proc { + post categories_path, params: { category: { category_name: " ", + products: "kombucha" } } + }.wont_change 'Category.count' + must_respond_with :error + + end + + + end end From b12856f66fa7829038ff4c39961533c7b37e99cd Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Wed, 25 Apr 2018 16:54:15 -0700 Subject: [PATCH 186/283] finished sessions controller tests --- test/controllers/sessions_controller_test.rb | 63 +++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index 93a7e9ca5e..d50a14b8e2 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -1,14 +1,61 @@ require "test_helper" describe SessionsController do - it "should get login" do - get sessions_login_url - value(response).must_be :success? - end + describe "login" do - it "should get logout" do - get sessions_logout_url - value(response).must_be :success? - end + it "logs in an existing user and redirects to the root route" do + existing_merchant = merchants(:mads) + + start_count = Merchant.count + + OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(existing_merchant)) + # here ^ mock_auth is not a path or method thats being called - its part of the overall way OmniAuth is used..? + + get auth_callback_path(existing_merchant.provider) + + Merchant.count.must_equal start_count + must_redirect_to root_path + session[:merchant_id].must_equal existing_merchant.id + end + + it "must create a new user and redirects to the root route" do + new_merchant = Merchant.new( + provider: 'github', + uid: 666, + username: 'new test merchant', + email: 'test@test.com' + ) + + proc { + login(new_merchant) }.must_change 'Merchant.count', 1 + + must_redirect_to root_path + end + it "fails if a user is already logged in and a user attempts to log in" do + existing_merchant = merchants(:mads) + login(existing_merchant) + + proc { + login(existing_merchant) }.wont_change 'Merchant.count' + + must_redirect_to root_path + + end + + it "redirects to the root route and doesn't create new user if given invalid user data" do + bad_merchant = Merchant.new( + provider: 'github', + uid: 666, + email: 'test@test.com' + ) + + proc { + login(bad_merchant) }.must_change 'Merchant.count', 0 + + must_redirect_to root_path + end + + + end end From b2448d102a6f7b9dc07aa21c1c8958059207c3a1 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Wed, 25 Apr 2018 17:31:39 -0700 Subject: [PATCH 187/283] added through association between a merchant and orderproduct through product, and added filtering paths for orders by status in the merchant controller and orderfulfilment view --- app/controllers/merchants_controller.rb | 13 ++++++++++--- app/controllers/order_products_controller.rb | 2 +- app/models/merchant.rb | 1 + app/models/order_product.rb | 3 +++ app/views/merchants/order_fulfillment.html.erb | 5 ++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 39201fb55c..2f5cb4cee1 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -11,9 +11,16 @@ def order_fulfillment flash[:alert] = "You do not have access to this Merchant's order page" else @order_products = [] - @current_merchant.products.each do |product| - product.order_products.each do |order_product| - @order_products << order_product + if params[:status] + order_products = OrderProduct.status(params[:status]) + order_products.each do | order_product | + @order_products << order_product if order_product.merchant == @current_merchant + end + else + @current_merchant.products.each do |product| + product.order_products.each do |order_product| + @order_products << order_product + end end end end diff --git a/app/controllers/order_products_controller.rb b/app/controllers/order_products_controller.rb index bff9f4c8e8..be4d91edff 100644 --- a/app/controllers/order_products_controller.rb +++ b/app/controllers/order_products_controller.rb @@ -1,5 +1,5 @@ class OrderProductsController < ApplicationController - + def update order_status = params[:status] @order_product = OrderProduct.find_by(id: params[:id]) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index bd38ef54d9..896db13a84 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -1,5 +1,6 @@ class Merchant < ApplicationRecord has_many :products + has_many :order_products, through: :product validates :username, uniqueness: true, presence: true validates :email, uniqueness: true, presence: true diff --git a/app/models/order_product.rb b/app/models/order_product.rb index d30ba5fb42..b138f039e8 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,8 +1,11 @@ class OrderProduct < ApplicationRecord STATUS = ["pending", "paid", "cancelled", "shipped"] + scope :status, -> (status) {where(status: status)} + belongs_to :order belongs_to :product + has_one :merchant, through: :product validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 } diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index a0d112c179..6e6268a06b 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -3,6 +3,9 @@ <% if @order_products.empty? %>

    No one wants to support your business ¯\_(ツ)_/¯

    <% else %> + <%= link_to "Awaiting Shipping", order_fulfillment_path(status: "paid") %> + <%= link_to "Shipped", order_fulfillment_path(status: "shipped") %> + <%= link_to "Cancelled", order_fulfillment_path(status: "cancelled") %>

    All Orders:

    @@ -37,5 +40,5 @@ <% end %>
    -<% end %>> +<% end %>
    From 9e14d7bff158cfc945926dcdb8fcff82d7bf3777 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Wed, 25 Apr 2018 17:36:07 -0700 Subject: [PATCH 188/283] adds hover css to img tags --- app/assets/stylesheets/application.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 467d2241f4..b2d99ca9df 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -61,8 +61,22 @@ footer { text-align: center; } +@keyframes fadein { + from { + opacity:0; + } + to { + opacity:1; + } +} + img { border-radius: 5px; + margin-bottom: 10px; +} + +img:hover { + opacity: 0.8; } .title { From 90bc154ae042357dd8bb1cb0725f44b778a23315 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Wed, 25 Apr 2018 17:36:53 -0700 Subject: [PATCH 189/283] refactors product controller actions based on test feedback --- app/controllers/products_controller.rb | 42 +++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 1bd62dd96b..2cf2265177 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -44,14 +44,17 @@ def show end def new - @product = Product.new @merchant = Merchant.find_by(id: params[:merchant_id]) + # if @merchant.nil? + # flash[:alert] = "Merchant does not exist." + # redirect_to root_path + # end + @product = Product.new end def create @product = Product.new(product_params) - @product.merchant = @merchant.id - + @product.merchant = @current_merchant @product.product_active = true if params[:product][:photo_url] == "" @product.photo_url = valid_image @@ -61,30 +64,35 @@ def create redirect_to product_path(@product.id) else flash.now[:error] = @product.errors - render :new + render :new, status: :error end end def edit - @product = Product.find_by(id: params[:id]) @merchant = Merchant.find_by(id: params[:merchant_id]) + @product = Product.find_by(id: params[:id]) + render_404 if @product.nil? end def update @product = Product.find_by(id: params[:id]) - if @product.photo_url.empty? && params[:product][:photo_url].empty? - @product.photo_url = valid_image - elsif params[:product][:photo_url] != "" - @product.photo_url = params[:product][:photo_url] - else - @product.photo_url = @product.photo_url - end - if @product.update(product_params) - flash[:success] = "Successfully updated your product: #{@product.name}" - redirect_to product_path(@product.id) + if @product.nil? + render_404 else - flash[:error] = @product.errors - render :edit + if @product.photo_url.empty? && params[:product][:photo_url].empty? + @product.photo_url = valid_image + elsif params[:product][:photo_url] != "" + @product.photo_url = params[:product][:photo_url] + else + @product.photo_url = @product.photo_url + end + if @product.update(product_params) + flash[:success] = "Successfully updated your product: #{@product.name}" + redirect_to product_path(@product.id) + else + flash[:error] = @product.errors + render :edit, status: :error + end end end From 1495bf52d23ab560b65579a66fac27d094bab005 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Wed, 25 Apr 2018 17:38:48 -0700 Subject: [PATCH 190/283] adds products controller tests for root, index, show, new, create, edit, and update --- test/controllers/products_controller_test.rb | 101 ++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 022f375696..cd8f35234c 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -5,6 +5,9 @@ let(:sage) { products(:sage) } let(:clothes) { categories(:clothes) } let(:ange) { merchants(:ange) } + let(:user) { merchants(:user) } + let(:nora) { merchants(:nora) } + let(:hoodie) { products(:hoodie) } describe "root" do it "succeeds for active products" do @@ -80,19 +83,115 @@ end describe "new" do + it "gets the new product form for logged-in merchant" do + login(ange) + get new_merchant_product_path(ange.id) + must_respond_with :success + end + it "does not get the new product form for guest" do + get new_merchant_product_path(ange.id) + must_respond_with :redirect + must_redirect_to root_path + end end describe "create" do + it "creates a new product for logged-in merchant, with valid data" do + login(nora) + proc { + post merchant_products_path(nora.id), params: { + product: { + name: "newproduct", + price: 32.67, + description: "Super awesome new product", + inventory: 5, + photo_url: "https://picsum.photos/200/?random" + } + } + }.must_change 'Product.count', 1 + + newproduct = Product.find_by(name: "newproduct") + must_respond_with :redirect + must_redirect_to product_path(newproduct.id) + end + it "does not create a new product for logged-in merchant with bogus data" do + login(nora) + proc { + post merchant_products_path(nora.id), params: { + product: { + name: "", + price: 0, + description: "Super awesome new product", + inventory: 0, + photo_url: "https://picsum.photos/200/?random" + } + } + }.wont_change 'Product.count' + + must_respond_with :error + end end describe "edit" do + it "succeeds for an extant product ID" do + login(nora) + product = Product.find_by(name: "hoodie") + get edit_merchant_product_path(nora.id, product.id) + must_respond_with :success + end + + it "renders 404 not_found for a bogus product ID" do + login(nora) + product = Product.find_by(name: "hoodie") + product.id = "notanid" + get edit_merchant_product_path(nora.id, product.id) + must_respond_with :not_found + end end describe "update" do + it "succeeds for valid data and an extant product ID and logged-in user" do + login(nora) + product = Product.find_by(name: "hoodie") + put merchant_product_path(nora.id, product.id), params: { + product: { + name: "blue hoodie", + price: 23.67, + description: "Super awesome new product", + inventory: 3, + photo_url: "https://picsum.photos/200/?random" + } + } + updated_work = Product.find_by(id: 3) + + updated_work.name.must_equal "blue hoodie" + must_respond_with :redirect + end - end + it "fails for bogus data and an extant product ID and logged-in user" do + login(nora) + product = Product.find_by(name: "man bun") + put merchant_product_path(nora.id, product.id), params: { + product: { + name: "", + price: 0, + description: "Super awesome new product", + inventory: 0, + photo_url: "https://picsum.photos/200/?random" + } + } + must_respond_with :error + end + it "renders 404 not_found for a bogus product ID" do + login(nora) + product = Product.find_by(name: "kale chips") + product.id = "notanid" + put merchant_product_path(nora.id, product.id) + must_respond_with :not_found + end + end end From 7021e21a1a5fc4059341f00b8a5275c03f5c8d81 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Wed, 25 Apr 2018 17:49:57 -0700 Subject: [PATCH 191/283] actually finished sessions controller tests this time - i think --- test/controllers/orders_controller_test.rb | 17 +++++++++++++---- test/controllers/sessions_controller_test.rb | 12 ++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 7c06f0978f..8d52b8fdd3 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -1,32 +1,41 @@ require "test_helper" describe OrdersController do - it "should get show" do - get orders_show_url - value(response).must_be :success? + let(:order_three) { orders(:order_three) } + + describe "show" do + it "show individual orders" do + get order_path(order_three.id) + must_respond_with :success + end end it "should get create" do - get orders_create_url + skip + get orders_creat value(response).must_be :success? end it "should get update" do + skip get orders_update_url value(response).must_be :success? end it "should get checkout" do + skip get orders_checkout_url value(response).must_be :success? end it "should get paid" do + skip get orders_paid_url value(response).must_be :success? end it "should get destroy" do + skip get orders_destroy_url value(response).must_be :success? end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index d50a14b8e2..b0dc8487dc 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -55,7 +55,19 @@ must_redirect_to root_path end + end + + describe "logout" do + it "can log out a logged in user" do + #login user from fixtures + login(merchants(:nora)) + delete logout_path + session[:merchant_id].must_be_nil + must_redirect_to root_path end + +end + end From 4d5b95a3fcdf89088a1c0fbe7e97853ad4c97e82 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Wed, 25 Apr 2018 17:59:02 -0700 Subject: [PATCH 192/283] adds function to return to all orders on order fulfillment page, and handles if there are no orders with a particular status --- app/controllers/merchants_controller.rb | 6 ++++++ app/views/merchants/order_fulfillment.html.erb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 2f5cb4cee1..2b5b0a68d3 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -11,6 +11,7 @@ def order_fulfillment flash[:alert] = "You do not have access to this Merchant's order page" else @order_products = [] + @merchant_orders = [] if params[:status] order_products = OrderProduct.status(params[:status]) order_products.each do | order_product | @@ -23,6 +24,11 @@ def order_fulfillment end end end + @current_merchant.products.each do |product| + product.order_products.each do |order_product| + @merchant_orders << order_product + end + end end end diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index 6e6268a06b..d2b6d198c0 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -1,8 +1,9 @@

    <%= @current_merchant.username %>

    - <% if @order_products.empty? %> + <% if @merchant_orders.empty? %>

    No one wants to support your business ¯\_(ツ)_/¯

    <% else %> + <%= link_to "All Orders", order_fulfillment_path %> <%= link_to "Awaiting Shipping", order_fulfillment_path(status: "paid") %> <%= link_to "Shipped", order_fulfillment_path(status: "shipped") %> <%= link_to "Cancelled", order_fulfillment_path(status: "cancelled") %> From 624235cb1c4685b4f4672405851fe65ff06354d7 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Wed, 25 Apr 2018 18:27:30 -0700 Subject: [PATCH 193/283] added images --- db/seed-data/product-seeds.csv | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/db/seed-data/product-seeds.csv b/db/seed-data/product-seeds.csv index 4fd4daa5d2..cbb7dda219 100644 --- a/db/seed-data/product-seeds.csv +++ b/db/seed-data/product-seeds.csv @@ -1,35 +1,35 @@ id,name,price,inventory,description,product_active,merchant_id,photo_url -1,1 dozen locally-sourced grass-fed organic cage-free eggs,37,6,"Lorem ipsum dolor amet pok pok bicycle rights 8-bit man braid, kinfolk humblebrag shabby chic.",TRUE,1,https://picsum.photos/300/?random +1,1 dozen locally-sourced grass-fed organic cage-free eggs,37,6,"Lorem ipsum dolor amet pok pok bicycle rights 8-bit man braid, kinfolk humblebrag shabby chic.",TRUE,1,https://i.imgur.com/Hg7nGth.jpg?1 2,single-origin shade-grown fair-trade coffee,20,30,Mumblecore coloring book DIY YOLO chia farm-to-table leggings man bun glossier trust fund.,TRUE,4,https://i.imgur.com/BQZTfkj.jpg?2 -3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1,https://picsum.photos/300/?random -4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3,https://picsum.photos/300/?random -5,PBR,52,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://picsum.photos/300/?random -6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial.,TRUE,1,https://picsum.photos/300/?random -7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4,https://picsum.photos/200/?random -8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2,https://picsum.photos/200/?random -9,cold-pressed green juice,24,6,"Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice.",TRUE,3,https://picsum.photos/200/?random -10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1,https://picsum.photos/200/?random -11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2,https://picsum.photos/200/?random -12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard.,TRUE,3,https://picsum.photos/200/?random +3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1,https://i.imgur.com/VaoLUUw.jpg?1 +4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3,https://i.imgur.com/Xs4ZJ45.jpg?1 +5,PBR,10,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://i.imgur.com/PtojRUr.png +6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial.,TRUE,1,https://i.imgur.com/9Buk6e4.jpg?1 +7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4,https://i.imgur.com/39j8OSQ.jpg?1 +8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2,https://i.imgur.com/pCVXDq4.jpg?1 +9,cold-pressed green juice,24,6,"Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice.",TRUE,3,https://i.imgur.com/NiFjw7u.jpg?1 +10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1,https://i.imgur.com/3NDAcqB.jpg?1 +11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2,https://i.imgur.com/DNC4VTY.png +12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard.,TRUE,3,https://i.imgur.com/svnw3Rk.png?1 13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3,https://picsum.photos/200/?random -14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4,https://picsum.photos/200/?random -15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://picsum.photos/200/?random -15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://picsum.photos/200/?random -16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1,https://picsum.photos/200/?random -17,tiny house made from reclaimed wood,23,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1,https://picsum.photos/200/?random -18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3,https://picsum.photos/200/?random -19,crystal collection,20,28,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,2,https://picsum.photos/200/?random -20,ukelele banjo hybrid,40,5,"Hell flames. In willow trees, killer dolls are rotten teeth bite, sheep children virus nibh, in zombies brains unknown ghost creepy. Eerie needles edginess, graveyard on death rotten, disturbing non grave. Drenched scream scared dark. Cat at decapitated guns. Undead obsession tear horrifying, a devil fiendish tense in. Haunt tearin.",TRUE,2,https://picsum.photos/200/?random -21,beard oil,25,10,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled.,TRUE,3,https://i.imgur.com/wKCkeYI.jpg -22,plaid flannel,30,11,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a, psychotic ashes ghost. Eyeball cat silent, morbid in damp torture, 666 at brains. Haunt suicide silent, gory as demonic alarming, burie.",TRUE,1,https://picsum.photos/200/?random -23,hoodie,23,22,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. Creep cold graves, shadow non fear a, psychotic ashes ghost. Trapped flesh grotesque squeal, bloodcurdling chilling hair-raising spooky hazardous daring. Creep serial killer, bury a scourge menacing, pai.",TRUE,3,https://picsum.photos/200/?random -24,skinny jeans,54,28,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights.,TRUE,2,https://picsum.photos/200/?random -25,vans,56,30,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings.,TRUE,1,https://picsum.photos/200/?random -26,neon fanny pack,40,20,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh.",TRUE,3,https://picsum.photos/200/?random -27,macrame wall hanging,24,40,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,4,https://picsum.photos/200/?random +14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4,https://i.imgur.com/QObnGi2.png?2 +15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://i.imgur.com/rkY4Y0E.jpg?1 +,,,,,,, +16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1,https://i.imgur.com/6NospY4.jpg?1 +17,tiny house made from reclaimed wood,5000,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1,https://i.imgur.com/eTjwShw.jpg?1 +18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3,https://i.imgur.com/CRydqQ3.jpg?1 +19,crystal collection,20,28,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,2,https://i.imgur.com/VvzeUC7.jpg?1 +20,ukelele banjo hybrid,40,5,"Hell flames. In willow trees, killer dolls are rotten teeth bite, sheep children virus nibh, in zombies brains unknown ghost creepy. Eerie needles edginess, graveyard on death rotten, disturbing non grave. Drenched scream scared dark. Cat at decapitated guns. Undead obsession tear horrifying, a devil fiendish tense in. Haunt tearin.",TRUE,2,https://i.imgur.com/VaNQLxS.jpg?1 +21,beard oil,25,10,Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled.,TRUE,3,https://i.imgur.com/wKCkeYI.jpg?1 +22,plaid flannel,30,11,"Church-key chia meh tumblr franzen taiyaki unicorn Creep cold graves, shadow non fear a, psychotic ashes ghost. Eyeball cat silent, morbid in damp torture, 666 at brains. Haunt suicide silent, gory as demonic alarming, burie.",TRUE,1,https://i.imgur.com/2Wuc2dH.jpg?1 +23,hoodie,23,22,"Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. Creep cold graves, shadow non fear a, psychotic ashes ghost. Trapped flesh grotesque squeal, bloodcurdling chilling hair-raising spooky hazardous daring. Creep serial killer, bury a scourge menacing, pai.",TRUE,3,https://i.imgur.com/b88O1DR.jpg?1 +24,skinny jeans,54,28,Flannel cardigan microdosing coloring book succulents waistcoat cornhole ethical pork belly yr messenger bag bicycle rights.,TRUE,2,https://i.imgur.com/mLhcyxG.jpg?1 +25,vans,56,30,Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings.,TRUE,1,https://i.imgur.com/uEy2zI2.jpg?2 +26,neon fanny pack,40,20,"Shoreditch migas cray knausgaard 90's, iPhone humblebrag pour-over single-origin coffee direct trade lomo tbh.",TRUE,3,https://i.imgur.com/7CvCOZX.jpg?1 +27,macrame wall hanging,24,40,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,4,https://i.imgur.com/qEUFAk2.png?2 28,chemex,23,22,Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up.,TRUE,3,https://i.imgur.com/IJliYrp.jpg?2 -29,fixie bike,54,28,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut",TRUE,4,https://picsum.photos/200/?random -30,wooden bowtie,56,30,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam.,TRUE,1,https://picsum.photos/200/?random -31,man bun,40,20,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. ",TRUE,1,https://picsum.photos/200/?random -32,air plant terrarium,24,40,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo.",TRUE,4,https://picsum.photos/200/?random -33,turntable & vinyl,85,2,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,1,https://picsum.photos/200/?random \ No newline at end of file +29,fixie bike,54,28,"Food truck trust fund street art snackwave gastropub, mlkshk helvetica pok pok meh truffaut cronut",TRUE,4,https://i.imgur.com/1CCRWnn.jpg?2 +30,wooden bowtie,56,30,Taiyaki jianbing chicharrones la croix prism fixie iPhone vegan asymmetrical shaman shabby chic squid everyday carry fam.,TRUE,1,https://i.imgur.com/Kmkdbh9.png?1 +31,man bun,40,20,"DIY yuccie brunch, hella tilde woke kombucha blog gentrify pour-over. ",TRUE,1,https://i.imgur.com/0NnAIV7.jpg?1 +32,air plant terrarium,24,40,"Raclette marfa semiotics, put a bird on it organic cardigan polaroid waistcoat palo santo church-key venmo.",TRUE,4,https://i.imgur.com/66c8ahb.jpg?1 +33,turntable & vinyl,85,2,"Swag hashtag edison bulb single-origin coffee XOXO 90's scenester master cleanse, man bun semiotics. In the deranged Halloween slice. Psycho crazy mental hospital moon. Eyeball cat silent, morbid in damp torture, 666 at brains. Pain needles commodo drool rabid nightmare. Demons in fallen angel non terror decomposed rotten teeth. Pain needles commodo drool rabid nightmare. Horror bowels exorcism grave cut, murderer creature ripped. Dungeon in a gruesome, a disembowel unknown. Creep serial killer.",TRUE,1,https://i.imgur.com/7b9D8dJ.jpg?1 \ No newline at end of file From 6a121a1c1ba89426aeadaa0a503a523b6c936b6b Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Wed, 25 Apr 2018 18:39:03 -0700 Subject: [PATCH 194/283] apply require_login to merchants controller and delete comments from sessions controller --- app/controllers/merchants_controller.rb | 44 ++++++++++--------------- app/controllers/sessions_controller.rb | 14 -------- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 2b5b0a68d3..7492445aca 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,43 +1,33 @@ - class MerchantsController < ApplicationController +class MerchantsController < ApplicationController + + before_action :require_login def account_page #show - only visible by OAuth - if !@current_merchant - flash[:alert] = "You do not have access to this Merchant's account" - end end def order_fulfillment - if !@current_merchant - flash[:alert] = "You do not have access to this Merchant's order page" - else - @order_products = [] - @merchant_orders = [] - if params[:status] - order_products = OrderProduct.status(params[:status]) - order_products.each do | order_product | - @order_products << order_product if order_product.merchant == @current_merchant - end - else - @current_merchant.products.each do |product| - product.order_products.each do |order_product| - @order_products << order_product - end - end + @order_products = [] + @merchant_orders = [] + if params[:status] + order_products = OrderProduct.status(params[:status]) + order_products.each do | order_product | + @order_products << order_product if order_product.merchant == @current_merchant end + else @current_merchant.products.each do |product| product.order_products.each do |order_product| - @merchant_orders << order_product + @order_products << order_product end end end + @current_merchant.products.each do |product| + product.order_products.each do |order_product| + @merchant_orders << order_product + end + end end def products_manager - if !@current_merchant - flash[:alert] = "You do not have access to this Merchant's product management" - else - @products = @current_merchant.products - end + @products = @current_merchant.products end - end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abd00ca605..a3db292c07 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,26 +1,12 @@ class SessionsController < ApplicationController - # skip_before_action :require_login, only: [:create] - - # def failure - # auth_hash = request.env['omniauth.auth'] - # - # logger.debug "MADE IT TO FAILURE" - # logger.debug "Auth_hash = #{auth_hash}" - # logger.debug "params = #{params}" - # - # end def login auth_hash = request.env['omniauth.auth'] - # logger.debug "MADE IT TO LOGIN" - # logger.debug "Auth_hash = #{auth_hash}" - if auth_hash['uid'] @merchant = Merchant.find_by(uid: auth_hash[:uid], provider: 'github') if @merchant.nil? - #its a new user, we need to MAKE a new user @merchant = Merchant.build_from_github(auth_hash) successful_save = @merchant.save if successful_save From d9dd3a79de153f72c7aace87efc1a808c5b10b40 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Wed, 25 Apr 2018 19:08:36 -0700 Subject: [PATCH 195/283] comments out new category form in new product form temporarily until it can be addressed --- app/views/products/_form.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb index cdf8ba98fa..098ad67cde 100644 --- a/app/views/products/_form.html.erb +++ b/app/views/products/_form.html.erb @@ -1,5 +1,5 @@

    <%= page_title %>

    -<%= form_for([@merchant, @product]) do |f| %> +<%= form_for @merchant, @product do |f| %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :price %> @@ -12,10 +12,11 @@ <%= f.text_field :photo_url %> <%= f.label :category %> <%= f.collection_check_boxes(:category_ids, Category.all, :id, :category_name ) %> - <%= f.fields_for :categories, @product.categories.build do |categories_fields| %> + <%= f.submit "Submit", class: "button" %> <% end %> From af81ff83804dfc67454137a3348dd0f99148d7fa Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Wed, 25 Apr 2018 19:32:53 -0700 Subject: [PATCH 196/283] hide nav bar on specified pages --- app/views/layouts/application.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fae5de2961..c524c0e07f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -44,7 +44,8 @@ <% end %> - <% unless action_name == ("index" || "show" || "root") && action_name != ("new" || "create" || "edit" || "update" || "checkout" || "paid") %> + <% unless controller_name == "merchants" || action_name == "new"|| action_name == "edit" || action_name == "checkout" || (controller_name != "products" && action_name == "index") %> + <%end%> -
    <%= yield %>
    From 083b82a661f7d8adaca5ee090b0a31b809720304 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Wed, 25 Apr 2018 20:28:34 -0700 Subject: [PATCH 198/283] tiny style change to merchant account page --- app/assets/stylesheets/application.css | 24 +++++++++++++++++++ app/views/merchants/account_page.html.erb | 2 +- .../merchants/order_fulfillment.html.erb | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index b2d99ca9df..d39fc6a82d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -47,6 +47,11 @@ a { color: black; } + +h3 { + font-size: 2em; +} + h3, h5 { text-align: center; padding-bottom: 40px; @@ -79,6 +84,11 @@ img:hover { opacity: 0.8; } +.shop-name { + font-size: 2em; + font-weight: bold; +} + .title { letter-spacing: 3px; text-align: center; @@ -117,6 +127,20 @@ img:hover { border-radius: 5px; } +.merchant-options { + text-align: center; +} + +.account-page { + border: dotted; + margin-left: 500px; + margin-right: 500px; + padding-top: 100px; + padding-bottom: 100px; + border-radius: 20px; +} + + @media screen and (max-width: 1000px) { .grid-container { grid-template-columns: 1fr 1fr 1fr; diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index c75c48094f..bcc654189c 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -1,4 +1,4 @@ -

    <%= @current_merchant.username%>

    +

    <%= @current_merchant.username%>'s Shop

    Account Options:

    - - -<%= @paid_orders.inject(0){|sum,x| sum + x } - %> From f27e4b205304448e20201dc4ccd88e1b544e0f02 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 10:14:50 -0700 Subject: [PATCH 215/283] refactored products fixtures to exclude manually assigned ids, updated products tests to handle change in fixtures, and refactored update action to redirect rather than render when errors occur in the form --- app/controllers/products_controller.rb | 2 +- test/controllers/products_controller_test.rb | 19 ++++++++++++++----- test/fixtures/products.yml | 7 ------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 8b4a912cbb..170d886167 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -91,7 +91,7 @@ def update redirect_to product_path(@product.id) else flash[:error] = @product.errors - render :edit, status: :error + redirect_to edit_merchant_product_path(@current_merchant.id, @product.id) end end end diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index cd8f35234c..c11e1e8d27 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -69,7 +69,10 @@ describe "show" do it "gets an individual product's page" do - get product_path(2) + id = Product.find_by(name: "sage").id + + get product_path(id) + must_respond_with :success end @@ -130,7 +133,8 @@ } }.wont_change 'Product.count' - must_respond_with :error + must_respond_with :redirect + must_redirect_to new_merchant_product_path(nora.id) end end @@ -165,9 +169,9 @@ photo_url: "https://picsum.photos/200/?random" } } - updated_work = Product.find_by(id: 3) + updated_product = Product.find_by(name: "blue hoodie") - updated_work.name.must_equal "blue hoodie" + updated_product.name.must_equal "blue hoodie" must_respond_with :redirect end @@ -183,7 +187,12 @@ photo_url: "https://picsum.photos/200/?random" } } - must_respond_with :error + + unchanged_product = Product.find_by(name: "man bun") + + unchanged_product.name.must_equal "man bun" + must_respond_with :redirect + must_redirect_to edit_merchant_product_path(nora.id, product.id) end it "renders 404 not_found for a bogus product ID" do diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 9fa410aff0..c9f89f96b4 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -1,7 +1,6 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html kombucha: - id: 1 name: kombucha price: 39 description: Subway tile hexagon letterpress austin cloud bread helvetica. @@ -12,7 +11,6 @@ kombucha: categories: food, beverage sage: - id: 2 name: sage price: 43 description: Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual. @@ -23,7 +21,6 @@ sage: categories: food, extra hoodie: - id: 3 name: hoodie price: 77 description: Artisan brooklyn plaid woke yuccie flannel truffaut copper mug irony leggings. @@ -34,7 +31,6 @@ hoodie: categories: clothes manbun: - id: 4 name: man bun price: 25 description: Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. @@ -44,7 +40,6 @@ manbun: photo_url: https://picsum.photos/200/?random chemex: - id: 5 name: chemex price: 39 description: Migas marfa iPhone prism four dollar toast truffaut man bun messenger bag pug pop-up. @@ -54,7 +49,6 @@ chemex: photo_url: https://picsum.photos/200/?random salt_lamp: - id: 6 name: salt lamp price: 56 description: Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice. @@ -64,7 +58,6 @@ salt_lamp: photo_url: https://picsum.photos/200/?random kale_chips: - id: 7 name: kale chips price: 9 description: Beard affogato pork belly mlkshk franzen. children virus nibh, in zombies brains unknown ghost creepy. From 6c92b4ca03d66ad009cd88dc2403e5457fc8715c Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 10:37:56 -0700 Subject: [PATCH 216/283] edits product show view --- app/assets/stylesheets/application.css | 22 +++++++++++++ app/views/products/show.html.erb | 43 ++++++++++++++------------ 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index d39fc6a82d..719c842cb8 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -140,6 +140,18 @@ img:hover { border-radius: 20px; } +.show-container { + display: flex; + margin-bottom: 20px; +} + +.show-section2 { + margin-left: 40px; +} + +.show-section1 { + margin-bottom: 20px; +} @media screen and (max-width: 1000px) { .grid-container { @@ -157,4 +169,14 @@ img:hover { .grid-container { grid-template-columns: 1fr; } + + .show-container { + flex-direction: column; + justify-content: center; + align-items: center; + } + + .show-section2 { + margin-left: 0px; + } } diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 7033df043b..ac365ed983 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -1,26 +1,29 @@ -

    Product: <%= @product.name %>

    +
    +
    + <%= image_tag @product.photo_url, :size => "400x400", alt:"product image" unless @product.photo_url.blank? %> +
    +
    +

    Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

    +

    Description: <%=@product.description %>

    +

    Cost: $<%= format_price(@product.price) %>

    + <% if @product.inventory == 0 %> +

    Out of Stock

    + <%else%> +

    <%= @product.inventory %> in stock

    + <%end%> +

    Categories: <% @product.categories.each do |c| %> <%= link_to c.category_name, category_products_path(c.id) %> + <% end %>

    +

    Quantity:

    + <%= form_for :order_products, url: add_to_order_path(@product.id), method: :get do |f| %> + <%= f.hidden_field :product_id, value: @product.id %> + <%= f.select(:inventory, (1..@product.inventory)) %> - <%= image_tag @product.photo_url, :size => "400x400", alt:"product image" unless @product.photo_url.blank? %> -

    Merchant: <%= link_to @product.merchant.username, merchant_products_path(@product.merchant.id) %>

    -

    Description: <%=@product.description %>

    -

    Cost: $<%= format_price(@product.price) %>

    - <% if @product.inventory == 0 %> -

    Out of Stock

    - <%else%> -

    <%= @product.inventory %> in stock

    - <%end%> -

    Categories: <% @product.categories.each do |c| %> <%= link_to c.category_name, category_products_path(c.id) %> - <% end %>

    -

    Quantity:

    - <%= form_for :order_products, url: add_to_order_path(@product.id), method: :get do |f| %> - <%= f.hidden_field :product_id, value: @product.id %> - <%= f.select(:inventory, (1..@product.inventory)) %> - - <%= f.submit "Add to Cart", class: "button" %> - <% end %> -
    + <%= f.submit "Add to Cart", class: "button" %> + <% end %> +
    +

    Reviews

    From 648494e04621a451a3abed190c6e7cd598dcb275 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 26 Apr 2018 10:59:46 -0700 Subject: [PATCH 217/283] show revenue and order count by status --- app/controllers/merchants_controller.rb | 30 +++++++++++ app/views/merchants/account_page.html.erb | 62 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 7e2cbfe512..ac64087b6f 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,5 +1,7 @@ class MerchantsController < ApplicationController def account_page + @total_net_revenue = [] + @total_orders = [] @current_merchant.products.each do |product| product.order_products.each do |order_product| @@ -7,14 +9,42 @@ def account_page end end + @total_orders.each do |order_product| + @total_net_revenue << order_product.product.price + end + + @pending_totals = [] + @pending_orders = @total_orders.select { |order| order.status == "pending" } + @pending_orders.each do |order_product| + @pending_totals << order_product.product.price + end + + + @paid_totals = [] + @paid_orders = @total_orders.select { |order| order.status == "paid" } + @paid_orders.each do |order_product| + @paid_totals << order_product.product.price + end + + @cancelled_totals = [] + @cancelled_orders = @total_orders.select { |order| order.status == "cancelled" } + @cancelled_orders.each do |order_product| + @cancelled_totals << order_product.product.price + end + + @shipped_totals = [] + @shipped_orders = @total_orders.select { |order| order.status == "shipped" } + @shipped_orders.each do |order_product| + @shipped_totals << order_product.product.price + end end diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index bcc654189c..43cfe4102a 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -13,3 +13,65 @@
    + +
    +

    Summary

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Revenue
    Total Revenue for Pending Orders: <%= "#{format_price(@pending_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Paid Orders: <%= "#{format_price(@paid_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Cancelled Orders: <%= "#{format_price(@cancelled_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Shipped Orders: <%= "#{format_price(@shipped_totals.inject(0){|sum,x| sum + x })}" %>
    Total Net Revenue: <%= "#{format_price(@total_net_revenue.inject(0){|sum,x| sum + x })}" %>
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Orders
    Total Pending Orders: <%= @pending_orders.count %>
    Total Paid Orders: <%= @paid_orders.count %>
    Total Cancelled Orders: <%= @cancelled_orders.count %>
    Total Shipped Orders: <%= @shipped_orders.count %>
    Total Orders: <%= @total_orders.count %>
    +
    From e28b34e5d2cb199ce150282eb527330204055013 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 11:21:20 -0700 Subject: [PATCH 218/283] small account page styling --- app/assets/stylesheets/application.css | 4 ++-- app/views/merchants/account_page.html.erb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 719c842cb8..e6d33b94d9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -135,8 +135,8 @@ img:hover { border: dotted; margin-left: 500px; margin-right: 500px; - padding-top: 100px; - padding-bottom: 100px; + padding-top: 50px; + padding-bottom: 50px; border-radius: 20px; } diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index 43cfe4102a..614150169d 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -3,13 +3,13 @@

    Account Options:

    From 1ea92df3f79b84a376bd574fd2090c8dee3b86a4 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 11:25:18 -0700 Subject: [PATCH 219/283] adds link to product index images and css to product show view --- app/assets/stylesheets/application.css | 1 + app/views/products/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 719c842cb8..0bd71e1ff8 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -151,6 +151,7 @@ img:hover { .show-section1 { margin-bottom: 20px; + flex-shrink: 0; } @media screen and (max-width: 1000px) { diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 43ca02d4a3..4a84c47d47 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -18,7 +18,7 @@ <% if p.product_active %>
    <%= link_to product_path(p.id) do %> - <%= image_tag p.photo_url, :size => "300x300", alt:"product image" unless p.photo_url.blank? %> + <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>

    <%= p.name.capitalize %>

    $<%= format_price(p.price) %>

    <% end %> From d1f36800ae297174113b6fb4164504bacb46442b Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 11:49:51 -0700 Subject: [PATCH 220/283] fixed paid action problem for correcting unused variable --- app/controllers/orders_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 1823269c49..853b2a4416 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -38,7 +38,7 @@ def paid #submit after checkout if @current_cart.save flash[:success] = "Order received! Thank you for your purchase." session[:order_id] = Order.create.id - redirect_to order_path(order.id) + redirect_to order_path(@current_cart.id) else flash.now[:error] = @current_cart.errors render :checkout From 044187a8b7d14ebd4696d5c491fa2a0063110470 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 12:02:37 -0700 Subject: [PATCH 221/283] minor change to order show view(confirmation page) --- app/views/orders/show.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb index cf27232ac0..39caf624ce 100644 --- a/app/views/orders/show.html.erb +++ b/app/views/orders/show.html.erb @@ -26,11 +26,12 @@ <% else %> <% order_products = @order.order_products %> -

    Confirmation Order

    +

    Order Confirmation

    <% if @order.completed_order? %>

    Order Completed!

    <% else %> -

    Status <%= @order.status %>

    +

    Order Status: <%= @order.status %>

    +

    Order # <%= @order.id %>

    <% end %> From 13036625c9ae2a582bf7ee8d49d784f202b56ecc Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 12:36:55 -0700 Subject: [PATCH 222/283] updated categories test to handle change to product yml file and changed application.html.erb view flash messages to handle an error that occurred when there is only one error message from invalid form submission --- app/views/layouts/application.html.erb | 8 +++- .../controllers/categories_controller_test.rb | 44 +++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ebe7470fbb..06fce302b1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,8 +42,12 @@
    <% flash[:error].each do |field, error_messages| %>
    <%= field.upcase %>
    - <% error_messages.each do |error_message| %> -
    >> <%= error_message %>
    + <% if error_messages.class == Array %> + <% error_messages.each do |error_message| %> +
    >> <%= error_message %>
    + <% end %> + <% else %> +
    >> <%= error_messages %>
    <% end %> <% end %> diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb index f622679e2b..0751a8c3d5 100644 --- a/test/controllers/categories_controller_test.rb +++ b/test/controllers/categories_controller_test.rb @@ -1,5 +1,5 @@ require "test_helper" - +require "pry" describe CategoriesController do let(:category) { categories(:beverage) } let(:ange) { merchants(:ange) } @@ -39,7 +39,8 @@ product_ids: [product.id] } } }.must_change 'Category.count', 1 - product.categories.length.must_equal 3 + updated_product = Product.find_by(name: "sage") + must_respond_with :redirect must_redirect_to products_manager_path end @@ -65,24 +66,9 @@ product_ids: [product.id] } } }.wont_change 'Category.count' - product.categories.length.must_equal 2 must_respond_with :error end - it "doesn't add new category to products that do not belong to current user" do - login(ange) - product = Product.find_by(name: "kombucha") - - proc { - post categories_path, params: { category: { category_name: "libations", - product_ids: [product.id] } } - }.must_change 'Category.count', 1 - - product.categories.length.must_equal 2 - must_respond_with :redirect - must_redirect_to products_manager_path - end - it "redirects to root view if no user present and doesn't save to model" do product = Product.find_by(name: "sage") @@ -91,10 +77,32 @@ product_ids: [product.id] } } }.wont_change 'Category.count' - product.categories.length.must_equal 2 must_respond_with :redirect must_redirect_to root_path end + it "does not duplicate the model records of product categories" do + # login(ange) + # product = Product.find_by(name: "sage") + # + # post categories_path, params: { category: { category_name: "libations", product_ids: [product.id] } } + # + # updated_product = Product.find_by(name: "sage") + # + # updated_product.categories.length.must_equal 3 + end + + it "doesn't add new category to products that do not belong to current user" do + # edge case to consider if there is time + # login(ange) + # product = Product.find_by(name: "kombucha") + # + # post categories_path, params: { category: { category_name: "libations", product_ids: [product.id] } } + # + # updated_product = Product.find_by(name: "kombucha") + # + # updated_product.categories.length.must_equal 2 + end + end end From a2c718d286996cc070e05be89ddc635f6812208a Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 13:55:31 -0700 Subject: [PATCH 223/283] changed product name to a link to product show pages in products manager table --- app/views/merchants/products_manager.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index 340f04e3bb..2ec231e305 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -27,7 +27,7 @@
    <% @products.each do | product | %> - + From dbe321418ed9dc40f05e13eb131994e96134011f Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 14:53:12 -0700 Subject: [PATCH 224/283] small styling stuff --- app/assets/stylesheets/application.css | 13 +++++++++++++ app/views/layouts/application.html.erb | 4 ++-- app/views/merchants/order_fulfillment.html.erb | 2 +- app/views/merchants/products_manager.html.erb | 6 +++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index be4381721a..184279ae06 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -127,6 +127,11 @@ img:hover { border-radius: 5px; } +.button:hover { + color: #43ECAE; +} + + .merchant-options { text-align: center; } @@ -154,6 +159,14 @@ img:hover { flex-shrink: 0; } +#footer { + border-top: solid thin; +} + +#find-order { + text-align: left; +} + @media screen and (max-width: 1000px) { .grid-container { grid-template-columns: 1fr 1fr 1fr; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ebe7470fbb..2a45e1d32a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -82,8 +82,8 @@ <%= yield %> -
    -

    <%= link_to "Find Order", enter_order_path %>

    +
    +

    <%= link_to "Homepage", root_path %> | <%= link_to "Find An Order", enter_order_path %> | <%= link_to "About Us", root_path %>

    diff --git a/app/views/merchants/order_fulfillment.html.erb b/app/views/merchants/order_fulfillment.html.erb index ab809b9ed6..cd3bf66d9e 100644 --- a/app/views/merchants/order_fulfillment.html.erb +++ b/app/views/merchants/order_fulfillment.html.erb @@ -1,4 +1,4 @@ -

    <%= @current_merchant.username %>

    +

    Merchant: <%= @current_merchant.username %>

    <% if @merchant_orders.empty? %>

    No one wants to support your business ¯\_(ツ)_/¯

    diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index 340f04e3bb..edfb6741e0 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -1,13 +1,13 @@ -

    <%= @current_merchant.username%>

    +

    Merchant: <%= @current_merchant.username%>

    Product Management:

    • - <%= link_to "Add a Product", new_merchant_product_path(@current_merchant.id) %> + <%= link_to "Add a Product", new_merchant_product_path(@current_merchant.id), class: "button" %>
    • - <%= link_to "Add a category", new_category_path %> + <%= link_to "Add a category", new_category_path, class: "button" %>
    From 0d12ff2034566648e35f79983c347bd3d8be9080 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 14:55:24 -0700 Subject: [PATCH 225/283] updates root method and view --- app/assets/stylesheets/application.css | 4 ++++ app/controllers/products_controller.rb | 1 + app/views/products/root.html.erb | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index be4381721a..89ba32b31b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -107,6 +107,10 @@ img:hover { margin-right: 2rem; } +.dropdown.menu li:nth-child(2) { + padding-left: 10px; +} + .grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 170d886167..d22ab6fe19 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -12,6 +12,7 @@ def root @staff_picks = active.sample(10) end @top_rated = active.sort_by {|p| p.average_rating} + @top_rated.reverse! @top_rated = @top_rated[0..9] end diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb index 2250bb2471..96453ad1a6 100644 --- a/app/views/products/root.html.erb +++ b/app/views/products/root.html.erb @@ -6,7 +6,7 @@ <% if !@staff_picks.nil? %> <% @staff_picks.each do |p| %>
    - <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %> + <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>

    <%= link_to p.name.capitalize, product_path(p.id) %>

    $<%= format_price(p.price) %>

    @@ -22,9 +22,9 @@
  • <% @top_rated.each do |p| %>
    - <%= image_tag p.photo_url, alt:"product image" unless p.photo_url.blank? %> + <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>

    <%= link_to p.name.capitalize, product_path(p.id) %>

    -

    $<%= format_price(p.price) %>

    +

    Average rating: <%= p.average_rating.round(1) %>

    <%end%>
  • From 6017ee5aed583da20f44700d2cb09eba7e966f8d Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 15:14:20 -0700 Subject: [PATCH 226/283] small style change --- app/assets/stylesheets/application.css | 5 +++++ app/views/products/index.html.erb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 729a9fcfc6..72466035da 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -135,6 +135,11 @@ img:hover { color: #43ECAE; } +a:hover { + color: #8467E7; +} + + .merchant-options { text-align: center; diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 4a84c47d47..d87e54c59d 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -19,7 +19,7 @@
    <%= link_to product_path(p.id) do %> <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %> -

    <%= p.name.capitalize %>

    +

    <%= link_to p.name.capitalize, product_path(p.id) %>

    $<%= format_price(p.price) %>

    <% end %>
    From ce0687c511a1ab6c07ffa5c7f902bfad0ba0f48b Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 26 Apr 2018 15:17:26 -0700 Subject: [PATCH 227/283] Add $ to price --- app/views/merchants/account_page.html.erb | 10 +++++----- app/views/orders/index.html.erb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index 614150169d..4fb0d9b5bc 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -25,23 +25,23 @@
    - + - + - + - + - +
    <%= product.name %><%= link_to product.name, product_path(product.id) %> <%= product.price %> <%= product.inventory %> <%= product.product_active == true ? "Active" : "Retired" %>
    Total Revenue for Pending Orders: <%= "#{format_price(@pending_totals.inject(0){|sum,x| sum + x })}" %><%= "$#{format_price(@pending_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Paid Orders: <%= "#{format_price(@paid_totals.inject(0){|sum,x| sum + x })}" %><%= "$#{format_price(@paid_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Cancelled Orders: <%= "#{format_price(@cancelled_totals.inject(0){|sum,x| sum + x })}" %><%= "$#{format_price(@cancelled_totals.inject(0){|sum,x| sum + x })}" %>
    Total Revenue for Shipped Orders: <%= "#{format_price(@shipped_totals.inject(0){|sum,x| sum + x })}" %><%= "$#{format_price(@shipped_totals.inject(0){|sum,x| sum + x })}" %>
    Total Net Revenue: <%= "#{format_price(@total_net_revenue.inject(0){|sum,x| sum + x })}" %><%= "$#{format_price(@total_net_revenue.inject(0){|sum,x| sum + x })}" %>
    diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb index b82985e22c..083c2c799d 100644 --- a/app/views/orders/index.html.erb +++ b/app/views/orders/index.html.erb @@ -40,7 +40,7 @@ Total: - <%= "#{format_price(@current_cart.calculate_total)}" %> + <%= "$#{format_price(@current_cart.calculate_total)}" %> <%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> From 8df9fbf3c8e2daf05bf1b243a013ba36d1cec514 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 15:18:28 -0700 Subject: [PATCH 228/283] updated all flash messages in controllers to match through app, and first attempt to order_product controller tests --- app/controllers/order_products_controller.rb | 2 ++ app/controllers/reviews_controller.rb | 4 ++-- app/controllers/sessions_controller.rb | 3 +-- .../controllers/order_products_controller_test.rb | 15 ++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/order_products_controller.rb b/app/controllers/order_products_controller.rb index dbaa0c7d00..d8fa65ee31 100644 --- a/app/controllers/order_products_controller.rb +++ b/app/controllers/order_products_controller.rb @@ -1,3 +1,4 @@ + class OrderProductsController < ApplicationController before_action :require_login, only: [:update] @@ -25,6 +26,7 @@ def destroy if @current_cart.order_products.include?(order_product) quantity = order_product.quantity product.inventory += quantity + if product.save && order_product.destroy flash[:success] = "Successfully removed from Cart" else diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index 401b32804d..4ca00da8c9 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -8,13 +8,13 @@ def create @review = Review.new(review_params) @review.product = Product.find(params[:product_id]) if @current_merchant == @review.product.merchant - flash[:message] = "You cannot review your own products" + flash[:alert] = "You cannot review your own products" redirect_to product_path(@review.product) elsif @review.save flash[:success] = "Thanks for your review!" redirect_to product_path(@review.product) else - flash.now[:alert] = @review.errors + flash.now[:error] = @review.errors render :new end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index a3db292c07..b2ec2ff0fd 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -30,8 +30,7 @@ def login def logout session[:merchant_id] = nil - flash[:status] = :success - flash[:result_text] = "Successfully logged out" + flash[:success] = "Successfully logged out" redirect_to root_path end end diff --git a/test/controllers/order_products_controller_test.rb b/test/controllers/order_products_controller_test.rb index 7ea8f10cf4..32e97990fe 100644 --- a/test/controllers/order_products_controller_test.rb +++ b/test/controllers/order_products_controller_test.rb @@ -14,9 +14,6 @@ updated_order_product.status.must_equal "shipped" must_respond_with :redirect must_redirect_to order_fulfillment_path - - # why you no work!!!! - # grrrr...... not passing end it "redirects to root page if no merchant is logged in" do @@ -53,21 +50,25 @@ updated_order_product.status.must_equal "paid" must_respond_with :redirect must_redirect_to order_fulfillment_path - - # currently not passing for the right reasons end end describe "destroy" do - let(:order_product_2) { order_products(:order_05) } it "redirects to cart and successfully destroy order_product record" do + product = products(:sage) + get add_to_order_path(product.id), params: { order_products: { inventory: 4 } } + + order = Order.last + new_order_product = order.order_products.first + # new_order_product = OrderProduct.find_by(order_id: cart.id) - proc { delete order_product_path(order_product_2.id), session: {order_id: orders(:order_one).id} }.must_change "OrderProduct.count", -1 + proc { delete order_product_path(new_order_product.id) }.must_change "OrderProduct.count", -1 must_respond_with :redirect must_redirect_to cart_path end it "redirects to cart and handles if order_product is invalid" do + get root_path proc { delete order_product_path(" ") }.wont_change "OrderProduct.count" must_respond_with :redirect From 344dc75ae18be743c090028765696e7452da7760 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 15:20:43 -0700 Subject: [PATCH 229/283] small cart message change --- app/assets/stylesheets/application.css | 4 ++-- app/views/orders/index.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 72466035da..2f22afb057 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -132,11 +132,11 @@ img:hover { } .button:hover { - color: #43ECAE; + color: #24AB82; } a:hover { - color: #8467E7; + color: #24AB82; } diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb index b82985e22c..b021651438 100644 --- a/app/views/orders/index.html.erb +++ b/app/views/orders/index.html.erb @@ -1,7 +1,7 @@

    Your Cart

    <% if @current_cart.order_products.empty? %> -

    Your Cart is Empty :P

    +

    Please add some items. You know that trust fund money is burning a hole in your pocket, afterall.

    <% else %> From a0a50abe2ae43bc3e1b1123d5916785210d47380 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 15:28:45 -0700 Subject: [PATCH 230/283] css --- app/assets/stylesheets/application.css | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 729a9fcfc6..155ad859e4 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -8,7 +8,7 @@ * 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. +* It is generally better to creaxte a new file per style scope. *= require normalize-rails * @@ -131,13 +131,24 @@ img:hover { border-radius: 5px; } +.merchant-options { + text-align: center; +} + .button:hover { color: #43ECAE; } + .merchant-options { + text-align: center; + } -.merchant-options { - text-align: center; +#footer { + border-top: solid thin; +} + +#find-order { + text-align: left; } .account-page { @@ -163,14 +174,6 @@ img:hover { flex-shrink: 0; } -#footer { - border-top: solid thin; -} - -#find-order { - text-align: left; -} - @media screen and (max-width: 1000px) { .grid-container { grid-template-columns: 1fr 1fr 1fr; @@ -181,19 +184,19 @@ img:hover { .grid-container { grid-template-columns: 1fr 1fr; } -} - -@media screen and (max-width: 600px) { - .grid-container { - grid-template-columns: 1fr; - } .show-container { flex-direction: column; justify-content: center; align-items: center; } +} +@media screen and (max-width: 600px) { + .grid-container { + grid-template-columns: 1fr; + } + .show-section2 { margin-left: 0px; } From 5868a749492cfca096e7d623575a92361409ac5c Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 15:29:09 -0700 Subject: [PATCH 231/283] adds price formatting to product mgr page --- app/views/merchants/products_manager.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index d129d02474..961cd657ab 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -28,7 +28,7 @@ <% @products.each do | product | %> - +
    <%= link_to product.name, product_path(product.id) %><%= product.price %>$<%= format_price(product.price) %> <%= product.inventory %> <%= product.product_active == true ? "Active" : "Retired" %> From 8eb19e49e7741b1a476df1a6b1dd8f05d1c82310 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 15:29:34 -0700 Subject: [PATCH 232/283] adds image links to root view --- app/views/products/root.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb index 96453ad1a6..98699179b5 100644 --- a/app/views/products/root.html.erb +++ b/app/views/products/root.html.erb @@ -6,7 +6,7 @@ <% if !@staff_picks.nil? %> <% @staff_picks.each do |p| %>
    - <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %> + <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>r

    <%= link_to p.name.capitalize, product_path(p.id) %>

    $<%= format_price(p.price) %>

    From d5f89f7921c02d7f24a94b700c71be7bd2109cb3 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 15:29:55 -0700 Subject: [PATCH 233/283] adds class to review section --- app/views/products/show.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index ac365ed983..05c0b2c818 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -29,7 +29,6 @@

    Reviews

    Average rating: - <% if @product.reviews.count == 0 %> No Reviews Yet @@ -38,7 +37,7 @@ <%= @product.average_rating %> <%end%>

    -
    +
    <% if @current_merchant != @product.merchant %>

    <%= link_to "Write a Review", new_product_review_path(@product.id), class: "button" %>

    <% end %> From 3d54a5f6c541b596d6b2bcada30e7a7c44c76100 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 16:01:51 -0700 Subject: [PATCH 234/283] updated csv files - fixed a couple of photos --- app/views/orders/index.html.erb | 2 +- db/seed-data/category-product-seeds.csv | 38 ++++++++++++++++++++++++- db/seed-data/category-seeds.csv | 6 ++-- db/seed-data/product-seeds.csv | 6 ++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb index 50c1e8e37f..b021651438 100644 --- a/app/views/orders/index.html.erb +++ b/app/views/orders/index.html.erb @@ -40,7 +40,7 @@
    Total: - <%= "$#{format_price(@current_cart.calculate_total)}" %> + <%= "#{format_price(@current_cart.calculate_total)}" %> <%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> diff --git a/db/seed-data/category-product-seeds.csv b/db/seed-data/category-product-seeds.csv index 3de56eff60..6eff3e18f3 100644 --- a/db/seed-data/category-product-seeds.csv +++ b/db/seed-data/category-product-seeds.csv @@ -1 +1,37 @@ -product_id,category_id 1,4 2,5 3,4 4,5 5,5 10,3 11,3 12,3 13,7 13,3 13,9 14,7 14,3 15,6 15,3 19,7 19,3 19,2 20,2 20,8 21,9 22,1 23,1 24,1 25,1 26,1 26,2 27,3 28,8 28,6 29,9 29,2 30,2 31,2 31,9 32,3 \ No newline at end of file +product_id,category_id +1,4 +2,5 +3,4 +4,5 +5,5 +10,3 +11,3 +12,3 +13,7 +13,3 +13,9 +14,7 +14,3 +15,6 +15,3 +19,7 +19,3 +19,2 +20,2 +20,8 +21,9 +22,1 +23,1 +24,1 +25,1 +26,1 +26,2 +27,3 +28,8 +28,6 +29,9 +29,2 +30,2 +31,2 +31,9 +32,9 \ No newline at end of file diff --git a/db/seed-data/category-seeds.csv b/db/seed-data/category-seeds.csv index 57a4dfb3a3..c3039f2d43 100644 --- a/db/seed-data/category-seeds.csv +++ b/db/seed-data/category-seeds.csv @@ -2,9 +2,9 @@ id,category_name 1,Clothing & Shoes 2,So Extra 3,Home -4,Food -5,Beverage +4,Edibles +5,Libations 6,Kitchen 7,Spiritual AF 8,You probably haven't heard of it -9,Health & Body \ No newline at end of file +9,Apothecary diff --git a/db/seed-data/product-seeds.csv b/db/seed-data/product-seeds.csv index cbb7dda219..70a9296987 100644 --- a/db/seed-data/product-seeds.csv +++ b/db/seed-data/product-seeds.csv @@ -3,7 +3,7 @@ id,name,price,inventory,description,product_active,merchant_id,photo_url 2,single-origin shade-grown fair-trade coffee,20,30,Mumblecore coloring book DIY YOLO chia farm-to-table leggings man bun glossier trust fund.,TRUE,4,https://i.imgur.com/BQZTfkj.jpg?2 3,kale chips,46,5,"Aesthetic snackwave sriracha sartorial, butcher microdosing vinyl four loko flannel green juice. ",TRUE,1,https://i.imgur.com/VaoLUUw.jpg?1 4,kombucha,39,31,"Subway tile hexagon letterpress austin cloud bread helvetica, cardigan single-origin coffee flannel squid master cleanse microdosing lo-fi.",TRUE,3,https://i.imgur.com/Xs4ZJ45.jpg?1 -5,PBR,10,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://i.imgur.com/PtojRUr.png +5,PBR,10,28,"Scourge scared, drowning helpless sheep at, terrifying and crazy gory. Flames at crazy slicing with murderer gore. Mental hospital sliced drowning. chainsaw dread full moon, pushed at alley bruises, children is knife. Willow trees undead wind, unknown ripped needles. Breathin.",TRUE,2,https://i.imgur.com/PtojRUr.png?1 6,bulletproof coffee,10,5,Hammock franzen pug ramps tbh. Bitters ugh tousled sartorial.,TRUE,1,https://i.imgur.com/9Buk6e4.jpg?1 7,turmeric latte,36,26,"Hell of keytar adaptogen, austin franzen pop-up kombucha fixie aesthetic glossier bushwick.",TRUE,4,https://i.imgur.com/39j8OSQ.jpg?1 8,wildcrafted mugwort tea,52,5,"Adaptogen banjo next level sartorial, tofu four loko mustache intelligentsia tumblr DIY shabby chic celiac. ",TRUE,2,https://i.imgur.com/pCVXDq4.jpg?1 @@ -11,10 +11,10 @@ id,name,price,inventory,description,product_active,merchant_id,photo_url 10,handcrafted artisan soy candle,12,3,Lomo food truck austin live-edge blog ugh. Meggings before they sold out chillwave tattooed chicharrones trust fund jean shorts.,TRUE,1,https://i.imgur.com/3NDAcqB.jpg?1 11,Himalayan salt lamp,22,34,"Mumblecore banh mi vape, butcher dreamcatcher coloring book af kale chips schlitz adaptogen paleo leggings messenger bag. Dark mutilation rotten, Blood hair raising or, blood i.",TRUE,2,https://i.imgur.com/DNC4VTY.png 12,essential oil aromatherapy diffuser,49,17,Skateboard normcore chicharrones disrupt farm-to-table sartorial 8-bit banh mi beard.,TRUE,3,https://i.imgur.com/svnw3Rk.png?1 -13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3,https://picsum.photos/200/?random +13,sage,43,14,"Mustache paleo sustainable green juice jianbing vegan plaid. Bushwick man bun poke pickled beard, williamsburg lumbersexual ramps succulents chicharrones. chainsaw knife crazed choking helpless. Creep cold graves, shadow non fear a, psychotic ashes ghost. Horror bowels exorcism grave cut, murderer creature ripped. Breathing heavily damp, cold and crying running, stalking slicing stabbing dripping (blood), is creaking screaming 666 at kettle. Bloodcurdling motionless murder, disturbing ominous runnin.",TRUE,3,https://i.imgur.com/mkOZfjk.jpg?1 14,palo santo,52,7,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral. ",TRUE,4,https://i.imgur.com/QObnGi2.png?2 15,mason jars,12,23,"Coloring book meditation ugh synth, hell of shaman palo santo raw denim selfies before they sold out tattooed air plant.",TRUE,1,https://i.imgur.com/rkY4Y0E.jpg?1 -,,,,,,, +34,Yoni Jade Egg,65,10,"Used by humans with vaginas to increase sexual energy and pleasure, this nephrite jade stone helps connect the second chakra (the heart) and yoni for optimal self-love and well being.",TRUE,4,placeholder.jpg 16,copper mule mug,20,32,"Chia 90's activated charcoal shabby chic twee seitan marfa vinyl tilde chambray yr cornhole street art pickled. bruises, children is knife. Horror bowels exorcism grave cut, murderer creature ripped. Blood guns bury scream, stab graveyard crazed dark crying. In the deranged Halloween slice. Buried non guts claw and creature hair-raising decapitated at est. Worms with guts ect. I.",TRUE,1,https://i.imgur.com/6NospY4.jpg?1 17,tiny house made from reclaimed wood,5000,22,Church-key chia meh tumblr franzen taiyaki unicorn chicharrones subway tile tousled.,TRUE,1,https://i.imgur.com/eTjwShw.jpg?1 18,charcoal toothpaste,52,24,"8-bit four loko green juice keffiyeh mixtape, etsy tofu palo santo normcore freegan copper mug squid viral.",TRUE,3,https://i.imgur.com/CRydqQ3.jpg?1 From 2fb96a0474c5294be47d050c8e76662b8c57e674 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 26 Apr 2018 16:04:12 -0700 Subject: [PATCH 235/283] temp comment out before_action for cart --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e4113261e1..ce7026eeee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,9 +1,9 @@ class ApplicationController < ActionController::Base - include ApplicationHelper + include ApplicationHelper protect_from_forgery with: :exception before_action :current_merchant - before_action :current_cart + # before_action :current_cart def require_login if !@current_merchant From 6ef00826a9f480c06b29bb07190440efd0444f99 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Thu, 26 Apr 2018 16:08:51 -0700 Subject: [PATCH 236/283] took out a random mistype --- app/views/products/root.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/root.html.erb b/app/views/products/root.html.erb index 98699179b5..96453ad1a6 100644 --- a/app/views/products/root.html.erb +++ b/app/views/products/root.html.erb @@ -6,7 +6,7 @@ <% if !@staff_picks.nil? %> <% @staff_picks.each do |p| %>
    - <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>r + <%= link_to image_tag(p.photo_url, :size => "300x300", alt:"product image"), product_path(p.id) unless p.photo_url.blank? %>

    <%= link_to p.name.capitalize, product_path(p.id) %>

    $<%= format_price(p.price) %>

    From 92e3d1923a972cb996797e25948b486f7fd7fecc Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Thu, 26 Apr 2018 16:12:22 -0700 Subject: [PATCH 237/283] require cart now --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce7026eeee..9ec686cf61 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :current_merchant - # before_action :current_cart + before_action :current_cart def require_login if !@current_merchant From 1edd8bed5f0cfc9598a42060ab3904755a092651 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 17:27:50 -0700 Subject: [PATCH 238/283] removes extraneous method from products controller --- app/models/product.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/product.rb b/app/models/product.rb index d837160bc7..0a38cc187e 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -19,14 +19,4 @@ def average_rating average = (total/num_of_ratings) return average end - - # def categories_attributes=(category_attributes) - # return if category_attributes.empty? - # category_attributes.values.each do |category_attribute| - # category = Category.find_or_create_by(category_attribute) - # self.categories << category - # end - # end - - end From 5980135cb1c57d4e37e7ffd440626c2317922ebb Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 19:22:27 -0700 Subject: [PATCH 239/283] fixes typo in pendingorder method --- app/models/order_product.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/order_product.rb b/app/models/order_product.rb index b138f039e8..56822f6539 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -16,7 +16,7 @@ def calculate_cost end def pending_order? - return self.status == "paid" + return self.status == "paid" end end From 110b1fdb4d7a5cabd4c85a8713758005934c936f Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 19:23:04 -0700 Subject: [PATCH 240/283] adds rounding to product show page ave rating --- app/views/products/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb index 05c0b2c818..59de36cd3e 100644 --- a/app/views/products/show.html.erb +++ b/app/views/products/show.html.erb @@ -34,7 +34,7 @@ No Reviews Yet
    <%else%> - <%= @product.average_rating %> + <%= @product.average_rating.round(1) %> <%end%>

    From b4af717d5819e00a76a1392ad300bc95df6f70ee Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 19:24:39 -0700 Subject: [PATCH 241/283] adds tests for products#add_to_order. all but two tests passing --- test/controllers/products_controller_test.rb | 93 ++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index c11e1e8d27..268ab99f8e 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -5,6 +5,7 @@ let(:sage) { products(:sage) } let(:clothes) { categories(:clothes) } let(:ange) { merchants(:ange) } + let(:kat) { merchants(:kat) } let(:user) { merchants(:user) } let(:nora) { merchants(:nora) } let(:hoodie) { products(:hoodie) } @@ -203,4 +204,96 @@ must_respond_with :not_found end end + + describe "add to order" do + it "succeeds for extant, in-stock product" do + product = Product.find_by(name: "kale chips") + proc { + get add_to_order_path(product.id), params: { + order_products: { + inventory: 3 + } + } + }.must_change 'OrderProduct.count', 1 + product = Product.find_by(name: "kale chips") + product.inventory.must_equal 31 + order_product = OrderProduct.last + order_product.status.must_equal "pending" + order = Order.last + order.order_products.last.quantity.must_equal 3 + must_respond_with :redirect + must_redirect_to product_path(product.id) + end + + + it "fails for a non-existant product" do + kalechips = Product.find_by(name: "kale chips") + kalechips.id = 78 + proc { + get add_to_order_path(kalechips.id), params: { + order_products: { + inventory: 6 + } + } + }.wont_change 'OrderProduct.count' + end + + it "fails for a request that is greater than the inventory available" do + chemex = Product.find_by(name: "chemex") + proc { + get add_to_order_path(chemex.id), params: { + order_products: { + inventory: 87 + } + } + }.wont_change 'OrderProduct.count' + end + + it "fails for a request to add 0 products to cart" do + chemex = Product.find_by(name: "chemex") + proc { + get add_to_order_path(chemex.id), params: { + order_products: { + inventory: 0 + } + } + }.wont_change 'OrderProduct.count' + end + + it "does not allow merchant to add her own products to cart" do + login(kat) + chemex = Product.find_by(name: "chemex") + proc { + get add_to_order_path(chemex.id), params: { + order_products: { + inventory: 5 + } + } + }.wont_change 'OrderProduct.count' + end + + it "fails when product status is retired" do + kombucha = Product.find_by(name: "kombucha") + kombucha.product_active = false + proc { + get add_to_order_path(kombucha.id), params: { + order_products: { + inventory: 9 + } + } + }.wont_change 'OrderProduct.count' + end + + it "fails when product is out of stock" do + kombucha = Product.find_by(name: "kombucha") + kombucha.inventory = 0 + proc { + get add_to_order_path(kombucha.id), params: { + order_products: { + inventory: 9 + } + } + }.wont_change 'OrderProduct.count' + end + end end From c3c1000bd4b9d3753dcefd05dc0c5e1e4ef0459f Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 19:52:22 -0700 Subject: [PATCH 242/283] finished refactor for orders controller and corresponding tests for actions show, update, checkout, paid --- app/controllers/orders_controller.rb | 66 ++++--- test/controllers/orders_controller_test.rb | 214 +++++++++++++++++++-- test/fixtures/orders.yml | 2 +- 3 files changed, 238 insertions(+), 44 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 853b2a4416..ac6012d374 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -13,42 +13,58 @@ def show def update #when dealing with cart before checkout order_product = OrderProduct.find_by(id: params[:order_product][:order_product_id]) - product = order_product.product - new_quantity = params[:order_product][:quantity] - inventory_difference = new_quantity.to_i - order_product.quantity - order_product.quantity = new_quantity - product.inventory -= inventory_difference - if order_product.save && product.save - flash[:success] = "Sucessfully updated quantity" + if !order_product.nil? + product = order_product.product + new_quantity = params[:order_product][:quantity].to_i + inventory_difference = new_quantity - order_product.quantity + order_product.quantity = new_quantity + product.inventory -= inventory_difference + if !(new_quantity > product.inventory) + if order_product.save && product.save + flash[:success] = "Successfully updated quantity" + else + flash[:alert] = "Unable to update quantity" + end + else + flash[:alert] = "Dee, is that you? You can't order more items than are available" + end else - flash[:alert] = "Unable to update quantity" + flash[:alert] = "Earth Creature, that doesn't exist" end redirect_to cart_path end def checkout #edit to enter billing info + order = Order.find_by(id: params[:id]) + if order.order_products.empty? + flash[:alert] = "Uhh.... Your cart is having existential crisis. It's empty" + redirect_to cart_path + end end def paid #submit after checkout - if @current_cart.update(billing_params) - @current_cart.order_products.each do |order_product| - order_product.update_attributes(status: "paid") - end - @current_cart.status = "paid" - if @current_cart.save - flash[:success] = "Order received! Thank you for your purchase." - session[:order_id] = Order.create.id - redirect_to order_path(@current_cart.id) + @order = Order.find_by(id: params[:id]) + if @order + if @order.update(billing_params) + @order.order_products.each do |order_product| + order_product.update_attributes(status: "paid") + end + @order.status = "paid" + if @order.save + flash[:success] = "Order received! Thank you for your purchase." + session[:order_id] = Order.create.id + redirect_to order_path(@order.id) + else + flash.now[:error] = @order.errors + render :checkout, status: :error + end else - flash.now[:error] = @current_cart.errors - render :checkout + flash[:alert] = "Insufficient funds. Go crowdfund for more" + render :checkout, status: :error end - elsif @current_cart.errors.any? - flash.now[:error] = @current_cart.errors - render :checkout else - flash[:alert] = "Something went wrong, and we couldn't process your order." - render :checkout + flash[:alert] = "Sorry. That order does not exist" + redirect_to root_path end end @@ -95,7 +111,7 @@ def billing_params :billing_num, :billing_exp, :billing_cvv, - :billing_zipcode + :billing_zipcode, ) end end diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 8d52b8fdd3..6feb8802c0 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -1,37 +1,215 @@ require "test_helper" +require "pry" describe OrdersController do let(:order_three) { orders(:order_three) } + describe "index" do + end + describe "show" do - it "show individual orders" do + it "sucessfully gets order show page" do get order_path(order_three.id) + must_respond_with :success end - end - it "should get create" do - skip - get orders_creat - value(response).must_be :success? + it "must redirect to enter_order path if order invalid" do + id = order_three.id + order_three.order_products.each { |order_product| order_product.destroy } + order_three.destroy + + get order_path(id) + + must_respond_with :redirect + must_redirect_to enter_order_path + end end - it "should get update" do - skip - get orders_update_url - value(response).must_be :success? + describe "update" do + it "successfully changes both an order_product and a product attribute" do + order = orders(:order_one) + order_product = order_products(:order_01) + patch order_path(order.id), params: { + order_product: { + order_product_id: order_product.id, + quantity: 2 + } + } + + updated_order_product = OrderProduct.find_by(id: order_product.id) + updated_product = Product.find_by(name: "kombucha") + + updated_order_product.quantity.must_equal 2 + updated_product.inventory.must_equal 30 + + must_respond_with :redirect + must_redirect_to cart_path + end + + it "doesn't save for bogus quantity (nil)" do + order = orders(:order_one) + order_product = order_products(:order_01) + patch order_path(order.id), params: { + order_product: { + order_product_id: order_product.id, + quantity: nil + } + } + + updated_order_product = OrderProduct.find_by(id: order_product.id) + updated_product = Product.find_by(name: "kombucha") + + updated_order_product.quantity.must_equal 1 + updated_product.inventory.must_equal 31 + + must_respond_with :redirect + must_redirect_to cart_path + end + + it "doesn't save if order_product doesn't exist" do + order = orders(:order_one) + order_product = order_products(:order_01) + id = order_product.id + order_product.destroy + + patch order_path(order.id), params: { + order_product: { + order_product_id: id, + quantity: 2 + } + } + + must_respond_with :redirect + must_redirect_to cart_path + end + + it "doesn't save if new quantity is greater than product inventory" do + order = orders(:order_one) + order_product = order_products(:order_01) + + patch order_path(order.id), params: { + order_product: { + order_product_id: order_product.id, + quantity: 100 + } + } + + updated_order_product = OrderProduct.find_by(id: order_product.id) + updated_product = Product.find_by(name: "kombucha") + + updated_order_product.quantity.must_equal 1 + updated_product.inventory.must_equal 31 + + must_respond_with :redirect + must_redirect_to cart_path + end + + it "doesn't save if new quantity is negative" do + # order = orders(:order_one) + # order_product = order_products(:order_01) + # + # patch order_path(order.id), params: { + # order_product: { + # order_product_id: order_product.id, + # quantity: 1-50 + # } + # } + # + # updated_order_product = OrderProduct.find_by(id: order_product.id) + # updated_product = Product.find_by(name: "kombucha") + # + # updated_order_product.quantity.must_equal 1 + # updated_product.inventory.must_equal 31 + # + # must_respond_with :redirect + # must_redirect_to cart_path + end + + it "doesn't save and destroys order_product if product has been retired" do + # extra edge case that hasn't been implemented + end + end - it "should get checkout" do - skip - get orders_checkout_url - value(response).must_be :success? + describe "checkout" do + it "successfully gets checkout form page" do + get checkout_path(orders(:order_one).id) + + must_respond_with :success + end + + it "redirects to cart if cart is empty" do + get checkout_path(orders(:order_five).id) + + must_respond_with :redirect + must_redirect_to cart_path + end end - it "should get paid" do - skip - get orders_paid_url - value(response).must_be :success? + describe "paid" do + it "successfully updates order with billing info and status to paid" do + order = Order.find_by(id: orders(:order_one).id) + + patch order_paid_path(order.id), params: { + order: { + billing_email: "sdkf@jsdk", + billing_address: "dsjfksdlfkdsfjskdfjksdjfk", + billing_name: "sdkfjkj sldkfjkdj slkdfjkdfj", + billing_num: "1234567890987654", + billing_exp: "12/12", + billing_cvv: 123, + billing_zipcode: 12345 + } + } + + updated_order = Order.find_by(id: orders(:order_one).id) + + updated_order.billing_email.must_equal "sdkf@jsdk" + updated_order.status.must_equal "paid" + must_respond_with :redirect + must_redirect_to order_path(order.id) + end + + it "fails to update with bogus billing data" do + order = Order.find_by(id: orders(:order_one).id) + + patch order_paid_path(order.id), params: { + order: { + billing_email: nil, + billing_address: "dsjfksdlfkdsfjskdfjksdjfk", + billing_name: "sdkfjkj sldkfjkdj slkdfjkdfj", + billing_num: "12345678909876", + billing_exp: "12/12", + billing_cvv: 123, + billing_zipcode: 1234567 + } + } + + must_respond_with :error + end + + it "should redirect to root page if order DNE" do + order = Order.find_by(id: orders(:order_one).id) + id = order.id + order.order_products.each { |order_product| order_product.destroy } + order.destroy + + patch order_paid_path(id), params: { + order: { + billing_email: "sdkf@jsdk", + billing_address: "dsjfksdlfkdsfjskdfjksdjfk", + billing_name: "sdkfjkj sldkfjkdj slkdfjkdfj", + billing_num: "1234567890987654", + billing_exp: "12/12", + billing_cvv: 123, + billing_zipcode: 00000 + } + } + + must_respond_with :redirect + must_redirect_to root_path + end end it "should get destroy" do diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index 6497442b74..a2d83e7283 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -1,7 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html order_one: - status: + status: billing_email: billing_address: billing_name: From 0b601bbb39b052313573c2e6ca6d986013adb84c Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Thu, 26 Apr 2018 20:59:12 -0700 Subject: [PATCH 243/283] all products controller tests passing --- test/controllers/products_controller_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 268ab99f8e..aaa7b6a8e4 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -7,6 +7,7 @@ let(:ange) { merchants(:ange) } let(:kat) { merchants(:kat) } let(:user) { merchants(:user) } + let(:mads) { merchants(:mads) } let(:nora) { merchants(:nora) } let(:hoodie) { products(:hoodie) } @@ -273,6 +274,7 @@ end it "fails when product status is retired" do + login(mads) kombucha = Product.find_by(name: "kombucha") kombucha.product_active = false proc { @@ -285,6 +287,7 @@ end it "fails when product is out of stock" do + login(mads) kombucha = Product.find_by(name: "kombucha") kombucha.inventory = 0 proc { @@ -296,4 +299,17 @@ }.wont_change 'OrderProduct.count' end end + + describe "product_status" do + it "updates a product's status" do + login(kat) + merchant = Merchant.find_by(username: "kat") + chemex = Product.find_by(name: "chemex") + patch product_status_path(merchant.id, chemex.id), params: { product_active: false } + + chemex = Product.find_by(name: "chemex") + + chemex.product_active.must_equal false + end + end end From c753f7c6578118adace14c340bd5ff2f7d907ac0 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 22:32:03 -0700 Subject: [PATCH 244/283] removed require 'pry' calls from controller tests to prevent potentially non-existent problems with heroku and added test to sessions controller --- test/controllers/categories_controller_test.rb | 1 - test/controllers/order_products_controller_test.rb | 1 - test/controllers/orders_controller_test.rb | 1 - test/controllers/sessions_controller_test.rb | 14 ++++++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb index 0751a8c3d5..0452bbe2c2 100644 --- a/test/controllers/categories_controller_test.rb +++ b/test/controllers/categories_controller_test.rb @@ -1,5 +1,4 @@ require "test_helper" -require "pry" describe CategoriesController do let(:category) { categories(:beverage) } let(:ange) { merchants(:ange) } diff --git a/test/controllers/order_products_controller_test.rb b/test/controllers/order_products_controller_test.rb index 32e97990fe..5ff7f35e17 100644 --- a/test/controllers/order_products_controller_test.rb +++ b/test/controllers/order_products_controller_test.rb @@ -1,5 +1,4 @@ require "test_helper" -require "pry" describe OrderProductsController do let(:mads) { merchants(:mads) } diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 6feb8802c0..cced3b1803 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -1,5 +1,4 @@ require "test_helper" -require "pry" describe OrdersController do let(:order_three) { orders(:order_three) } diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index b0dc8487dc..1eeda4aa96 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -55,6 +55,20 @@ must_redirect_to root_path end + + it "redirects to the root route and doesn't create new user if given invalid user data" do + bad_merchant = Merchant.new( + provider: 'github', + uid: nil, + username: 'new test merchant', + email: 'test@test.com' + ) + + proc { + login(bad_merchant) }.must_change 'Merchant.count', 0 + + must_redirect_to root_path + end end describe "logout" do From e1e2baa9044697b343c864e7df93e528f0f5afd7 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 23:15:42 -0700 Subject: [PATCH 245/283] update merchants test so they are getting >90% with SimpleCov --- test/controllers/merchants_controller_test.rb | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/controllers/merchants_controller_test.rb b/test/controllers/merchants_controller_test.rb index 72b2212daf..fcf242513d 100644 --- a/test/controllers/merchants_controller_test.rb +++ b/test/controllers/merchants_controller_test.rb @@ -2,9 +2,27 @@ describe MerchantsController do let(:meka) { merchants(:kat) } + let(:mads) { merchants(:mads) } describe 'account_page' do it 'successfully gets account_page view if merchant is logged in' do + login(mads) + + get account_page_path + + must_respond_with :success + end + + it 'successfully gets account_page if has products have no order_products' do + login(meka) + + get account_page_path + + must_respond_with :success + end + + it 'successfully gets account_page if has no products' do + meka.products.each { |product| product.destroy } login(meka) get account_page_path @@ -27,7 +45,7 @@ describe 'order_fulfillment' do it 'successfully gets order_fulfillment view if merchant is logged in' do - login(meka) + login(mads) get order_fulfillment_path @@ -35,11 +53,6 @@ end it 'successfully gets order_fulfillment view if merchant has no orders' do - meka.products.each do | product | - if !product.order_products.nil? - product.order_products.each { | order | order.destroy } - end - end login(meka) get order_fulfillment_path @@ -48,15 +61,15 @@ end it 'successfully gets filtered products_manager view if valid filter applied' do - login(meka) + login(mads) - get products_manager_path, params: { status: "paid" } + get products_manager_path, params: { status: "shipped" } must_respond_with :success end it 'successfully gets all products_manager view if invalid filter applied' do - login(meka) + login(mads) get products_manager_path, params: { status: "blah" } From bd970988386213bcee179898e0799627b9d34cba Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Thu, 26 Apr 2018 23:45:34 -0700 Subject: [PATCH 246/283] added tests for enter_order and find_order in the products controller and did a minor refactor to find_controller that may be unnecessary --- app/controllers/orders_controller.rb | 12 ++++---- test/controllers/orders_controller_test.rb | 35 +++++++++++++++++++--- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index ac6012d374..55a2413010 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -44,7 +44,7 @@ def checkout #edit to enter billing info def paid #submit after checkout @order = Order.find_by(id: params[:id]) - if @order + if @order && ( @order.status == "pending" || @order.status.nil? ) if @order.update(billing_params) @order.order_products.each do |order_product| order_product.update_attributes(status: "paid") @@ -58,12 +58,9 @@ def paid #submit after checkout flash.now[:error] = @order.errors render :checkout, status: :error end - else - flash[:alert] = "Insufficient funds. Go crowdfund for more" - render :checkout, status: :error end else - flash[:alert] = "Sorry. That order does not exist" + flash[:alert] = "Insufficient funds. Go crowdfund for more" redirect_to root_path end end @@ -91,13 +88,14 @@ def enter_order end def find_order - order = Order.find_by(id: (params[:order][:id]).to_i) + id = params[:order][:id].to_i + order = Order.find_by(id: id) if order flash[:success] = "Successfully found your Confirmation Order" redirect_to order_path(order.id) else flash[:alert] = "That Order does not exist" - render :enter_order + render :enter_order, status: :error end end diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index cced3b1803..dafb93453b 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -211,10 +211,37 @@ end end - it "should get destroy" do - skip - get orders_destroy_url - value(response).must_be :success? + describe "destroy" do + end + + describe "enter_order" do + it "successfully gets the enter order form" do + get enter_order_path + + must_respond_with :success + end + end + + describe "find_order" do + it "successfully finds and redirects to order's show view" do + order = Order.find_by(id: orders(:order_four).id) + + get find_order_path, params: { order: {id: "#{order.id}"} } + + must_respond_with :redirect + must_redirect_to order_path(order.id) + end + + it "successfully finds and redirects to order's show view" do + order = Order.find_by(id: orders(:order_four).id) + id = order.id + order.order_products.each { |order_product| order_product.destroy} + order.destroy + + get find_order_path, params: { order: {id: "#{id}"} } + + must_respond_with :error + end end end From f65a84e9f173ee1e7e79c6931fc8e404af182184 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 09:13:51 -0700 Subject: [PATCH 247/283] updated account page css - took out dotted border and now it reacts better to media queries --- app/assets/stylesheets/application.css | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index a17e9a01dd..e1a0b01aeb 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -156,14 +156,6 @@ a:hover { text-align: left; } -.account-page { - border: dotted; - margin-left: 500px; - margin-right: 500px; - padding-top: 50px; - padding-bottom: 50px; - border-radius: 20px; -} .show-container { display: flex; From e0492813b659d12d61ecb81789a89240e7a70295 Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 27 Apr 2018 09:29:11 -0700 Subject: [PATCH 248/283] account page styling --- app/assets/stylesheets/application.css | 26 ++++++++++++++++++++++- app/helpers/application_helper.rb | 1 - app/views/merchants/account_page.html.erb | 4 +++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index a17e9a01dd..5fa9d6c68f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -157,13 +157,37 @@ a:hover { } .account-page { + border: dotted; + margin-left: 300px; + margin-right: 300px; + padding-top: 50px; + padding-bottom: 50px; + + /* border-radius: 20px; */ +} + +#ul_top_hypers li { + display: inline; +} + +/* .order-fulfillment { + border: dotted; + margin-left: 300px; + margin-right: 300px; + padding-top: 50px; + padding-bottom: 50px; + + /* border-radius: 20px; */ +} */ + +/* .account-page { border: dotted; margin-left: 500px; margin-right: 500px; padding-top: 50px; padding-bottom: 50px; border-radius: 20px; -} +} */ .show-container { display: flex; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b543a0e45f..a6bfa0c727 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,5 +7,4 @@ def total def format_price(price) sprintf('%.2f', price) end - end diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index 4fb0d9b5bc..5accc49f77 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -1,7 +1,9 @@

    <%= @current_merchant.username%>'s Shop

    Account Options:

    -
    diff --git a/app/views/merchants/products_manager.html.erb b/app/views/merchants/products_manager.html.erb index 961cd657ab..e47d046e84 100644 --- a/app/views/merchants/products_manager.html.erb +++ b/app/views/merchants/products_manager.html.erb @@ -1,8 +1,6 @@ -

    Merchant: <%= @current_merchant.username%>

    +

    <%= @current_merchant.username.capitalize %>'s Products

    -

    Product Management:

    - -
      +
      • <%= link_to "Add a Product", new_merchant_product_path(@current_merchant.id), class: "button" %>
      • @@ -10,38 +8,44 @@ <%= link_to "Add a category", new_category_path, class: "button" %>
      +
    - - - - - - - - - - - - - - <% @products.each do | product | %> - - - - - - - - - <% end %> - -
    NamePriceInventoryStatusChange StatusEdit
    <%= link_to product.name, product_path(product.id) %>$<%= format_price(product.price) %><%= product.inventory %><%= product.product_active == true ? "Active" : "Retired" %> - <% if product.product_active == true %> - <%= link_to "Retire Product?", product_status_path(@current_merchant.id, product.id, product_active: false), method: :patch %> - <% else %> - <%= link_to "Activate Product?", product_status_path(@current_merchant.id, product.id, product_active: true), method: :patch %> - <% end %> - <%= link_to 'edit', edit_merchant_product_path(@current_merchant.id, product.id), class: 'product-link' %>
    +
    +
      +
    • + + + + + + + + + + + + + + <% @products.each do | product | %> + + + + + + + + + <% end %> + +
      NamePriceInventoryStatusChange StatusEdit
      <%= link_to product.name, product_path(product.id) %>$<%= format_price(product.price) %><%= product.inventory %><%= product.product_active == true ? "Active" : "Retired" %> + <% if product.product_active == true %> + <%= link_to "Mark Inactive", product_status_path(@current_merchant.id, product.id, product_active: false), method: :patch %> + <% else %> + <%= link_to "Activate Product", product_status_path(@current_merchant.id, product.id, product_active: true), method: :patch %> + <% end %> + <%= link_to 'edit', edit_merchant_product_path(@current_merchant.id, product.id), class: 'product-link' %>
      +
    • +
    From 05ebc80a7675d15ecfba115ae08cce5462494a28 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 12:21:29 -0700 Subject: [PATCH 262/283] adds validation to orders#destroy to check for nil order --- app/controllers/orders_controller.rb | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 55a2413010..a9cdfb1f5c 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -66,20 +66,27 @@ def paid #submit after checkout end def destroy #this clears the cart before order has gone into paid status + order = Order.find_by(id: params[:id]) count = 0 - orders_count = @current_cart.order_products.count - @current_cart.order_products.each do | order_product | - product = order_product.product - quantity = order_product.quantity - product.inventory += quantity - if product.save && order_product.destroy - count += 1 + if !order.nil? + orders_count = order.order_products.count + order.order_products.each do | order_product | + product = order_product.product + quantity = order_product.quantity + product.inventory += quantity + successful_destroy = order_product.destroy + successful_save = product.save + if successful_save && successful_destroy + count += 1 + end + end + if count == orders_count + flash[:success] = "Successfully emptied your Cart" + else + flash[:alert] = "Unable to empty your Cart at this time" end - end - if count == orders_count - flash[:success] = "Successfully emptied your Cart" else - flash[:alert] = "Unable to empty your Cart at this time" + flash[:alert] = "Umm that order doesn't exist bro." end redirect_to cart_path end From 18fbeff6a50b716227baa504002d576dab9c4b52 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 12:22:07 -0700 Subject: [PATCH 263/283] removes currentcart else condition in products#add_to_order --- app/controllers/products_controller.rb | 31 +++++++------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index d22ab6fe19..de5b968dd2 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -119,30 +119,15 @@ def add_to_order flash[:alert] = "That product is out of stock." render :show else - if @current_cart - @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: params[:order_products][:inventory], status: 'pending') - if @order_product.save - product.inventory -= params[:order_products][:inventory].to_i - product.save - flash[:success] = "Successfully added product to cart" - redirect_to product_path(product.id) - else - flash[:alert] = "Failed to add to cart" - render :show - end + @order_product = OrderProduct.new(order_id: @current_cart.id, product_id: product.id, quantity: params[:order_products][:inventory], status: 'pending') + if @order_product.save + product.inventory -= params[:order_products][:inventory].to_i + product.save + flash[:success] = "Successfully added product to cart" + redirect_to product_path(product.id) else - session[:order_id] = Order.create.id - @order_product = OrderProduct.new(order_id: session[:order_id], product_id: product.id, quantity: params[:order_products][:inventory], status: 'pending') - if @order_product.save - product.inventory -= params[:order_products][:inventory].to_i - product.save - flash[:success] = "Successfully added product to cart" - redirect_to product_path(product.id) - # redirect_to order_path(session[:order_id]) - else - flash[:alert] = "Failed to add to cart" - render :show - end + flash[:alert] = "Failed to add to cart" + render :show end end end From 72b30271fa6a5694450dfe1e5392e0ceea3e7242 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 12:23:16 -0700 Subject: [PATCH 264/283] adds tests for orders#destroy --- test/controllers/orders_controller_test.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb index 490ae22ebb..0af241c3c5 100644 --- a/test/controllers/orders_controller_test.rb +++ b/test/controllers/orders_controller_test.rb @@ -19,9 +19,6 @@ get cart_path must_respond_with :success end - - it "gets the cart associated with current logged-in user" do - end end describe "show" do @@ -230,6 +227,25 @@ end describe "destroy" do + let(:order) { orders(:order_one) } + + it "successfully clears the cart of order_products, increases inventory of associated products, and redirects to cart path" do + proc { delete order_path(order.id) }.must_change "OrderProduct.count", -2 + + must_respond_with :redirect + must_redirect_to cart_path + end + + it "succeeds if Order does not exist" do + id = order.id + order.order_products.each { |order_product| order_product.destroy } + order.destroy + + proc { delete order_path(order.id) }.wont_change "OrderProduct.count" + + must_respond_with :redirect + must_redirect_to cart_path + end end describe "enter_order" do From f3812f01c3d300eb5782673ec47c95c5eccb40fa Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 12:23:54 -0700 Subject: [PATCH 265/283] edits test for products#add_to_order --- test/controllers/products_controller_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index aaa7b6a8e4..3b3a480c9f 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -277,6 +277,7 @@ login(mads) kombucha = Product.find_by(name: "kombucha") kombucha.product_active = false + kombucha.save proc { get add_to_order_path(kombucha.id), params: { order_products: { @@ -287,13 +288,12 @@ end it "fails when product is out of stock" do - login(mads) - kombucha = Product.find_by(name: "kombucha") - kombucha.inventory = 0 + root_path + saltlamp = Product.find_by(name: "salt lamp") proc { - get add_to_order_path(kombucha.id), params: { + get add_to_order_path(saltlamp.id), params: { order_products: { - inventory: 9 + inventory: 5 } } }.wont_change 'OrderProduct.count' From 2af4a91e2810d089447d675c2df7d740f283ee44 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 12:24:23 -0700 Subject: [PATCH 266/283] changes inventory for salt lamp fixture to 0 --- test/fixtures/products.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index c9f89f96b4..832a687fc6 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -53,7 +53,7 @@ salt_lamp: price: 56 description: Typewriter la croix vape yr. Distillery venmo tousled, pour-over pop-up hexagon deep v green juice. product_active: true - inventory: 16 + inventory: 0 merchant: user photo_url: https://picsum.photos/200/?random From 5685701fbce6143ade677691fe13ca2895ca9b56 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 12:38:52 -0700 Subject: [PATCH 267/283] added about us page --- app/assets/stylesheets/application.css | 8 ++++++++ app/controllers/merchants_controller.rb | 6 +++++- app/views/layouts/application.html.erb | 2 +- app/views/merchants/about_us.html.erb | 27 +++++++++++++++++++++++++ config/routes.rb | 2 ++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 app/views/merchants/about_us.html.erb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 4f99e14a8b..683b10bf61 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -163,6 +163,11 @@ a:hover { } +.us-grid { + display: grid; + grid-template: 1fr 1fr / 1fr 1fr; + margin: 30px; +} #footer { @@ -189,6 +194,9 @@ a:hover { flex-shrink: 0; } + + + @media screen and (max-width: 1000px) { .grid-container { grid-template-columns: 1fr 1fr 1fr; diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index d706537eb8..33488b43b6 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,7 +1,7 @@ class MerchantsController < ApplicationController before_action :require_login - + def account_page @total_net_revenue = [] @@ -85,4 +85,8 @@ def order_fulfillment def products_manager @products = @current_merchant.products end + + def about_us + end + end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8bfb5cccd0..3d2b74f0d0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -88,7 +88,7 @@
    -

    <%= link_to "Homepage", root_path %> | <%= link_to "Find An Order", enter_order_path %> | <%= link_to "About Us", root_path %>

    +

    <%= link_to "Homepage", root_path %> | <%= link_to "Find An Order", enter_order_path %> | <%= link_to "About Us", about_us_path %>

    diff --git a/app/views/merchants/about_us.html.erb b/app/views/merchants/about_us.html.erb new file mode 100644 index 0000000000..c27a30fe54 --- /dev/null +++ b/app/views/merchants/about_us.html.erb @@ -0,0 +1,27 @@ +

    Meet the Team

    + + +
    +
      +
    • + <%= image_tag("https://i.imgur.com/9OwI2iL.jpg?3", :size => "300X300", alt:"mads") %> +

      Maddie

      +

      Spitfire lover. Check out their hella microbrewery mezcal. Runs a market for indie kimchi tacos. You probably haven't heard of them.

      +
    • +
    • + <%= image_tag("https://i.imgur.com/yHJVgIY.png?3", :size => "300X300", alt:"ange") %> +

      Angela

      +

      Runs a library for original wolves. Regular deep v liveblogger. Was into micro sriracha before it was cool. Sells original tech startups on Etsy. Built a next-level flat white app.

      +
    • +
    • + <%= image_tag("https://i.imgur.com/s3UcblY.jpg?2", :size => "300X300", alt:"nora") %> +

      Nora

      +

      Aspires to be a tactile designer. Check out their nonconforming coffee shop dragonfruit. Collector of church vapings from New York. Was into lo-fi bitters before it was cool.

      +
    • +
    • + <%= image_tag("https://i.imgur.com/9dGg4Ky.jpg?2", :size => "300X300", alt:"katie") %> +

      Katie

      +

      Built a waxed sushi burrito app. Regular salvia micro vlogger. Runs an Airbnb for bootstrapped listicles. Original gin sniffer for a record store.

      +
    • +
    +
    diff --git a/config/routes.rb b/config/routes.rb index ef2d4dcf22..e9ce0cfdf0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ get '/merchant/order_fulfillment', to: 'merchants#order_fulfillment', as: 'order_fulfillment' get '/merchant/products_manager', to: 'merchants#products_manager', as: 'products_manager' + get '/merchant/about_us', to: 'merchants#about_us', as: 'about_us' + get '/auth/failure', to: 'sessions#failure' resources :categories, only: [:new, :create] do From fb1108f4d79cc2f165694420b3f161af7e0de8aa Mon Sep 17 00:00:00 2001 From: Madaleine Shields Date: Fri, 27 Apr 2018 12:42:15 -0700 Subject: [PATCH 268/283] adjust views and logic for merchant page --- app/assets/stylesheets/application.css | 4 ---- app/controllers/merchants_controller.rb | 5 +---- app/views/merchants/account_page.html.erb | 4 ++-- app/views/orders/index.html.erb | 4 ---- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index b09b60cd27..b362d57495 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -205,10 +205,6 @@ table { border-collapse: separate; } -.titles { - border-bottom: solid thin; -} - .order-fulfillment { display: flex; justify-content: center; diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index d706537eb8..6aa29d6d70 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,7 +1,7 @@ class MerchantsController < ApplicationController before_action :require_login - + def account_page @total_net_revenue = [] @@ -24,7 +24,6 @@ def account_page @pending_totals << order_product.product.price end - @paid_totals = [] @paid_orders = @total_orders.select { |order| order.status == "paid" } @@ -50,8 +49,6 @@ def account_page end end - - def order_fulfillment @merchant_orders = [] @current_merchant.products.each do |product| diff --git a/app/views/merchants/account_page.html.erb b/app/views/merchants/account_page.html.erb index d9528eee2a..fd95306846 100644 --- a/app/views/merchants/account_page.html.erb +++ b/app/views/merchants/account_page.html.erb @@ -28,7 +28,7 @@ Total Revenue for Cancelled Orders: - <%= "$#{format_price(@cancelled_totals.inject(0){|sum,x| sum + x })}" %> + <%= "$#{format_price(0)}" %> Total Revenue for Shipped Orders: @@ -36,7 +36,7 @@ Total Net Revenue: - <%= "$#{format_price(@total_net_revenue.inject(0){|sum,x| sum + x })}" %> + <%= "$#{format_price(@total_net_revenue.inject(0){|sum,x| sum + x } - @cancelled_totals.inject(0){|sum,x| sum + x })}" %> diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb index c73214a279..3f363aa19b 100644 --- a/app/views/orders/index.html.erb +++ b/app/views/orders/index.html.erb @@ -1,5 +1,4 @@

    Your Cart

    - <% if @current_cart.order_products.empty? %>

    Please add some items. You know that trust fund money is burning a hole in your pocket, afterall.

    <% else %> @@ -14,7 +13,6 @@ Options - <% @current_cart.order_products.each do | order_product | %> <% product = order_product.product %> @@ -26,7 +24,6 @@ <%= form_for :order_product, url: order_path(@current_cart.id), method: :patch do |f| %> <%= f.hidden_field :order_product_id, value: order_product.id %> <%= f.select :quantity, (1..(order_product.product.inventory + order_product.quantity)), selected: order_product.quantity %> - <%= f.submit "Update Quantity", class: "button" %> <% end %> @@ -49,7 +46,6 @@ -
    • <%= link_to "Checkout", checkout_path(@current_cart.id), class: "button" %> From 39d96145fb7e964ed07770658d47a9c5cc40d310 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 12:44:49 -0700 Subject: [PATCH 269/283] about us change --- app/views/merchants/about_us.html.erb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/merchants/about_us.html.erb b/app/views/merchants/about_us.html.erb index c27a30fe54..a08954d079 100644 --- a/app/views/merchants/about_us.html.erb +++ b/app/views/merchants/about_us.html.erb @@ -4,23 +4,27 @@
      • +

        Maddie

        <%= image_tag("https://i.imgur.com/9OwI2iL.jpg?3", :size => "300X300", alt:"mads") %> -

        Maddie

        +

        Spitfire lover. Check out their hella microbrewery mezcal. Runs a market for indie kimchi tacos. You probably haven't heard of them.

      • +

        Angela

        <%= image_tag("https://i.imgur.com/yHJVgIY.png?3", :size => "300X300", alt:"ange") %> -

        Angela

        +

        Runs a library for original wolves. Regular deep v liveblogger. Was into micro sriracha before it was cool. Sells original tech startups on Etsy. Built a next-level flat white app.

      • +

        Nora

        <%= image_tag("https://i.imgur.com/s3UcblY.jpg?2", :size => "300X300", alt:"nora") %> -

        Nora

        +

        Aspires to be a tactile designer. Check out their nonconforming coffee shop dragonfruit. Collector of church vapings from New York. Was into lo-fi bitters before it was cool.

      • +

        Katie

        <%= image_tag("https://i.imgur.com/9dGg4Ky.jpg?2", :size => "300X300", alt:"katie") %> -

        Katie

        +

        Built a waxed sushi burrito app. Regular salvia micro vlogger. Runs an Airbnb for bootstrapped listicles. Original gin sniffer for a record store.

      From a7dfc8a5616383258ed3fdb64d0d4e193cda1a1a Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 12:54:58 -0700 Subject: [PATCH 270/283] more styling to about us page --- app/assets/stylesheets/application.css | 13 +++++++++++++ app/views/merchants/about_us.html.erb | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 1c8e6ba45d..4ee25e224f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -179,6 +179,13 @@ a:hover { margin: 30px; } +.us-box { + display: inline-block; + max-width: 400px; + min-width: 200px; + padding-bottom: 70px; +} + #footer { border-top: solid thin; @@ -281,6 +288,12 @@ margin: 6px; .show-section2 { margin-left: 0px; } + + .us-grid { + display: flex; + flex-direction: column; + + } } @media screen and (max-width: 800px) { diff --git a/app/views/merchants/about_us.html.erb b/app/views/merchants/about_us.html.erb index a08954d079..350c4e663d 100644 --- a/app/views/merchants/about_us.html.erb +++ b/app/views/merchants/about_us.html.erb @@ -3,25 +3,25 @@
        -
      • +
      • Maddie

        <%= image_tag("https://i.imgur.com/9OwI2iL.jpg?3", :size => "300X300", alt:"mads") %>

        Spitfire lover. Check out their hella microbrewery mezcal. Runs a market for indie kimchi tacos. You probably haven't heard of them.

      • -
      • +
      • Angela

        <%= image_tag("https://i.imgur.com/yHJVgIY.png?3", :size => "300X300", alt:"ange") %>

        Runs a library for original wolves. Regular deep v liveblogger. Was into micro sriracha before it was cool. Sells original tech startups on Etsy. Built a next-level flat white app.

      • -
      • +
      • Nora

        <%= image_tag("https://i.imgur.com/s3UcblY.jpg?2", :size => "300X300", alt:"nora") %>

        Aspires to be a tactile designer. Check out their nonconforming coffee shop dragonfruit. Collector of church vapings from New York. Was into lo-fi bitters before it was cool.

      • -
      • +
      • Katie

        <%= image_tag("https://i.imgur.com/9dGg4Ky.jpg?2", :size => "300X300", alt:"katie") %> From 97ee24460f7cd11e803ab7be47f1fa85f231f12d Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 12:59:25 -0700 Subject: [PATCH 271/283] added message about security onto checkout page --- app/views/orders/checkout.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/orders/checkout.html.erb b/app/views/orders/checkout.html.erb index 5a67a3bf1d..c70aa87a0c 100644 --- a/app/views/orders/checkout.html.erb +++ b/app/views/orders/checkout.html.erb @@ -1,5 +1,5 @@

        Checkout your Order:

        -

        Please fill out your billing info.

        +

        Please fill out your billing info. (Do not put real billing info onto our satire site, we care about your security.)

        <%= form_for @current_cart, url: url_for(controller: 'orders', action: 'paid') do |f| %> <%= f.label :billing_email, "Email" %> <%= f.text_field :billing_email %> From c94330535b625d59b8cf6afec6d8a9798e875869 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 13:06:02 -0700 Subject: [PATCH 272/283] fixed visibility of about us page --- app/controllers/merchants_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/merchants_controller.rb b/app/controllers/merchants_controller.rb index 3ddb2a435a..46f2ed3718 100644 --- a/app/controllers/merchants_controller.rb +++ b/app/controllers/merchants_controller.rb @@ -1,6 +1,6 @@ class MerchantsController < ApplicationController - before_action :require_login + before_action :require_login, except: [:about_us] def account_page @total_net_revenue = [] @@ -85,5 +85,5 @@ def products_manager def about_us end - + end From b5b7f713c47c14f6640100af44f9104ae3c88620 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 13:09:35 -0700 Subject: [PATCH 273/283] css clean up --- app/assets/stylesheets/application.css | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 4ee25e224f..7242232dd3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -266,6 +266,9 @@ margin: 6px; .grid-container { grid-template-columns: 1fr 1fr 1fr; } + .cart-bottom { + grid-template-columns: 1fr 1fr; + } } @media screen and (max-width: 800px) { @@ -278,6 +281,13 @@ margin: 6px; justify-content: center; align-items: center; } + .top-nav { + grid-template-rows: 2fr 1fr 1fr 1fr; + } + .top-nav li { + padding-left: 10px; + padding-right: 10px; + } } @media screen and (max-width: 600px) { @@ -295,19 +305,3 @@ margin: 6px; } } - -@media screen and (max-width: 800px) { - .top-nav { - grid-template-rows: 2fr 1fr 1fr 1fr; - } - .top-nav li { - padding-left: 10px; - padding-right: 10px; - } -} - -@media screen and (max-width: 1000px) { - .cart-bottom { - grid-template-columns: 1fr 1fr; - } -} From 98c5064abbe08a3ce8aeb6d361c56682686625b5 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 13:11:34 -0700 Subject: [PATCH 274/283] fixes indentation on dropdown menu ul --- app/assets/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index b09b60cd27..1eee0a996a 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -117,7 +117,7 @@ img:hover { margin-right: 2rem; } -.dropdown.menu li:nth-child(2) { +.dropdown.menu li { padding-left: 10px; } From e38be605d44ea122a545917ff66d0b4a0c8cdaa2 Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 27 Apr 2018 13:16:56 -0700 Subject: [PATCH 275/283] deleted unused method from merchant model --- app/models/merchant.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/models/merchant.rb b/app/models/merchant.rb index 68fb5e808c..896db13a84 100644 --- a/app/models/merchant.rb +++ b/app/models/merchant.rb @@ -9,12 +9,4 @@ def self.build_from_github(auth_hash) return Merchant.new(provider: auth_hash[:provider], uid: auth_hash[:uid], email: auth_hash[:info][:email], username: auth_hash[:info][:nickname]) end - def calculate_total - total = 0 - self.order_products.each do |order_product| - total += order_product.calculate_cost - end - total - end - end From ee51dc22f8f22cf61cd6a43806ed1dccbfd1883a Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 27 Apr 2018 13:17:56 -0700 Subject: [PATCH 276/283] added test for empty photo url submission in the product controller test for the create action --- test/controllers/products_controller_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 3b3a480c9f..c971e91aa4 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -121,6 +121,26 @@ must_redirect_to product_path(newproduct.id) end + it "creates a new product for logged-in merchant, with valid data and no photo" do + login(nora) + proc { + post merchant_products_path(nora.id), params: { + product: { + name: "newproduct", + price: 32.67, + description: "Super awesome new product", + inventory: 5, + photo_url: "" + + } + } + }.must_change 'Product.count', 1 + + newproduct = Product.find_by(name: "newproduct") + must_respond_with :redirect + must_redirect_to product_path(newproduct.id) + end + it "does not create a new product for logged-in merchant with bogus data" do login(nora) proc { From 65f1bfbff89b0eedb7e46f5b79f27780fa11feb6 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 13:19:17 -0700 Subject: [PATCH 277/283] changed path for editing an order will now redirect back to manage products page --- app/controllers/products_controller.rb | 2 +- test/controllers/products_controller_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index de5b968dd2..6e81b3a0b1 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -89,7 +89,7 @@ def update end if @product.update(product_params) flash[:success] = "Successfully updated your product: #{@product.name}" - redirect_to product_path(@product.id) + redirect_to products_manager_path else flash[:error] = @product.errors redirect_to edit_merchant_product_path(@current_merchant.id, @product.id) diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index 3b3a480c9f..98fbee67d0 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -175,6 +175,7 @@ updated_product.name.must_equal "blue hoodie" must_respond_with :redirect + must_redirect_to products_manager_path end it "fails for bogus data and an extant product ID and logged-in user" do From 0f4ae1a97b3230bee62dc19646ec0a2fbab101e2 Mon Sep 17 00:00:00 2001 From: AngelaPoland Date: Fri, 27 Apr 2018 13:27:25 -0700 Subject: [PATCH 278/283] updated dropdown padding so they are all even --- app/assets/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 7242232dd3..84c91aa88b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -117,7 +117,7 @@ img:hover { margin-right: 2rem; } -.dropdown.menu li:nth-child(2) { +.dropdown.menu li { padding-left: 10px; } From 6177baef161fbc08e684707f87e135213a9c5417 Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 13:39:14 -0700 Subject: [PATCH 279/283] adds tests for order model method calculate total --- test/models/order_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/models/order_test.rb b/test/models/order_test.rb index f727b15886..4af9d718ba 100644 --- a/test/models/order_test.rb +++ b/test/models/order_test.rb @@ -3,6 +3,7 @@ describe Order do let(:order) { Order.new } + let(:order_five) { orders(:order_five) } describe "validations" do it "must be valid" do @@ -26,4 +27,16 @@ order_five.valid?.must_equal false end end + + describe "calculate_total" do + let(:order_one) { orders(:order_one) } + + it "returns total cost of an order" do + order_one.calculate_total.must_equal 273 + end + + it "returns 0 when there are no order_products" do + order_five.calculate_total.must_equal 0 + end + end end From 88290aa62bcc6b0f2f32b4214f9037f3fccaba8e Mon Sep 17 00:00:00 2001 From: Nora Peters Date: Fri, 27 Apr 2018 13:49:29 -0700 Subject: [PATCH 280/283] styles grid for about us page --- app/assets/stylesheets/application.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 84c91aa88b..396fb2cf26 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -175,8 +175,11 @@ a:hover { .us-grid { display: grid; - grid-template: 1fr 1fr / 1fr 1fr; + grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); + /*grid-template: 1fr 1fr / 1fr 1fr;*/ margin: 30px; + grid-column-gap: 100px; + grid-row-gap: 25px; } .us-box { From acd03b4c52397c339cfb0da1a37e0f7a3aa3a65f Mon Sep 17 00:00:00 2001 From: Kaitlin Forsman Date: Fri, 27 Apr 2018 14:09:18 -0700 Subject: [PATCH 281/283] adjusted flash messages to have some kind of view --- app/assets/stylesheets/application.css | 20 +++++++++++++++ app/views/layouts/application.html.erb | 35 +++++++++++++++----------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 84c91aa88b..4979932f45 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -23,6 +23,26 @@ li { @include dropdown-style; } }*/ +.flash-container { + width: 100%; + color: white; + text-align: center; +} + +.flash-container > *:not(.error) { + background-color: #24AB82; + padding: 5px 0; +} + +.flash-container h4.error { + border-bottom: 1px solid DarkRed; +} + +.flash-container .error { + color: DarkRed; + background-color: white; +} + table { margin-left:auto; margin-right:auto; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3d2b74f0d0..ac1e86e866 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -37,27 +37,32 @@ + <% flash.each do | name, message | %> - <% if name == "error" %> -

        You're doing something wrong

        -
        - <% flash[:error].each do |field, error_messages| %> -
        <%= field.upcase %>
        - <% if error_messages.class == Array %> - <% error_messages.each do |error_message| %> -
        >> <%= error_message %>
        +
        + <% if name == "error" %> +

        You're doing something wrong

        +
        + <% flash[:error].each do |field, error_messages| %> +
        +
        <%= field.upcase %>
        + <% if error_messages.class == Array %> + <% error_messages.each do |error_message| %> +
        >> <%= error_message %>
        + <% end %> + <% else %> +
        >> <%= error_messages %>
        + <% end %> +
        <% end %> +
        <% else %> -
        >> <%= error_messages %>
        +

        <%= message %>

        <% end %> -
      • - <% end %> - - <% else %> -

        <%= message %>

        - <% end %> + <% end %> + <% unless controller_name == "merchants" || action_name == "new"|| action_name == "edit" || action_name == "checkout" || (controller_name != "products" && action_name == "index") %>