diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000..fa356bcc2f Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..2495c4b694 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# 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 +.env + +coverage/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..d606740546 --- /dev/null +++ b/Gemfile @@ -0,0 +1,79 @@ +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 + +gem 'foundation-rails' +gem 'autoprefixer-rails' + +# 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 +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] + # 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' + gem 'dotenv-rails' +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' + gem 'simplecov', require: false + +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..b9a50ab659 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,275 @@ +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) + autoprefixer-rails (8.3.0) + execjs + 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) + docile (1.1.5) + dotenv (2.3.0) + dotenv-rails (2.3.0) + dotenv (= 2.3.0) + 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) + sass (>= 3.3.0, < 3.5) + 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) + 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 + json (2.1.0) + jwt (1.5.6) + 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) + 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) + 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) + 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) + 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 + autoprefixer-rails + better_errors + binding_of_caller + byebug + capybara (~> 2.13) + dotenv-rails + foundation-rails + jbuilder (~> 2.5) + jquery-rails + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + normalize-rails + omniauth + omniauth-github + pg (>= 0.18, < 2.0) + pry-rails + puma (~> 3.7) + rails (~> 5.1.6) + sass-rails (~> 5.0) + selenium-webdriver + simplecov + 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/.DS_Store b/app/.DS_Store new file mode 100644 index 0000000000..6156fe7e3f Binary files /dev/null and b/app/.DS_Store differ diff --git a/app/assets/.DS_Store b/app/assets/.DS_Store new file mode 100644 index 0000000000..2b3c7042d6 Binary files /dev/null and b/app/assets/.DS_Store differ 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/.DS_Store b/app/assets/images/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/app/assets/images/.DS_Store differ diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/images/Bag-Dispenser.jpg b/app/assets/images/Bag-Dispenser.jpg new file mode 100644 index 0000000000..af59b909d3 Binary files /dev/null and b/app/assets/images/Bag-Dispenser.jpg differ diff --git a/app/assets/images/Bandana.jpg b/app/assets/images/Bandana.jpg new file mode 100644 index 0000000000..42ff088d4a Binary files /dev/null and b/app/assets/images/Bandana.jpg differ diff --git a/app/assets/images/Buffalo-Skull.jpg b/app/assets/images/Buffalo-Skull.jpg new file mode 100644 index 0000000000..76b50b1d19 Binary files /dev/null and b/app/assets/images/Buffalo-Skull.jpg differ diff --git a/app/assets/images/Cat-Bed.jpg b/app/assets/images/Cat-Bed.jpg new file mode 100644 index 0000000000..32fa6592db Binary files /dev/null and b/app/assets/images/Cat-Bed.jpg differ diff --git a/app/assets/images/Cat-Bow-Tie.jpg b/app/assets/images/Cat-Bow-Tie.jpg new file mode 100644 index 0000000000..a01861b70a Binary files /dev/null and b/app/assets/images/Cat-Bow-Tie.jpg differ diff --git a/app/assets/images/Cat-Brush.jpg b/app/assets/images/Cat-Brush.jpg new file mode 100644 index 0000000000..df144e2f8a Binary files /dev/null and b/app/assets/images/Cat-Brush.jpg differ diff --git a/app/assets/images/Cat-Can-Food.jpg b/app/assets/images/Cat-Can-Food.jpg new file mode 100644 index 0000000000..a0c48d791f Binary files /dev/null and b/app/assets/images/Cat-Can-Food.jpg differ diff --git a/app/assets/images/Cat-Dry-Food.jpg b/app/assets/images/Cat-Dry-Food.jpg new file mode 100644 index 0000000000..1b98512e32 Binary files /dev/null and b/app/assets/images/Cat-Dry-Food.jpg differ diff --git a/app/assets/images/Cat-Dry-Shampoo.jpg b/app/assets/images/Cat-Dry-Shampoo.jpg new file mode 100644 index 0000000000..aa0e878832 Binary files /dev/null and b/app/assets/images/Cat-Dry-Shampoo.jpg differ diff --git a/app/assets/images/Cat-Harness.jpg b/app/assets/images/Cat-Harness.jpg new file mode 100644 index 0000000000..d5335484b4 Binary files /dev/null and b/app/assets/images/Cat-Harness.jpg differ diff --git a/app/assets/images/Cat-Litter.jpg b/app/assets/images/Cat-Litter.jpg new file mode 100644 index 0000000000..535927ee35 Binary files /dev/null and b/app/assets/images/Cat-Litter.jpg differ diff --git a/app/assets/images/Cat-Shampoo.jpg b/app/assets/images/Cat-Shampoo.jpg new file mode 100644 index 0000000000..3dcaa9fae7 Binary files /dev/null and b/app/assets/images/Cat-Shampoo.jpg differ diff --git a/app/assets/images/Cat-Wet-Food.jpg b/app/assets/images/Cat-Wet-Food.jpg new file mode 100644 index 0000000000..cfad8b40f6 Binary files /dev/null and b/app/assets/images/Cat-Wet-Food.jpg differ diff --git a/app/assets/images/Cattree.jpg b/app/assets/images/Cattree.jpg new file mode 100644 index 0000000000..f3579b207b Binary files /dev/null and b/app/assets/images/Cattree.jpg differ diff --git a/app/assets/images/Chewsen.jpg b/app/assets/images/Chewsen.jpg new file mode 100644 index 0000000000..358b346f24 Binary files /dev/null and b/app/assets/images/Chewsen.jpg differ diff --git a/app/assets/images/Dog-Bed.jpg b/app/assets/images/Dog-Bed.jpg new file mode 100644 index 0000000000..a7b1f6342f Binary files /dev/null and b/app/assets/images/Dog-Bed.jpg differ diff --git a/app/assets/images/Dog-Brush.jpg b/app/assets/images/Dog-Brush.jpg new file mode 100644 index 0000000000..e9855bd613 Binary files /dev/null and b/app/assets/images/Dog-Brush.jpg differ diff --git a/app/assets/images/Dog-Dry-Food.jpg b/app/assets/images/Dog-Dry-Food.jpg new file mode 100644 index 0000000000..1462866155 Binary files /dev/null and b/app/assets/images/Dog-Dry-Food.jpg differ diff --git a/app/assets/images/Dog-Harness.jpg b/app/assets/images/Dog-Harness.jpg new file mode 100644 index 0000000000..1457e42c94 Binary files /dev/null and b/app/assets/images/Dog-Harness.jpg differ diff --git a/app/assets/images/Dog-Leash.jpg b/app/assets/images/Dog-Leash.jpg new file mode 100644 index 0000000000..5a9002c3b9 Binary files /dev/null and b/app/assets/images/Dog-Leash.jpg differ diff --git a/app/assets/images/Dog-Shampoo.jpg b/app/assets/images/Dog-Shampoo.jpg new file mode 100644 index 0000000000..b5b2050ea6 Binary files /dev/null and b/app/assets/images/Dog-Shampoo.jpg differ diff --git a/app/assets/images/Dog-Waste-Bags.jpg b/app/assets/images/Dog-Waste-Bags.jpg new file mode 100644 index 0000000000..0742daad55 Binary files /dev/null and b/app/assets/images/Dog-Waste-Bags.jpg differ diff --git a/app/assets/images/Dog-Wet-Food.jpg b/app/assets/images/Dog-Wet-Food.jpg new file mode 100644 index 0000000000..965abc5ef7 Binary files /dev/null and b/app/assets/images/Dog-Wet-Food.jpg differ diff --git a/app/assets/images/Fishbone-Bow-Tie.jpg b/app/assets/images/Fishbone-Bow-Tie.jpg new file mode 100644 index 0000000000..d8dc35c7ba Binary files /dev/null and b/app/assets/images/Fishbone-Bow-Tie.jpg differ diff --git a/app/assets/images/Heat-Lamp.jpg b/app/assets/images/Heat-Lamp.jpg new file mode 100644 index 0000000000..5775477bdf Binary files /dev/null and b/app/assets/images/Heat-Lamp.jpg differ diff --git a/app/assets/images/Hideaway.jpg b/app/assets/images/Hideaway.jpg new file mode 100644 index 0000000000..b1e6891ad6 Binary files /dev/null and b/app/assets/images/Hideaway.jpg differ diff --git a/app/assets/images/Jungle-Plant.jpg b/app/assets/images/Jungle-Plant.jpg new file mode 100644 index 0000000000..74891c78aa Binary files /dev/null and b/app/assets/images/Jungle-Plant.jpg differ diff --git a/app/assets/images/KONG.jpg b/app/assets/images/KONG.jpg new file mode 100644 index 0000000000..2f6c88abb4 Binary files /dev/null and b/app/assets/images/KONG.jpg differ diff --git a/app/assets/images/Laser.jpg b/app/assets/images/Laser.jpg new file mode 100644 index 0000000000..c2d6fab5c2 Binary files /dev/null and b/app/assets/images/Laser.jpg differ diff --git a/app/assets/images/Mices.jpg b/app/assets/images/Mices.jpg new file mode 100644 index 0000000000..d8882ac9a1 Binary files /dev/null and b/app/assets/images/Mices.jpg differ diff --git a/app/assets/images/Nail-Clipper.jpg b/app/assets/images/Nail-Clipper.jpg new file mode 100644 index 0000000000..3327a0ce7b Binary files /dev/null and b/app/assets/images/Nail-Clipper.jpg differ diff --git a/app/assets/images/Pads.jpg b/app/assets/images/Pads.jpg new file mode 100644 index 0000000000..ff1b249c4e Binary files /dev/null and b/app/assets/images/Pads.jpg differ diff --git a/app/assets/images/Pickles.jpg b/app/assets/images/Pickles.jpg new file mode 100644 index 0000000000..9b5ebae4f3 Binary files /dev/null and b/app/assets/images/Pickles.jpg differ diff --git a/app/assets/images/Plush-Vader.jpg b/app/assets/images/Plush-Vader.jpg new file mode 100644 index 0000000000..e38cb26346 Binary files /dev/null and b/app/assets/images/Plush-Vader.jpg differ diff --git a/app/assets/images/Rep-Bedding.jpg b/app/assets/images/Rep-Bedding.jpg new file mode 100644 index 0000000000..df88a250ef Binary files /dev/null and b/app/assets/images/Rep-Bedding.jpg differ diff --git a/app/assets/images/Rep-Clip.jpg b/app/assets/images/Rep-Clip.jpg new file mode 100644 index 0000000000..1a44e1f73b Binary files /dev/null and b/app/assets/images/Rep-Clip.jpg differ diff --git a/app/assets/images/Rep-Food.jpg b/app/assets/images/Rep-Food.jpg new file mode 100644 index 0000000000..0cc89a9854 Binary files /dev/null and b/app/assets/images/Rep-Food.jpg differ diff --git a/app/assets/images/Rep-Leash.jpg b/app/assets/images/Rep-Leash.jpg new file mode 100644 index 0000000000..d5af9a8bee Binary files /dev/null and b/app/assets/images/Rep-Leash.jpg differ diff --git a/app/assets/images/Rep-Veg-Food.jpg b/app/assets/images/Rep-Veg-Food.jpg new file mode 100644 index 0000000000..556aeb8c6e Binary files /dev/null and b/app/assets/images/Rep-Veg-Food.jpg differ diff --git a/app/assets/images/Skull-Hideaway.jpg b/app/assets/images/Skull-Hideaway.jpg new file mode 100644 index 0000000000..e5d62573ba Binary files /dev/null and b/app/assets/images/Skull-Hideaway.jpg differ diff --git a/app/assets/images/Teaser.jpg b/app/assets/images/Teaser.jpg new file mode 100644 index 0000000000..b84d2fcaae Binary files /dev/null and b/app/assets/images/Teaser.jpg differ diff --git a/app/assets/images/Teepee.jpg b/app/assets/images/Teepee.jpg new file mode 100644 index 0000000000..c0c8778bc4 Binary files /dev/null and b/app/assets/images/Teepee.jpg differ diff --git a/app/assets/images/Terrarium.jpg b/app/assets/images/Terrarium.jpg new file mode 100644 index 0000000000..77883a9b8e Binary files /dev/null and b/app/assets/images/Terrarium.jpg differ diff --git a/app/assets/images/Tug-Rope.jpg b/app/assets/images/Tug-Rope.jpg new file mode 100644 index 0000000000..39d1a25e3a Binary files /dev/null and b/app/assets/images/Tug-Rope.jpg differ diff --git a/app/assets/images/Tunnel.jpg b/app/assets/images/Tunnel.jpg new file mode 100644 index 0000000000..711e59428a Binary files /dev/null and b/app/assets/images/Tunnel.jpg differ diff --git a/app/assets/images/cat.jpg b/app/assets/images/cat.jpg new file mode 100644 index 0000000000..fbc900bf6f Binary files /dev/null and b/app/assets/images/cat.jpg differ diff --git a/app/assets/images/cat_home.jpg b/app/assets/images/cat_home.jpg new file mode 100644 index 0000000000..b6f62a7bc1 Binary files /dev/null and b/app/assets/images/cat_home.jpg differ diff --git a/app/assets/images/dog_home.jpg b/app/assets/images/dog_home.jpg new file mode 100644 index 0000000000..60591714b7 Binary files /dev/null and b/app/assets/images/dog_home.jpg differ diff --git a/app/assets/images/dog_shopping.jpg b/app/assets/images/dog_shopping.jpg new file mode 100644 index 0000000000..fa5b7080be Binary files /dev/null and b/app/assets/images/dog_shopping.jpg differ diff --git a/app/assets/images/download.jpg b/app/assets/images/download.jpg new file mode 100644 index 0000000000..2ff835f9a3 Binary files /dev/null and b/app/assets/images/download.jpg differ diff --git a/app/assets/images/pet_shopping.jpg b/app/assets/images/pet_shopping.jpg new file mode 100644 index 0000000000..88a2a93cfe Binary files /dev/null and b/app/assets/images/pet_shopping.jpg differ diff --git a/app/assets/images/reptile_home.jpg b/app/assets/images/reptile_home.jpg new file mode 100644 index 0000000000..df2c28454b Binary files /dev/null and b/app/assets/images/reptile_home.jpg differ diff --git a/app/assets/images/star.png b/app/assets/images/star.png new file mode 100644 index 0000000000..e2268755a8 Binary files /dev/null and b/app/assets/images/star.png differ 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/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/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/javascripts/mains.js b/app/assets/javascripts/mains.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/mains.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_items.js b/app/assets/javascripts/order_items.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/order_items.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/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/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/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/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/javascripts/users.js b/app/assets/javascripts/users.js new file mode 100644 index 0000000000..dee720facd --- /dev/null +++ b/app/assets/javascripts/users.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/_settings.scss b/app/assets/stylesheets/_settings.scss new file mode 100644 index 0000000000..b8c6fceddc --- /dev/null +++ b/app/assets/stylesheets/_settings.scss @@ -0,0 +1,868 @@ +// 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..90ab96a44a --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,137 @@ +/* +* 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 + +*/ + +.style-image { + + width: 25px; + height: 25px; +} + +.navbar { + overflow: hidden; + background-color: #0066cc; + font-family: Arial, Helvetica, sans-serif; +} + +.navbar a { + float: right; + font-size: 16px; + color: white; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +.dropdown { + float: right; + overflow: hidden; + font-size: 30px; +} + +.dropdown .dropbtn { + font-size: 16px; + border: none; + outline: none; + color: white; + padding: 14px 16px; + background-color: inherit; + font-family: inherit; + margin: 0; +} + +.navbar a:hover, .dropdown:hover .dropbtn { + /* background-color: lightgray; */ +} + +.dropdown-content { + display: none; + position: absolute; + background-color: #f9f9f9; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; +} + +.dropdown-content a { + float: none; + color: black; + padding: 12px 16px; + text-decoration: none; + display: block; + text-align: left; +} + +.dropdown-content a:hover { + background-color: #ddd; +} + +.dropdown:hover .dropdown-content { + display: block; +} + +.contact-footer-nav { + background-color: #bcd9e2; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + align-items: flex-start; + justify-content: center; + padding-top: 40px; + width: 100%; + margin-left: 0px; + margin-right: 0px; +} + +.contact-footer-nav div ul { + list-style-type: none; +} + +.contact-footer-nav div h3, .contact-footer-nav div ul li { + text-align: center; + display: flex; + justify-content: center; + padding: 0; + margin: 0; +} + +.contact-footer-nav div ul li { + margin-right: 35px; +} + +.contact-footer-nav div:last-child ul { + min-width: 50px; + min-height: 50px; + text-align: center; + display: flex; + justify-content: center; + flex-direction: row; +} + +.contact-footer-nav div:last-child ul li { + color: #fff; +} + + +.footer { + background-color: #0066cc; + font-family: Arial, Helvetica, sans-serif; + color: white; + padding: 14px 16px; + text-align: center; +} 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/categories.scss b/app/assets/stylesheets/categories.scss new file mode 100644 index 0000000000..79dada9aaf --- /dev/null +++ b/app/assets/stylesheets/categories.scss @@ -0,0 +1,15 @@ +// 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/ +.container-products li{ + display: flex; + flex-direction: column; + flex-wrap: wrap; + align-items:center; + list-style-type: none; +} + +.container{ + display: inline; + margin-left: 10%; +} 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/assets/stylesheets/mains.scss b/app/assets/stylesheets/mains.scss new file mode 100644 index 0000000000..4d707a641f --- /dev/null +++ b/app/assets/stylesheets/mains.scss @@ -0,0 +1,125 @@ +// Place all the styles related to the mains controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + + +.pictures { + border-radius: 70%; +} + +.homepage-picture { + margin-left: 10%; +} + +span { + padding-right: 5%; + color: #00cc66; + font-size: 30pt; +} + +.shop-now { + display: flex; +} + +.container { + display: flex; + align-items: center; + padding-top: 5%; + padding-left: 10%; +} + +.name { + font-size: 50pt; + color: red; +} + +#etsy { + color: green; +} + +.site-nav { + background-color: red; +} + + +.list { + list-style-type: none; + color: darkblue; + text-align: center; + border: lightblue 2px solid; + padding: 10px; + padding-left: 30px; + padding-right: 30px; +} + +.list a { + list-style-type: none; + color: black; +} + +.list a:hover { + color: blue; +} + +.pet-type { + display: flex; + flex-direction: row; + padding-top: 5%; + padding-left: 0px; + padding-right: 10%; +} + +.pet-name { + color: #ff6600; + padding-left: 10%; +} + +.main { + padding-bottom: 100px; + list-style-type: none; + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-around; +} + +.main-images { + position: relative; + height: 250px; + width: 250px; +} +// +// .main .main-images img { +// /* position: absolute; */ +// border-radius: 50%; +// border: #bcd9e2 3px solid; +// width: 250px; +// height: 250px; +// margin: 50px; +// } +// +// .main-images .center-image-title { +// position: absolute; +// border-radius: 50%; +// border: #bcd9e2 3px solid; +// margin: 50px; +// display: flex; +// align-items: center; +// justify-content: center; +// width: 250px; +// height: 250px; +// top: 0; +// bottom: 0; +// left: 0; +// right: 0; +// background: #F7B26E; +// color: #fff; +// visibility: hidden; +// opacity: 0; +// transition: opacity 1s, visibility 1s; +// } +// +// .main .main-images:hover .center-image-title { +// visibility: visible; +// opacity: 1; +// } diff --git a/app/assets/stylesheets/order_items.scss b/app/assets/stylesheets/order_items.scss new file mode 100644 index 0000000000..78be5d8800 --- /dev/null +++ b/app/assets/stylesheets/order_items.scss @@ -0,0 +1,9 @@ +// Place all the styles related to the OrderItems controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +section { + margin-left: 10%; + margin-right: 10%; + margin-top: 5%; + +} diff --git a/app/assets/stylesheets/orders.scss b/app/assets/stylesheets/orders.scss new file mode 100644 index 0000000000..8cce2fabb6 --- /dev/null +++ b/app/assets/stylesheets/orders.scss @@ -0,0 +1,9 @@ +// 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/ +h4{ + margin-left: 10%; + margin-right: 10%; + margin-top: 5%; + text-align: center; +} diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss new file mode 100644 index 0000000000..c004f22db8 --- /dev/null +++ b/app/assets/stylesheets/products.scss @@ -0,0 +1,36 @@ +// 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/ + + +#image-container.image{ + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + padding-right: 30px; + list-style-type: none; +} + +#image-container li{ + padding-right: 75px; +} + +.product-container{ + display: flex; + align-items: center; +} + +.container-products{ + display: flex; + flex-direction: column; + flex-wrap: wrap; + align-items:center; + padding-right: 10px; + padding-left: 10px; +} + +.container{ + display: inline; + margin-left: 10%; +} diff --git a/app/assets/stylesheets/reviews.scss b/app/assets/stylesheets/reviews.scss new file mode 100644 index 0000000000..11bbb12cd5 --- /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/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/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 0000000000..6de09c0fba --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,27 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +.merchants { + font-size: 30pt; + padding-left: 10%; + list-style-type: none; + +} + +.merchants .container li { + list-style-type: none; + font-size: 20px; + text-align: center; +} + +.small-container { + display: flex; + flex-direction:row; + justify-content:space-around; +} + +.links { + display: flex; + flex-direction:row; + justify-content:flex-start; +} 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..15911dd13e --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,22 @@ +class ApplicationController < ActionController::Base + protect_from_forgery with: :exception + + before_action :current_user + + def current_user + @login_user ||= User.find_by(id: session[:user_id]) if session[:user_id] + end + + def require_login + unless current_user + flash[:status] = :failure + flash[:result_text] = "You need to be logged in to do that" + redirect_back fallback_location: root_path + end + end + + def render_404 + render file: "/public/404.html", status: 404 + # raise ActionController::RoutingError.new('Not Found') + end +end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb new file mode 100644 index 0000000000..80a41ecda9 --- /dev/null +++ b/app/controllers/categories_controller.rb @@ -0,0 +1,29 @@ +class CategoriesController < ApplicationController + def index + @categories = Category.all + end + + def new + if current_user + @category = Category.new + else + flash[:status] = :failure + flash[:result_text] = "You need to be logged in to add a category" + redirect_to users_path + end + + end + + def create + @category = Category.new(category_params) + @category.save + redirect_to users_path + end + + private + def category_params + params.require(:category).permit(:name, product_ids:[]) + end + + +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/controllers/mains_controller.rb b/app/controllers/mains_controller.rb new file mode 100644 index 0000000000..e86fb89e8d --- /dev/null +++ b/app/controllers/mains_controller.rb @@ -0,0 +1,9 @@ +class MainsController < ApplicationController + + def index + @categories = Category.all + @cat_products = Product.cat + @dog_products = Product.dog + @reptile_products = Product.reptile + end +end diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb new file mode 100644 index 0000000000..115ad121d7 --- /dev/null +++ b/app/controllers/order_items_controller.rb @@ -0,0 +1,87 @@ +class OrderItemsController < ApplicationController + + def index + @order_items = OrderItem.where(order_id: session[:order_id]) + @order = Order.find_by(id: session[:order_id]) + end + + def new + @order_item = OrderItem.new(order_id: params[:order_id]) + end + + def create + # Step 1: Find or create an order + @order = Order.find_by(id: session[:order_id]) + + unless @order + @order = Order.new() + unless @order.save + flash[:status] = :failure + flash[:result_text] = "Didn't add to the cart" + flash[:messages] = @order.errors.messages + redirect_back fallback_location: root_path + return + end + session[:order_id] = @order.id + puts "created new order number #{@order.id}" + else + puts "Found order number #{@order.id}" + end + + # If we get here we're guaranteed to have an order + add_products_to_cart(@order) + + end + + def add_products_to_cart(order) + # Step 0: Get all the required info + product_id = order_item_params[:product_id] + quantity = order_item_params[:quantity] + + # Step 1: get an order item + # either pull an existing one for this product from the cart + # or, create a new one + @order_item = order.order_items.find_by(product_id: product_id) + if @order_item + @order_item.quantity += quantity.to_i + else + @order_item = order.order_items.new(order_item_params) + end + + # Step 2: save, report the result + if @order_item.save + + flash[:success] = "Product added successfully" + redirect_to order_items_path + else + flash[:failure] = "Didn't add to the cart" + redirect_to product_path(@order_item.product_id), status: :bad_request + end + end + + def update + @order_item = OrderItem.find_by(id: params[:id]) + @order_item.assign_attributes(order_item_params) + @order_item.save + redirect_to order_items_path + + end + + + def show + end + + def destroy + @order_item = OrderItem.find_by(id: params[:id]) + @order_item.destroy + flash[:status] = :success + flash[:result_text] = "Successfully deleted" + redirect_to order_items_path + end + + private + def order_item_params + return params.require(:order_item).permit(:quantity, :product_id) + end + +end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb new file mode 100644 index 0000000000..e14c378503 --- /dev/null +++ b/app/controllers/orders_controller.rb @@ -0,0 +1,78 @@ +class OrdersController < ApplicationController + before_action :find_order, only: [:show, :edit, :update] + before_action :current_user + + def index + + if session[:user_id] + @user = User.find(session[:user_id]) + if params[:user_id] + @orders = Order.all.where(id: params[:order_id]) + else + @orders = Order.all + end + + + else + @orders = Order.all + + end + end + + + + def new + @order = Order.new + # session[:order_id] = @order.id + end + + + def show + + end + + def update + @order = Order.find_by(id: params[:id]) + @order.assign_attributes(order_params) + # @order.status = "paid" + + if @order.save + @order.status = "paid" + @order.reduce_inventory + session[:order_id] = nil + + # if @order.save + flash[:success] = 'Your order has been placed' + redirect_to order_path + # end + else + flash.now[:status] = :failure + flash.now[:result_text] = "Please enter the Order details again" + flash.now[:messages] = @order.errors.messages + render :edit, status: :found + end + end + + def edit + if params[:id] + @order = Order.find_by(id: params[:id]) + else + @order.Order.new + end + end + + def destroy + end + + private + def order_params + return params.require(:order).permit(:status, :email, :mail_adr, :cc_name, :cc_num, :cc_exp, :cc_cvv, :bill_zip) + end + + def find_order + @order = Order.find_by(id: params[:id]) + render_404 unless @order + end + + +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 0000000000..b68cfa4a67 --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,98 @@ +class ProductsController < ApplicationController + before_action :find_product, only: [:show, :edit, :update, :destroy] + before_action :require_login, except: [:index, :show] + + def index + if params[:user_id] + @user = User.find(params[:user_id]) + @products = @user.products + # finds the products for specific user + else + @products = Product.all + end + end + + def new + @product = Product.new(user: @login_user) + end + + def create + @product = @login_user.products.new(product_params) + + # @product.user_id = @login_user.id + + if @product.save + flash[:status] = :success + flash[:result_text]= "Product added successfully" + redirect_to products_path + else + flash[:status] = :failure + flash[:result_text] = "Could not create a product" + render :new, status: :bad_request + end + end + + def show + @product = Product.find_by(id: params[:id]) + @review = Review.new(product: @product) + @order_item = OrderItem.new(product: @product, quantity: 1) + end + + def edit + if session[:user_id ] + if session[:user_id] != @product.user.id + flash[:status] = :failure + flash[:result_text] = "This isn't your product!" + redirect_to product_path(@product.id) + end + else + flash[:status] = :failure + flash[:result_text] = "You need to log in to edit!" + redirect_to product_path(@product.id) + end + end + + def update + if find_product && (@user.id != @product.user.id) + flash[:status] = :failure + flash[:result_text] = "Oops..This isn't your product!" + redirect_to product_path(@product.id) + else + # @product = Product.find_by(product_id) + + @product.update_attributes(product_params) + if @product.save + flash[:status] = :success + flash[:result_text] = "Successfully updated #{@product.name}!" + redirect_to product_path + else + flash.now[:status] = :error + flash.now[:result_text] = "#{@product.name} could not be updated" + render :edit, status: :bad_request + end + end + end + + def destroy + @product.destroy + redirect_to root_path + + end + + def reviews + @reviews = Review.all + # call method that takes average on all reviews + end + + + private + + def product_params + params.require(:product).permit(:name, :stock, :price, :description, :pet_type, :photo_url, category_ids: []) + end + + def find_product + @product = Product.find_by(id: params[:id]) + head :not_found unless @product + end +end diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb new file mode 100644 index 0000000000..7ae06fafc3 --- /dev/null +++ b/app/controllers/reviews_controller.rb @@ -0,0 +1,47 @@ +class ReviewsController < ApplicationController + + def new + @product = Product.find_by(id: params[:product_id]) + if current_user && session[:user_id] == @product.user_id + flash[:status] = :failure + flash[:result_text] = "Oops..You can't review your own product!" + redirect_to product_path(@product.id) + else + render_404 unless @product + @review = Review.new + end + end + + + + def create + @product = Product.find_by(id: params[:product_id]) + # @review = Review.new(review_params) + + if current_user && session[:user_id] == @product.user_id + flash[:status] = :failure + flash[:result_text] = "You can't review your own product" + redirect_to product_path(@product.id) + else + @review = Review.new(review_params) + @review.product = @product + + if @review.save + flash[:status] = :success + flash[:result_text] = "Successfully created review" + redirect_to product_path(@product) + else + flash[:status] = :failure + flash[:result_text] = "Could not create review" + flash[:messages] = @review.errors.messages + render :new, status: :bad_request + end + end + end + + private + def review_params + params.require(:review).permit(:rating, :comments, :product_id) + end + +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..166ef27f87 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,86 @@ +class SessionsController < ApplicationController + before_action :find_user, only: [:show, :index] + skip_before_action :current_user + + def index + # @user = User.find_by(id: params[:id]) + if current_user && session[:user_id] + @products_sold =[] + orders_paid= Order.where(status: "paid") + orders_paid.each do |po| + po.order_items.each do |op| + product = Product.find_by(id: op.product_id) + if product.user_id == @user.id + @products_sold << product + end + end + end + @total_revenue = 0 + @products_sold.each do |product| + @total_revenue += product.price + end + else + flash[:status] = :failure + flash[:result_text] = "You need to login in to see this page" + redirect_to user_path + end + end + + def new + @user = User.new + end + + def create + auth_hash = request.env['omniauth.auth'] + + if auth_hash['uid'] + @user = User.find_by(uid: auth_hash['uid'], provider: 'github') + + if @user.nil? + @user = User.info_from_github(auth_hash) + if @user.save + session[:user_id] = @user.id + flash[:success] = "Successfully created new user #{@user.username} with ID #{@user.id}" + + else + flash[:error] = "Could not log in" + flash[:messages] = @user.errors.messages + + end + else + session[:user_id] = @user.id + flash[:success] = "Successfully logged in #{@user.username} as existing user!" + + end + session[:user_id] = @user.id + + else + flash[:error] = "Could not authenticate user via Github" + + end + redirect_to root_path + end + + def logout + if session[:user_id] + session[:user_id] = nil + flash[:result_text] = "Successfully logged out" + redirect_to root_path + end + end + + + # def destroy + # session[:user_id] = nil + # flash[:success] = "Successfully logged out!" + # + # redirect_to root_path + # end + + private + def find_user + @user = User.find_by(id: params[:id]) + render_404 unless @user + end + +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000000..c25b7ea72f --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,55 @@ +class UsersController < ApplicationController + before_action :find_user, only: [:show, :edit] + before_action :current_user + + def index + @users = User.all + end + + def new + @user = User.new + end + + def create + @user = User.new(user_params) + if @user.save + flash[:status] = "success" + flash[:result_text] = "User added!" + redirect_to users_path + else + flash.now[:alert] = @user.errors + render :new + end + end + + def show + + @user = User.find_by(id: params[:id]) + head :not_found unless @user + + @products = @user.products + + end + + def edit + end + + def update + if @user.update(user_params) + flash[:status] = "success" + flash[:result_text] = "#{@user.username} updated!" + redirect_to user_path(params[:id]) + else + render :edit + end + end + + def user_params + return params.require(:user).permit(:username, :email) + end + + def find_user + @user = User.find_by(id: params[:id]) + render_404 unless @user + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000000..be6d627462 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,22 @@ +module ApplicationHelper + + def render_date(date) + date.strftime("%b %e, %Y") + end + + def format_price(price) + if price.nil? + price = 0 + end + + "$" + format("%.2f", price/100) + end + + def render_stars(value) + output = '' + if (1..5).include?(value.to_i) + value.to_i.times { output += image_tag("star.png", class: "style-image")} + end + output.html_safe + end +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/helpers/mains_helper.rb b/app/helpers/mains_helper.rb new file mode 100644 index 0000000000..b0bc382007 --- /dev/null +++ b/app/helpers/mains_helper.rb @@ -0,0 +1,2 @@ +module MainsHelper +end diff --git a/app/helpers/order_items_helper.rb b/app/helpers/order_items_helper.rb new file mode 100644 index 0000000000..e197528ae1 --- /dev/null +++ b/app/helpers/order_items_helper.rb @@ -0,0 +1,2 @@ +module OrderItemsHelper +end diff --git a/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/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/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/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/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 0000000000..2310a240d7 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +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/category.rb b/app/models/category.rb new file mode 100644 index 0000000000..3c3c624f58 --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,17 @@ +class Category < ApplicationRecord + has_and_belongs_to_many :products + + validates :name, presence: true, uniqueness: true + + def show_products + + products = self.products + + each_product = products.each do |item| + item + end + + return each_product + end + +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 0000000000..dc6bcf370c --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,40 @@ +class Order < ApplicationRecord + + STATUS = %w(pending paid complete cancelled) + + has_many :order_items, dependent: :destroy + + +with_options if: :checking_out? do |order| + order.validates :status, presence: true, inclusion: { in: STATUS } + order.validates :email, presence: true + order.validates :mail_adr, presence: true + order.validates :cc_name, presence: true + order.validates :cc_num, presence: true, numericality: {only_integer: true}, length: {is: 16} + order.validates :cc_exp, presence: true + order.validates :cc_cvv, presence: true, numericality: {only_integer: true}, length: {is: 3} + order.validates :bill_zip, presence: true, numericality: {only_integer: true} +end + + def checking_out? + self.status != "pending" + end + + + def total_sum + total = 0 + self.order_items.each do |item| + sub_total = item.sub_total + total += sub_total + end + return total + end + + def reduce_inventory + self.order_items.each do |item| + item.product.stock_reduction(item.quantity) + end + + end + +end diff --git a/app/models/order_item.rb b/app/models/order_item.rb new file mode 100644 index 0000000000..6272ed586a --- /dev/null +++ b/app/models/order_item.rb @@ -0,0 +1,33 @@ +class OrderItem < ApplicationRecord + belongs_to :product + belongs_to :order + + validates :quantity, presence: true, numericality: {only_integer: true, greater_than: 0} + validate :available? + validate :available_quantity + + def available? + product = self.product + if product.stock == 0 + errors.add(:stock, "out of stock") + end + end + + def available_quantity + quantity = self.quantity + if quantity > self. product.stock + errors.add(:stock, "is #{self.product.stock}") + end + end + + def sub_total + price = self.product.price + quantity = self.quantity + sub_total = price * quantity + + return sub_total + end + + + +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 0000000000..f95c3b1351 --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,68 @@ +class Product < ApplicationRecord + + has_many :order_items, dependent: :destroy + has_many :reviews, dependent: :destroy + belongs_to :user, optional: true + has_and_belongs_to_many :categories + + + validates :name, presence: true, uniqueness: true + validates :price, presence: true, numericality: {only_integer: true, greater_than: 0} + validates :stock, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 0} + + + def show_rating + @reviews = Review.all + + total = 0 + reviews = @reviews.where(product_id: self.id) + + return "No reviews" if reviews.count == 0 + + reviews.each do |review| + total += review.rating + end + + average = total/reviews.count + return average + end + + def self.by_pet_type + # {"cat"=>[product1]} + products_by_pets = {} + + Product.all.each do |product| + unless products_by_pets.key? product.pet_type + # that pet type is not already there + products_by_pets[product.pet_type] = [] + end + products_by_pets[product.pet_type] << product + end + + return products_by_pets + end + + def self.pet_type(type) + where(pet_type: type).limit(4) + end + + def self.cat + pet_type("cat") + end + + def self.dog + pet_type("dog") + end + + def self.reptile + pet_type("reptile") + end + + def stock_reduction(quantity) + stock = self.stock - quantity + self.update(stock: stock) + end + + + +end diff --git a/app/models/review.rb b/app/models/review.rb new file mode 100644 index 0000000000..6eebbd9cbd --- /dev/null +++ b/app/models/review.rb @@ -0,0 +1,11 @@ +class Review < ApplicationRecord + belongs_to :product + # TODO Does the thing below need a migration? + # counter_cache: :review_count + + + validates :rating, presence: true + + validates :rating, numericality: {only_integer: true, less_than_or_equal_to: 5, greater_than: 0} + +end diff --git a/app/models/shopping_cart.rb b/app/models/shopping_cart.rb new file mode 100644 index 0000000000..8d577a9607 --- /dev/null +++ b/app/models/shopping_cart.rb @@ -0,0 +1,4 @@ +class ShoppingCart < ApplicationRecord + # Our design didnt need it anymore + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000000..0ac8e15dd4 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,22 @@ +class User < ApplicationRecord + has_many :products + + validates :username, presence: true, uniqueness: true + validates :email, presence: true, uniqueness: true + + def self.info_from_github(auth_hash) + + user_data = { + uid: auth_hash[:uid], + username: auth_hash[:info][:nickname], + email: auth_hash[:info][:email], + provider: auth_hash[:provider]} + + @user = self.new(user_data) + @user.save + return @user + + end + + +end diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb new file mode 100644 index 0000000000..fe6d8c44cb --- /dev/null +++ b/app/views/categories/_form.html.erb @@ -0,0 +1,10 @@ +

Category Form Page

+ +<%= render partial: "layouts/error_messages", locals: { model: @category } %> + +<%= form_for @category do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + + <%= f.submit class: "button" %> +<% end %> diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb new file mode 100644 index 0000000000..f13be80895 --- /dev/null +++ b/app/views/categories/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Form

+ +<%= render partial: "form" %> diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb new file mode 100644 index 0000000000..a9dde9f4f3 --- /dev/null +++ b/app/views/categories/index.html.erb @@ -0,0 +1,35 @@ +
+

Categories

+
+ <% @categories.each do |category| %> + <%= category.name%> + <% end %> +
+ + <% @categories.each do |category| %> +

<%= category.name%>

+
+
+
  • + <% category.products.each do |product| %> +
      +
    • + <%=image_tag product.photo_url unless product.photo_url.blank?%> +
    • +
    • + <%= link_to product.name, product_path(product) %> +
    • +
    • + <%= format_price(product.price) %> +
    • +
    • + <%= product.description %> +
    • +
    + <% end %> +
  • +
    + + <% end %> + +
    diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb new file mode 100644 index 0000000000..9b6b46dcb9 --- /dev/null +++ b/app/views/categories/new.html.erb @@ -0,0 +1,2 @@ + +<%= render partial: "form", locals: { model: @category, page_title: "Create a category" } %> diff --git a/app/views/layouts/_error_messages.html.erb b/app/views/layouts/_error_messages.html.erb new file mode 100644 index 0000000000..22c41f2220 --- /dev/null +++ b/app/views/layouts/_error_messages.html.erb @@ -0,0 +1,17 @@ +<% unless !model %> +<% if model.errors.messages.any? %> +
    +

    There were some problems

    + +
    +<% end %> +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000000..ff8a150d65 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,133 @@ + + + + + + + <%= content_for?(:title) ? yield(:title) : "pEtsy" %> + + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + + + + +<% if flash[:result_text] or flash[:messages] %> +
    +

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

    + <% if flash[:messages] %> + + <% end %> +
    +<% end %> + +
    + <%= 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/app/views/mains/index.html.erb b/app/views/mains/index.html.erb new file mode 100644 index 0000000000..cc2836da3a --- /dev/null +++ b/app/views/mains/index.html.erb @@ -0,0 +1,72 @@ +
    +
    + <%= image_tag "dog_shopping.jpg", width:"500", height:"500", class:"homepage-picture"%> + New Arrivals + <%= link_to "Shop Now", products_path, class:"button " %> +
    +
    +
    +
    +
    +

    + <%= image_tag "cat.jpg", class:"pictures"%> +

    +

    Cats

    +
    + +
      + <% @cat_products.each do |product| %> +
    • +
      + <%= link_to product.name, product_path(product) %> + <%= link_to( image_tag(product.photo_url), product_path(product)) unless product.photo_url.blank? %> + <%= format_price(product.price) %> +
      +
    • + <% end %> +
    +
    + +
    +
    +

    + <%= image_tag "dog_home.jpg", class:"pictures"%> +

    +

    Dogs

    +
    + +
      + <% @dog_products.each do |product| %> +
    • +
      + <%= link_to product.name, product_path(product) %> + <%= link_to( image_tag(product.photo_url), product_path(product)) unless product.photo_url.blank? %> + <%= format_price(product.price) %> +
      +
    • + <% end %> +
    +
    + +
    +
    +

    + <%= image_tag "reptile_home.jpg", class:"pictures"%> +

    +

    Reptile

    +
    + +
      + <% @reptile_products.each do |product| %> +
    • +
      + <%= link_to product.name, product_path(product) %> + <%= link_to( image_tag(product.photo_url), product_path(product)) unless product.photo_url.blank? %> + <%= format_price(product.price) %> +
      +
    • + <% end %> +
    +
    +
    +
    diff --git a/app/views/order_items/index.html.erb b/app/views/order_items/index.html.erb new file mode 100644 index 0000000000..cef88bd600 --- /dev/null +++ b/app/views/order_items/index.html.erb @@ -0,0 +1,43 @@ +
    + + <% if @order_items && @order_items.last %> +

    Your Shopping Cart

    + + + + + + + + + + + + + + <% @order_items.each do |item| %> + + + + + + + + <% end %> + + + +
    ProductDescriptionPriceQuantitySubtotal
    <%= link_to(item.product.name, product_path(item.product.id)) %><%= item.product.description %><%= format_price(item.product.price) %> <%= form_for item, url: order_item_path(item.id), method: :patch do |f| %> + <%= f.select :quantity, (1..item.product.stock).to_a, :selected => item.quantity %> + <%= f.submit "Update" %> + <% end %> + <%= format_price(item.sub_total) %><%= link_to "Remove", order_item_path(item.id), method: :delete, + data: { confirm: "Are you sure you want to delete #{item.product.name}?"}%>
    +

    Total: <%= format_price(@order.total_sum) %>

    + + <%= link_to "Place my order", edit_order_path(@order_items.last.order_id), class:"button" %> + + <% else %> +

    Your shopping cart is empty!

    + <%end%> +
    diff --git a/app/views/order_items/show.html.erb b/app/views/order_items/show.html.erb new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/app/views/order_items/show.html.erb @@ -0,0 +1 @@ + diff --git a/app/views/orders/_form.html.erb b/app/views/orders/_form.html.erb new file mode 100644 index 0000000000..1e8d0ad3f9 --- /dev/null +++ b/app/views/orders/_form.html.erb @@ -0,0 +1,32 @@ +
    + + <%= render partial: "layouts/error_messages", locals: { model: @category } %> + + + <%= form_for @order do |f| %> + <%= f.label :cc_name, "NAME" %> + <%= f.text_field :cc_name %> + + <%= f.label :mail_adr, "ADDRESS" %> + <%= f.text_field :mail_adr %> + + <%= f.label :email, "EMAIL" %> + <%= f.text_field :email %> + + <%= f.label :cc_num, "CREDIT CARD NUMBER" %> + <%= f.text_field :cc_num %> + + <%= f.label :cc_exp, "EXPIRATION DATE" %> + <%= f.text_field :cc_exp %> + + <%= f.label :cc_cvv, "CVV" %> + <%= f.text_area :cc_cvv %> + + <%= f.label :bill_zip, "BILLING ZIP CODE" %> + <%= f.text_area :bill_zip %> + + <%= f.hidden_field :status, value: "paid" %> + + <%= f.submit "Proceed to checkout" , class:"button"%> + <% end %> +
    diff --git a/app/views/orders/edit.html.erb b/app/views/orders/edit.html.erb new file mode 100644 index 0000000000..485a3f5c85 --- /dev/null +++ b/app/views/orders/edit.html.erb @@ -0,0 +1,5 @@ +

    CHECKOUT

    + +
    + <%= render partial: "form", locals: { action_name: "Proceed to checkout" } %> +
    diff --git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb new file mode 100644 index 0000000000..d90c8207b0 --- /dev/null +++ b/app/views/orders/index.html.erb @@ -0,0 +1,48 @@ +
    +

    Orders of all merchants

    +

    <%= link_to "Back to all merchants", users_path, class:"button"%>

    +

    <%= link_to("Continue Shopping", products_path, :class => "button") %> + + + + + + + + + + <% @orders.each do |order| %> + <% unless order.status == "pending" %> + + + + <% end %> + + <% end %> + +
    OrderStatusTotal
    <%= link_to "Order ##{order.id}", order_path(order.id) %>
    <%= order.status.capitalize %><%= format_price(order.total_sum) %>
    + +<% if @orders != "paid" %> + + + + + + + + + <% @orders.each do |order| %> + <% unless order.status == "paid" %> + + + + <% end %> + + <% end %> + +
    OrderStatusTotal
    <%= link_to "Order ##{order.id}", order_path(order.id) %>
    <%= order.status.capitalize %><%= format_price(order.total_sum) %>
    +<% else %> +

    You have no orders yet.

    +

    <%= link_to("Continue Shopping", new_product_path, :class => "button") %> +<% end %> +

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

    CHECKOUT

    + +
    + <%= render partial: "form", locals: { action_name: "COMPLETE ORDER" } %> +
    diff --git a/app/views/orders/show.html.erb b/app/views/orders/show.html.erb new file mode 100644 index 0000000000..434cf60532 --- /dev/null +++ b/app/views/orders/show.html.erb @@ -0,0 +1,40 @@ +
    +

    Thanks for your order!

    + +

    Order Total: <%=format_price(@order.total_sum) %>

    +

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

    +
    +

    Customer Information

    +
      +
    • Name: <%= @order.cc_name %>
    • +
    • Email: <%= @order.email %>
    • +
    • Credit Card: <%= " ************#{@order.cc_num[13]}#{@order.cc_num[14]}#{@order.cc_num[15]}"%>
    • +
    • Shipping Address: <%= @order.mail_adr %>
    • +
    • Order Status: <%= @order.status %>
    • +
    +
    +
    +

    Purchased Items

    + + + + + + + <% @order.order_items.each do |item| %> + + + + + + + <% end %> + +
    ProductQuantityPriceSubtotal
    <%= item.product.name%><%= item.quantity %><%= format_price(item.product.price) %><%= format_price(item.sub_total) %>
    + + + <% unless @order.status == "canceled"%> + <%= link_to "Cancel", order_path(@order.id), method: :patch, class: "button" %> + <% end %> +
    +
    diff --git a/app/views/products/_forms.html.erb b/app/views/products/_forms.html.erb new file mode 100644 index 0000000000..27f4b0593c --- /dev/null +++ b/app/views/products/_forms.html.erb @@ -0,0 +1,39 @@ +

    + <% page_title %> + <%= page_title %> +

    + +
    + + + <%= render partial: "layouts/error_messages", locals: { model: @product } %> + + <%= form_for @product do |f| %> + + <%= f.label :name %> + <%= f.text_field :name %> + + <%= f.label :stock %> + <%= f.number_field :stock %> + + <%= f.label :price %> + <%= f.number_field :price %> + + <%= f.label :description %> + <%= f.text_area :description %> + + <%= f.label :pet_type, "Pet Type" %> + <%= f.select :pet_type, ["dog", "cat", "reptile"] %> + + <%= f.label :photo_url, "Photo" %> + <%= f.text_field :photo_url %> + +
    + <%= f.label :categories %> + <%= collection_check_boxes(:product, :category_ids, Category.all, :id, :name) %> +
    + + + <%= f.submit class: "button" %> + <% end %> +
    diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb new file mode 100644 index 0000000000..51e051b983 --- /dev/null +++ b/app/views/products/edit.html.erb @@ -0,0 +1 @@ +<%= render partial: "forms", locals: { page_title: "Edit a product"} %> diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb new file mode 100644 index 0000000000..65ba19e8bd --- /dev/null +++ b/app/views/products/index.html.erb @@ -0,0 +1,43 @@ +
    +

    New Collection of Products

    + <%= link_to root_path %> +
      +
    • <%= image_tag "cat.jpg", width:"200", height:"400", class: "pictures" %>
    • +
    • <%= image_tag "dog_home.jpg", width:"200", height:"400", class:"pictures"%>
    • +
    • <%= image_tag "reptile_home.jpg", width:"200", height:"400", class:"pictures"%>
    • +
    +
    + +<% Product.by_pet_type.each do |pet_type, products| %> +<% if pet_type.nil? %> +

    NIL

    +<% else %> +

    <%= pet_type.capitalize %>

    +<% end %> +
    + <% products.each do |product| %> +
    +
    + <%= link_to( image_tag(product.photo_url), product_path(product)) unless product.photo_url.blank? %> +

    <%= link_to(product.name, product_path(product)) %>

    +

    <%= format_price(product.price) %>

    +

    <%= product.description %>

    +

    <%= product.stock %> Available

    + + +

    Rating: + <% if product.reviews.count == 0 %> + No reviews + <% else %> + <%= render_stars(product.show_rating) %> + <% end %> +

    +
    +
    +
    + + + +<% end %> +<% end %> + diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb new file mode 100644 index 0000000000..cf5f01667d --- /dev/null +++ b/app/views/products/new.html.erb @@ -0,0 +1 @@ +<%= render partial: "forms", locals: { page_title: "Create a new product"} %> diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb new file mode 100644 index 0000000000..70ebbec9de --- /dev/null +++ b/app/views/products/show.html.erb @@ -0,0 +1,54 @@ +
    + +

    Merchant: <%= link_to @product.user_id, user_path %>

    + +

    + <% @product.categories.each do |category| %> + +

    <%= category.name %>

    + + <% end %> +

    + +
    + <%=image_tag(@product.photo_url)%> +

    <%= @product.name %>

    +

    <%= format_price(@product.price) %>

    +

    <%= @product.description %>

    +

    <%= @product.stock %> Available

    + +

    +

    Product Reviews:
    +
      + <% if @product.reviews.count == 0 %> +
    • + <%= @product.show_rating %> +
    • + <% else %> + <% @product.reviews.each do |review| %> +
    • + <%= render_stars(review.rating) %> + <%= review.comments %> + <%= render_date(review.created_at) %> +
    • + <% end %> + <% end %> +
    +

    + + +

    + <%= form_for @order_item do |f| %> + <%= f.hidden_field :product_id %> + <%= f.label :quantity %> + <%= f.number_field :quantity %> + <%= f.submit "Add to cart" , class:"button"%> + <% end %> +

    + +
    + <%= render partial: "reviews/form", locals: { action_name: "Save My Review" } %> +
    + +
    +
    diff --git a/app/views/reviews/_form.html.erb b/app/views/reviews/_form.html.erb new file mode 100644 index 0000000000..918deea1f0 --- /dev/null +++ b/app/views/reviews/_form.html.erb @@ -0,0 +1,14 @@ +
    + + <%= form_for [@product, @review] do |f| %> + + <%= f.label :rating, "Rating (1-5)" %> + <%= f.number_field :rating %> + + <%= f.label :comments, "Comments" %> + <%= f.text_area :comments %> + + <%= f.submit action_name, class: "button" %> + <% end %> + +
    diff --git a/app/views/reviews/new.html.erb b/app/views/reviews/new.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb new file mode 100644 index 0000000000..022978a32d --- /dev/null +++ b/app/views/sessions/index.html.erb @@ -0,0 +1,39 @@ +
    + + <% if @user.id == @user.id %> +

    Welcome!

    + +

    <%= link_to "Back to User Summary", user_path, class:"button"%>

    + + <% end %> + + <% unless @total_revenue == 0 %> + + + + + + + + + <% @products_sold.each do |product| %> + + + + <% qty= 0 %> + <% @products_sold.each do |product| %> + <% qty += 1 if product.id == product.id %> + + + + <% end %> + + + + +
    ProductPriceQuantity SoldProduct Revenue
    <%= link_to product.name, product_path(product.id) %> <%= format_price(product.price) %> <%= qty %><%= format_price(qty * product.price)%>
    Total revenue: <%= format_price(@total_revenue) %>
    + <% else %> +

    No revenue.

    + <% end %> + +
    diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb new file mode 100644 index 0000000000..3e9655d270 --- /dev/null +++ b/app/views/sessions/show.html.erb @@ -0,0 +1,17 @@ +
    + + <%= render partial: "layouts/error_messages", locals: { model: @user } %> + +
    + + <%= form_for @user, url: login_path do |u| %> + <%= f.label :username %> + <%= f.text_field :username %> + + <%= f.submit "Login", class: "button" %> + <% end %> + +
    + + +
    diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 0000000000..cd3e093714 --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,46 @@ +
    +

    All Merchants:

    + + <% @users.each do |user| %> + + <%= link_to(user.username, user_path(user.id), alt: 'link to') %> + <%end%> +

    +

      + <% @users.each do |user| %> + + <%= link_to(user.username, user_path(user.id), alt: 'link to') %> +
      +
    • + <% user.products.each do |product| %> +
        +
        +
      • + <%= link_to( image_tag(product.photo_url), product_path(product)) unless product.photo_url.blank? %> +
      • +
      • + <%= link_to product.name, product_path(product) %> +
      • +
      • + <%= format_price(product.price) %> +
      • +
      • + <%= product.description %> +
      • +
      • + <% if product.reviews.count == 0 %> + No reviews + <% else %> + <%= render_stars(product.show_rating) %> + <% end %> +
      • +
        +
      + <% end %> +
    • +
      + <% end %> +
    +

    + +
    diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000000..33fb956095 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,45 @@ +
    +

    User Summary: <%= link_to @user.username, user_path(@user) %>

    +

    Joined site <%= render_date @user.created_at %>

    + + <%= render partial: "layouts/error_messages", locals: { model: @user } %> + + + + + +

    <%= "Products of #{@user.username}"%>

    + + + + + + + + + + + + + <% @user.products.each do |product| %> + + + + + + + + + + <% end %> + +
    NameStockPricePictureType
    <%= link_to product.name, product_path(product.id) %><%= product.stock %><%= format_price(product.price) %> + <%= link_to( image_tag(product.photo_url, width:"60", height:"50"), product_path(product)) unless product.photo_url.blank? %> + <%= product.pet_type%><%= link_to "Edit", edit_product_path(product.id) %>
    +
    diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000000..66e9889e8b --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..5badb2fde0 --- /dev/null +++ b/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..d87d5f5781 --- /dev/null +++ b/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..78c4e861dc --- /dev/null +++ b/bin/setup @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/spring b/bin/spring new file mode 100755 index 0000000000..fb2ec2ebb4 --- /dev/null +++ b/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/bin/update b/bin/update new file mode 100755 index 0000000000..a8e4462f20 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 0000000000..c2bacef836 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..f7ba0b527b --- /dev/null +++ b/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..5f6ca0f9b2 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,25 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Betsy + class Application < Rails::Application + config.generators do |g| + # Force new test files to be generated in the minitest-spec style + g.test_framework :minitest, spec: true + + # Always use .js files, never .coffee + g.javascript_engine :js + end + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000..30f5120df6 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..3cba994bb2 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 + channel_prefix: betsy_production diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000000..6903bb6083 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,85 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: betsy_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: betsy + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: betsy_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: betsy_production + username: betsy + password: <%= ENV['BETSY_DATABASE_PASSWORD'] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000000..426333bb46 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000000..5187e22186 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,54 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000000..9284f84839 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,91 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "betsy_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000000..8e5cbde533 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000000..89d2efab2b --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000000..4b828e80cb --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000000..59385cdf37 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000000..5a6a32d371 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000000..4a994e1e7b --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000000..ac033bf9dc --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000000..dc1899682b --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 0000000000..fd4416122a --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,3 @@ +Rails.application.config.middleware.use OmniAuth::Builder do + provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email" +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000000..bbfc3961bf --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..decc5a8573 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000000..1e19380dcb --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..3461e7137f --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,31 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + + root 'mains#index' + + get '/user/:id', to: 'sessions#index', as: 'user_profile' + + delete '/logout', to: 'sessions#logout', as: 'logout' + resources :order_items + + resources :mains, only: [:index] + + resources :categories, only: [:index, :new, :create] do + resources :products, only: [:index] + end + + resources :users do + resources :products, only: [:index] + end + + resources :orders + + resources :products do + resources :reviews, only: [:new, :create] + end + + + get "/auth/:provider/callback", to: "sessions#create", as: "auth_callback" + +end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000000..dc42500d6f --- /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: 5bc0d441f84843b1e1630c3069776c5c7df8ec601c28040ae4a3f60bf1bdcb2ff4855d063d580ff664b6eea6257c43adf195579cc9a299e739871c54b3ee5c97 + +test: + secret_key_base: 3b5eb0c26371d457be0fba27ec9e928322d5a00c9c778ca18bc39a509196ed0f6e2e649b57a587faf5b630ec663aeec5c587411fc1ab76e418e43b155b930d60 + +# 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/categories.csv b/db/categories.csv new file mode 100644 index 0000000000..28553da410 --- /dev/null +++ b/db/categories.csv @@ -0,0 +1,9 @@ +name +Home +Bedding +Health +Grooming +Toys +Training +Accessories +Food diff --git a/db/migrate/20180419210951_create_products.rb b/db/migrate/20180419210951_create_products.rb new file mode 100644 index 0000000000..d4682f63bd --- /dev/null +++ b/db/migrate/20180419210951_create_products.rb @@ -0,0 +1,8 @@ +class CreateProducts < ActiveRecord::Migration[5.1] + def change + create_table :products do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20180419211453_add_columns_to_products.rb b/db/migrate/20180419211453_add_columns_to_products.rb new file mode 100644 index 0000000000..0d5095bdcd --- /dev/null +++ b/db/migrate/20180419211453_add_columns_to_products.rb @@ -0,0 +1,8 @@ +class AddColumnsToProducts < ActiveRecord::Migration[5.1] + def change + add_column :products, :name, :string + add_column :products, :stock, :integer + add_column :products, :price, :integer + add_column :products, :description, :string + end +end diff --git a/db/migrate/20180419212536_create_users.rb b/db/migrate/20180419212536_create_users.rb new file mode 100644 index 0000000000..a588bf5a68 --- /dev/null +++ b/db/migrate/20180419212536_create_users.rb @@ -0,0 +1,8 @@ +class CreateUsers < ActiveRecord::Migration[5.1] + def change + create_table :users do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20180419214144_create_orders.rb b/db/migrate/20180419214144_create_orders.rb new file mode 100644 index 0000000000..8d3698575f --- /dev/null +++ b/db/migrate/20180419214144_create_orders.rb @@ -0,0 +1,9 @@ +class CreateOrders < ActiveRecord::Migration[5.1] + def change + create_table :orders do |t| + t.string :status + + t.timestamps + end + end +end diff --git a/db/migrate/20180419214714_create_order_items.rb b/db/migrate/20180419214714_create_order_items.rb new file mode 100644 index 0000000000..db8b5cfa57 --- /dev/null +++ b/db/migrate/20180419214714_create_order_items.rb @@ -0,0 +1,9 @@ +class CreateOrderItems < ActiveRecord::Migration[5.1] + def change + create_table :order_items do |t| + t.integer :quantity + + t.timestamps + end + end +end diff --git a/db/migrate/20180419215007_create_reviews.rb b/db/migrate/20180419215007_create_reviews.rb new file mode 100644 index 0000000000..4556d11346 --- /dev/null +++ b/db/migrate/20180419215007_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 :comments + + t.timestamps + end + end +end diff --git a/db/migrate/20180419215339_create_categories.rb b/db/migrate/20180419215339_create_categories.rb new file mode 100644 index 0000000000..5bef4913b8 --- /dev/null +++ b/db/migrate/20180419215339_create_categories.rb @@ -0,0 +1,9 @@ +class CreateCategories < ActiveRecord::Migration[5.1] + def change + create_table :categories do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20180419220346_create_shopping_carts.rb b/db/migrate/20180419220346_create_shopping_carts.rb new file mode 100644 index 0000000000..9aa3ec7ff1 --- /dev/null +++ b/db/migrate/20180419220346_create_shopping_carts.rb @@ -0,0 +1,8 @@ +class CreateShoppingCarts < ActiveRecord::Migration[5.1] + def change + create_table :shopping_carts do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20180420214215_add_pet_type_and_photo_to_products.rb b/db/migrate/20180420214215_add_pet_type_and_photo_to_products.rb new file mode 100644 index 0000000000..1aebb1b1c8 --- /dev/null +++ b/db/migrate/20180420214215_add_pet_type_and_photo_to_products.rb @@ -0,0 +1,6 @@ +class AddPetTypeAndPhotoToProducts < ActiveRecord::Migration[5.1] + def change + add_column :products, :pet_type, :string + add_column :products, :photo_url, :string + end +end diff --git a/db/migrate/20180420215210_create_products_categories_join.rb b/db/migrate/20180420215210_create_products_categories_join.rb new file mode 100644 index 0000000000..3af322f986 --- /dev/null +++ b/db/migrate/20180420215210_create_products_categories_join.rb @@ -0,0 +1,8 @@ +class CreateProductsCategoriesJoin < ActiveRecord::Migration[5.1] + def change + create_table :products_categories do |t| + t.belongs_to :product, index: true + t.belongs_to :category, index: true + end + end +end diff --git a/db/migrate/20180421184241_add_username_and_email.rb b/db/migrate/20180421184241_add_username_and_email.rb new file mode 100644 index 0000000000..20fd9e17b7 --- /dev/null +++ b/db/migrate/20180421184241_add_username_and_email.rb @@ -0,0 +1,6 @@ +class AddUsernameAndEmail < ActiveRecord::Migration[5.1] + def change + add_column :users, :username, :string + add_column :users, :email, :string + end +end diff --git a/db/migrate/20180421184734_add_uid_and_provider.rb b/db/migrate/20180421184734_add_uid_and_provider.rb new file mode 100644 index 0000000000..f76794f8b3 --- /dev/null +++ b/db/migrate/20180421184734_add_uid_and_provider.rb @@ -0,0 +1,7 @@ +class AddUidAndProvider < ActiveRecord::Migration[5.1] + def change + add_column :users, :uid, :integer, :null => false + add_column :users, :provider, :string, :null => false + + end +end diff --git a/db/migrate/20180421200355_add_user_foreign_key_to_product.rb b/db/migrate/20180421200355_add_user_foreign_key_to_product.rb new file mode 100644 index 0000000000..07e5feb713 --- /dev/null +++ b/db/migrate/20180421200355_add_user_foreign_key_to_product.rb @@ -0,0 +1,5 @@ +class AddUserForeignKeyToProduct < ActiveRecord::Migration[5.1] + def change + add_reference :products, :users, foreign_key: true + end +end diff --git a/db/migrate/20180421204232_add_product_to_reviews.rb b/db/migrate/20180421204232_add_product_to_reviews.rb new file mode 100644 index 0000000000..c0f1aed214 --- /dev/null +++ b/db/migrate/20180421204232_add_product_to_reviews.rb @@ -0,0 +1,5 @@ +class AddProductToReviews < ActiveRecord::Migration[5.1] + def change + add_reference :reviews, :product, foreign_key: true + end +end diff --git a/db/migrate/20180423050846_change_foreign_key_user_for_products.rb b/db/migrate/20180423050846_change_foreign_key_user_for_products.rb new file mode 100644 index 0000000000..f45fde418e --- /dev/null +++ b/db/migrate/20180423050846_change_foreign_key_user_for_products.rb @@ -0,0 +1,5 @@ +class ChangeForeignKeyUserForProducts < ActiveRecord::Migration[5.1] + def change + rename_column :products, :users_id, :user_id + end +end diff --git a/db/migrate/20180423195434_add_foreign_key_orders.rb b/db/migrate/20180423195434_add_foreign_key_orders.rb new file mode 100644 index 0000000000..1cfb584e7e --- /dev/null +++ b/db/migrate/20180423195434_add_foreign_key_orders.rb @@ -0,0 +1,6 @@ +class AddForeignKeyOrders < ActiveRecord::Migration[5.1] + def change + add_reference :order_items, :order, foreign_key:true + add_reference :order_items, :product, foreign_key:true + end +end diff --git a/db/migrate/20180423200648_change_default_column_orders.rb b/db/migrate/20180423200648_change_default_column_orders.rb new file mode 100644 index 0000000000..ee60925a10 --- /dev/null +++ b/db/migrate/20180423200648_change_default_column_orders.rb @@ -0,0 +1,5 @@ +class ChangeDefaultColumnOrders < ActiveRecord::Migration[5.1] + def change + change_column_default :orders, :status, "pending" + end +end diff --git a/db/migrate/20180423221528_change_products_categories.rb b/db/migrate/20180423221528_change_products_categories.rb new file mode 100644 index 0000000000..d7ac93465a --- /dev/null +++ b/db/migrate/20180423221528_change_products_categories.rb @@ -0,0 +1,5 @@ +class ChangeProductsCategories < ActiveRecord::Migration[5.1] + def change + rename_table :products_categories, :categories_products + end +end diff --git a/db/migrate/20180423221943_change_order_items.rb b/db/migrate/20180423221943_change_order_items.rb new file mode 100644 index 0000000000..2c535d08ae --- /dev/null +++ b/db/migrate/20180423221943_change_order_items.rb @@ -0,0 +1,5 @@ +class ChangeOrderItems < ActiveRecord::Migration[5.1] + def change + rename_table :order_items, :items_order + end +end diff --git a/db/migrate/20180423223729_change_name_back_to_order_items.rb b/db/migrate/20180423223729_change_name_back_to_order_items.rb new file mode 100644 index 0000000000..d8b8585b69 --- /dev/null +++ b/db/migrate/20180423223729_change_name_back_to_order_items.rb @@ -0,0 +1,5 @@ +class ChangeNameBackToOrderItems < ActiveRecord::Migration[5.1] + def change + rename_table :items_order, :order_items + end +end diff --git a/db/migrate/20180424180040_add_columns_to_orders.rb b/db/migrate/20180424180040_add_columns_to_orders.rb new file mode 100644 index 0000000000..6928635870 --- /dev/null +++ b/db/migrate/20180424180040_add_columns_to_orders.rb @@ -0,0 +1,11 @@ +class AddColumnsToOrders < ActiveRecord::Migration[5.1] + def change + add_column :orders, :email, :string + add_column :orders, :mail_adr, :string + add_column :orders, :cc_name, :string + add_column :orders, :cc_num, :string + add_column :orders, :cc_exp, :string + add_column :orders, :cc_cvv, :string + add_column :orders, :bill_zip, :string + end +end diff --git a/db/order_seeds.csv b/db/order_seeds.csv new file mode 100644 index 0000000000..2ab8a14894 --- /dev/null +++ b/db/order_seeds.csv @@ -0,0 +1,6 @@ +email,mail_adr,cc_name,cc_num,cc_exp,cc_cvv,bill_zip +NinaHsr@gmail.org,405 N Smart St Seattle WA,Nina Hintz Sr.,4567-7654-3456-9876,09/20,253,98373 +KaiaKlocko@hotmail.org,Apt 3 6th Ave Kent WA,Kaia Klocko,1234-5678-9101-1121,11/24,678,98378 +MarcHoeger@gmail.org,253 North Shore Beach Seattle WA,Marcellus Hoeger,9876-4453-1123-3214,04/21,456,98075 +ErvinW76@msn.org,567432 College Way Mount Vernon WA,Ervin Wiza,1203-4521-4765-9876,02/28,123,98273 +eeheller@ada.org,Apt 5B 14th St Seattle WA,Elmore Heller MD,5643-2231-4321-6754,12/22,543,98075 diff --git a/db/product_seeds.csv b/db/product_seeds.csv new file mode 100644 index 0000000000..f268684b6c --- /dev/null +++ b/db/product_seeds.csv @@ -0,0 +1,46 @@ +name,stock,price,description,pet_type,photo_url,user_id +The Indestructible Petsy KONG,14,2000,Our most popular toy for dogs of all sizes.,dog,KONG.jpg,1 +The Chewsen One,12,300,The most powerful chew toy ever.,dog,Chewsen.jpg,1 +Plush Vader,2,500,The cuteness of this toy will really choke you up.,dog,Plush-Vader.jpg,4 +Tug Rope,10,1000,Get some arm muscles while playing tug of war with your BFF.,dog,Tug-Rope.jpg,5 +Pickles In A Jar,6,1400,Set of 4 funny pickle plush toys.,dog,Pickles.jpg,2 +C-3PO & R2-D2 Mice,9,300,Pack of 2 full of surprises your cat will love.,cat,Mices.jpg +Petsy Cat Teaser,15,300,This toy is the cat's meow.,cat,Teaser.jpg,3 +Crinkly Cat Tunnel,4,1500,Your pet will play with this like it is an endless tunnel.,cat,Tunnel.jpg,5 +Laser Toy,11,250,This toy is on point.,cat,Laser.jpg,6 +The Mega Terrarium,3,50000,High glass terrarium with lots of room for your reptile friend.,reptile,Terrarium.jpg,5 +Petsy Halogen Reptile Dome Heat Lamp,7,1500,Bulb not included a radiant heat source for your pet reptile.,reptile,Heat-Lamp.jpg,3 +Coconut Husk Brick Reptile Bedding,12,500,It does not smell like coconut but good for the environment.,reptile,Rep-Bedding.jpg,2 +Reptile Hideaway,3,700,Spacious log made out of full cork for your reptile friend to hide in.,reptile,Hideaway.jpg,1 +Jungle Plant,5,300,We recommend getting 2 to create the full jungle feel.,reptile,Jungle-Plant.jpg,4 +Skull Hideaway,2,1300,Our most popular hideaway for reptiles.,reptile,Skull-Hideaway.jpg,3 +Petsy Clips for Reptiles,5,500,Reptiles have nails too that need to be regularly trimmed.,reptile,Rep-Clip.jpg,1 +Reptile Leash,4,800,Take your pet reptile out for a walk when the weather is nice outside.,reptile,Rep-Leash.jpg,5 +Petsy Clips for Pets,10,1000,Soft grip to help cut nails easily.,cat,Nail-Clipper.jpg,2 +Petsy Scented Litter,4,900,35lbs litter you won't even notice the litter box.,cat,Cat-Litter.jpg,2 +Cat Leash,3,1300,We are not kitten you right meow,cat,Cat-Harness.jpg,3 +Cat Bow Tie,11,1100,For the hipster cat.,cat,Cat-Bow-Tie.jpg,4 +Fishbone Bow Tie,2,200,So good looking your cat might eat it.,cat,Fishbone-Bow-Tie.jpg,4 +Dog Leash,5,3500,Easy to use on puppies and dogs of all sizes.,dog,Dog-Leash.jpg,5 +Petsy Harness for dogs,10,2000,Gentle and easy to use on dogs of all sizes.,dog,Dog-Harness.jpg,6 +Camo Skull Bandana Dog Collar,1,1000,Dog not included.,dog,Bandana.jpg,4 +Cat Brush,7,2500,Eliminates cat fur.,cat,Cat-Brush.jpg,2 +Cat Shampoo,9,1200,Fragrance Free Oatmeal & Aloe Totally Natural Pet Shampoo.,cat,Cat-Shampoo.jpg,1 +Cat Dry Shampoo,3,700,Dander Reducing Waterless Shampoo for Cats.,cat,Cat-Dry-Shampoo.jpg,5 +Dog Brush,9,3000,Eliminates dog hair.,dog,Dog-Brush.jpg,1 +Dog Shampoo,20,550,Nourishing Avocado & Olive Oil Dog Shampoo.,dog,Dog-Shampoo.jpg,3 +Petsy Pads,30,1500,Gigantic Puppy Housebreaking Pads.,dog,Pads.jpg,5 +Doggie Bag Dispenser,14,600,Refillable Bag Dispenser.,dog,Bag-Dispenser.jpg,6 +Doggie Bags,10,599,100% Compostable Dog Waste Bags.,dog,Dog-Waste-Bags.jpg,6 +Petsy Luxurious Dog Bed,1,20000,Only the best for your BFF sharing is of optional.,dog,Dog-Bed.jpg,1 +Petsy Teepee,1,8000,Perfect for the pet + who loves to stargaze.,dog,Teepee.jpg,1 +Petsy Luxurious Cat Purch,1,10000,Only the best for your BFF.,cat,Cat-Bed.jpg,4 +Petsy Cat Tree Playground,1,15000,Can fit up to 6 cats.,cat,Cattree.jpg,4 +Reptile Food,15,320,Gourmet Style Mealworms Reptile Food.,reptile,Rep-Food.jpg,4 +Vegetable Reptile Munchies,8,850,For a healthy pet reptile.,reptile,Rep-Veg-Food.jpg,5 +Cat Wet Food Pouch,9,1130,Case of 12 Tuna Ocean Whitefish & Pumpkin Wet Cat Food Pouch.,cat,Cat-Wet-Food.jpg,4 +Cat Wet Food Can,8,1200,Case of 8 Grill Mackerel Sardine Calamari Wet Cat Food.,cat,Cat-Can-Food.jpg,1 +Cat Dry Food,12,3000,Dry Cat Food.,cat,Cat-Dry-Food.jpg,1 +Dog Wet Food Can,13,3500,Case of 12 Chicken & Mackerel Poke.,dog,Dog-Dry-Food.jpg,4 +Dog Dry Food,5,3000,Dry Dog Food.,dog,Dog-Wet-Food.jpg,2 diff --git a/db/review_seeds.csv b/db/review_seeds.csv new file mode 100644 index 0000000000..3f27a7a2b2 --- /dev/null +++ b/db/review_seeds.csv @@ -0,0 +1,5 @@ +rating, comments, product_id +4,delectable,1 +5,incredible flexibility,10 +1,garbage,3 +2,This changed my pets life,24 diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..731de955c5 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,94 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20180424180040) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "categories", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "categories_products", force: :cascade do |t| + t.bigint "product_id" + t.bigint "category_id" + t.index ["category_id"], name: "index_categories_products_on_category_id" + t.index ["product_id"], name: "index_categories_products_on_product_id" + end + + create_table "order_items", force: :cascade do |t| + t.integer "quantity" + 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_items_on_order_id" + t.index ["product_id"], name: "index_order_items_on_product_id" + end + + create_table "orders", force: :cascade do |t| + t.string "status", default: "pending" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "email" + t.string "mail_adr" + t.string "cc_name" + t.string "cc_num" + t.string "cc_exp" + t.string "cc_cvv" + t.string "bill_zip" + end + + create_table "products", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.integer "stock" + t.integer "price" + t.string "description" + t.string "pet_type" + t.string "photo_url" + t.bigint "user_id" + t.index ["user_id"], name: "index_products_on_user_id" + end + + create_table "reviews", force: :cascade do |t| + t.integer "rating" + t.string "comments" + 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 + + create_table "shopping_carts", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "username" + t.string "email" + t.integer "uid", null: false + t.string "provider", null: false + end + + add_foreign_key "order_items", "orders" + add_foreign_key "order_items", "products" + add_foreign_key "products", "users" + add_foreign_key "reviews", "products" +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000000..9b4c82b64e --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,46 @@ +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) +require 'csv' + +user_file = Rails.root.join('db', 'user_seeds.csv') + +# might have to change to .open, and +CSV.foreach(user_file, headers: true, header_converters: :symbol, converters: :all) do |row| + # data is in a Hash, create a product ising the row data? + data = Hash[row.headers.zip(row.fields)] + puts data + User.create!(data) + # we never do anything with the new data structure +end + +product_file = Rails.root.join('db', 'product_seeds.csv') + +# might have to change to .open, and +CSV.foreach(product_file, headers: true, header_converters: :symbol, converters: :all) do |row| + # data is in a Hash, create a product ising the row data? + data = Hash[row.headers.zip(row.fields)] + puts data + Product.create!(data) + # we never do anything with the new data structure +end + + +category_file = Rails.root.join('db', 'categories.csv') + +# might have to change to .open, and +CSV.foreach(category_file, headers: true, header_converters: :symbol, converters: :all) do |row| + # data is in a Hash, create a product ising the row data? + data = Hash[row.headers.zip(row.fields)] + puts data + Category.create!(data) + # we never do anything with the new data structure +end + +review_file = Rails.root.join('db', 'review_seeds.csv') + +CSV.foreach(review_file, headers: true, header_converters: :symbol, converters: :all) do |row| + data = Hash[row.headers.zip(row.fields)] + Review.create!(data) +end diff --git a/db/user_seeds.csv b/db/user_seeds.csv new file mode 100644 index 0000000000..fc34c93a68 --- /dev/null +++ b/db/user_seeds.csv @@ -0,0 +1,7 @@ +username, email, uid, provider +rufo, puppy@petsy.com, 123, github +kitty, kitty@petsy.com, 345, github +max, max@petsy.com, 567, github +rhino, rhino@petsy.com, 899, github +kerry, kerry@petsy.com, 124, github +sally, sally@petsy.com, 125, github diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/package.json b/package.json new file mode 100644 index 0000000000..f874acf437 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "name": "betsy", + "private": true, + "dependencies": {} +} diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000000..2be3af26fc --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

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

    +
    +

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

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

    The change you wanted was rejected.

    +

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

    +
    +

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

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

    We're sorry, but something went wrong.

    +
    +

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

    +
    + + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000000..37b576a4a0 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000000..d19212abd5 --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb new file mode 100644 index 0000000000..bd6c935d4f --- /dev/null +++ b/test/controllers/categories_controller_test.rb @@ -0,0 +1,89 @@ +require "test_helper" + + +describe CategoriesController do + let(:user) { users(:one) } + describe 'index' do + it 'sends a success response when there are many categories' do + Category.count.must_be :>, 0 + + # Act + get categories_path + + # Assert + must_respond_with :success + end + + end + + describe 'new' do + it 'responds with success with a logged user' do + # category = Category.first + login(user) + + get new_category_path + + must_respond_with :success + end + + + end + + describe "create" do + it "lets a logged user to create a category" do + category_data = {name: 'new category'} + user = User.first + old_category_count = Category.count + + Category.new(category_data).must_be :valid? + login(user) + + post categories_path, params: {category: category_data} + + must_respond_with :redirect + must_redirect_to users_path + Category.count.must_equal old_category_count + 1 + end + + it "can add a valid category" do + # Arrange + category_data = { + name: 'test category name' + } + old_category_count = Category.count + + # Assumption + Category.new(category_data).must_be :valid? + + # Act + post categories_path, params: { category: category_data } + + # # Assert + # # ***The HTTP response below + # must_respond_with :redirect + # must_redirect_to categorys_path + + Category.count.must_equal old_category_count + 1 + Category.last.name.must_equal category_data[:name] + end + + it "won't add an invalid category" do + # Arrange + category_data = { + name: nil + } + old_category_count = Category.count + + # Assumption + Category.new(category_data).wont_be :valid? + + # Act + post categories_path, params: { category: category_data } + + # Assert + # must_respond_with :bad_request + Category.count.must_equal old_category_count + end + end + +end diff --git a/test/controllers/mains_controller_test.rb b/test/controllers/mains_controller_test.rb new file mode 100644 index 0000000000..e61c5eed75 --- /dev/null +++ b/test/controllers/mains_controller_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +describe MainsController do + describe "index" do + it "sends a success response" do + + get root_path + + must_respond_with :success + end + end + +end diff --git a/test/controllers/order_items_controller_test.rb b/test/controllers/order_items_controller_test.rb new file mode 100644 index 0000000000..a4b496f4cf --- /dev/null +++ b/test/controllers/order_items_controller_test.rb @@ -0,0 +1,81 @@ +require "test_helper" + +describe OrderItemsController do + describe "index" do + it "sends a success response when there are many order items" do + get order_items_path + + must_respond_with :success + end + + it "sends a success response when there are no orders" do + OrderItem.destroy_all + get order_items_path + must_respond_with :success + end + end + describe "show" do + it "should get show" do + get order_item_path(OrderItem.first.id) + + must_respond_with :success + end + + end + + describe "create" do + + it "sends success if the order exists" do + order = Order.first + orderitem_data = { product_id: Product.first.id, quantity: Product.first.stock, order_id: order.id } + + post order_items_path, params: {order_item: orderitem_data} + + get order_item_path(order) + must_respond_with :success + end + it "sends not_found if the order does not exist" do + order_id = Order.last.id + 1 + get order_item_path(order_id) + must_respond_with :bad_request + must_redirect_to root_path + end + + end + + describe "update" do + it 'updates the quantity of a same product added to the cart' do + + updated_quantity = 3 + + patch order_item_path(OrderItem.first.id), + params: { + order_item: { + quantity: updated_quantity, + } + } + + updated_op = OrderItem.find(OrderItem.first.id) + updated_op.quantity.must_equal updated_quantity + + end + end + + describe "destroy" do + it "deletes a order item" do + delete order_item_path(OrderItem.first.id) + + must_respond_with :redirect + end + + it "reduces order item count" do + initial = OrderItem.count + + delete order_item_path(OrderItem.first.id) + + OrderItem.count.must_equal initial - 1 + + end + end + +end diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb new file mode 100644 index 0000000000..3ab6ea4c98 --- /dev/null +++ b/test/controllers/orders_controller_test.rb @@ -0,0 +1,77 @@ +require "test_helper" + +describe OrdersController do + before do + @orders = Order.all + end + describe "index" do + + it "sends a success response when there are many orders" do + @orders.count.must_be :>, 0 + get orders_path + must_respond_with :success + end + + it "sends a success response when there are no orders" do + Order.destroy_all + @orders.count.must_equal 0 + get orders_path + must_respond_with :success + end + + end + + describe "update" do + + it "takes customer information and changes status to paid" do + product = Product.first + + order_item = {product_id: product.id, quantity: product.stock} + post order_items_path, params: {order_item: order_item} + + order_id = Order.last.id + + order_data = { + cc_name: "Sarah Parker", + email: "jackson@petsy.com", + cc_num: "12345678901234567", + cc_cvv: "980", + cc_exp: "01/22", + mail_adr: "2615 233rd Ave SE, Sammamish", + bill_zip: "98075", + status: "pending" + } + patch order_path(order_id), params: {order: order_data} + + must_redirect_to order_path + + + Order.last.status.must_equal "paid" + end + + it "does not procees the order if the customer data is incomplete" do + orderitem = {product_id: Product.first.id, quantity: Product.first.stock} + post order_items_path, params: {order_item: orderitem} + + order_data = { + email: "jackson@petsy.com", + cc_num: "12345678901234567", + cc_cvv: "980", + cc_exp: "01/22", + mail_adr: "2615 233rd Ave SE, Sammamish", + bill_zip: "98075", + status: "pending" + } + patch order_path(session[:order_id]), params: {order: order_data} + + must_respond_with :found + + Order.last.status.must_equal "pending" + + session[:order_id].must_equal OrderItem.last.order_id + end + + + end + +end diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb new file mode 100644 index 0000000000..5ca1b3faf8 --- /dev/null +++ b/test/controllers/products_controller_test.rb @@ -0,0 +1,118 @@ +require "test_helper" + +describe ProductsController do + describe "index" do + it "succeeds when there are products" do + # Arrange + Product.count.must_be :>, 0 + # Act + get products_path + # Assert + must_respond_with :success + + end + + it "succeeds when there are no products" do + # Arrange + Product.destroy_all + Product.all.length.must_equal 0 + # Act + get products_path + # Assert + must_respond_with :success + end + + end + + describe "new" do + it "does not succeed when guest user" do + # Arrange & Act + get new_product_path + # Assert + must_redirect_to users_path + end + + it "succeeds when login user" do + # Arrange & Act + existing_user = users(:one) + login(existing_user) + get new_product_path + # Assert + must_respond_with :success + end + end + + describe "create" do + it 'can add a valid product' do + # Arrange + existing_user = users(:one) + login(existing_user) + product_data = { + name: 'TestToy', + stock: 5, + price: 500, + description: "A dogs dream", + pet_type: "dog", + photo_url: "Pickles.jpg", + user_id: existing_user.id, + } + old_product_count = Product.count + + # Assumptions + Product.new(product_data).must_be :valid? + + # Act + post products_path, params: { product: product_data } + + # Assert + must_respond_with :redirect + must_redirect_to products_path + + Product.count.must_equal old_product_count + 1 + Product.last.name.must_equal product_data[:name] + end + + it 'cannot add a product with bogus data' do + # Arrange + existing_user = users(:two) + login(existing_user) + product_data = { + stock: 5, + price: 500, + description: "A dogs dream", + pet_type: "dog", + photo_url: "Pickles.jpg", + user_id: existing_user.id, + } + old_product_count = Product.count + + # Act + post products_path, params: { product: product_data } + + # Assert + must_respond_with :bad_request + + Product.count.must_equal old_product_count + # Product.last.name.must_equal product_data[:name] + end + + + end + + describe "show" do + it 'sends success if the product exists' do + get product_path(Product.first) + must_respond_with :success + end + + it "sends not_found if the product doesn't exist" do + product_id = Product.last.id + 1 + + get product_path(product_id) + + must_respond_with :not_found + end + end + + +end diff --git a/test/controllers/reviews_controller_test.rb b/test/controllers/reviews_controller_test.rb new file mode 100644 index 0000000000..242771ca89 --- /dev/null +++ b/test/controllers/reviews_controller_test.rb @@ -0,0 +1,54 @@ +require "test_helper" + +describe ReviewsController do + describe 'new' do + it 'responds with success with a logged out user' do + product = Product.first + get new_product_review_path(product) + + must_respond_with :success + end + + it "renders 404 not_found " do + get new_product_review_path(-1) + must_respond_with :not_found + end + + it "won't let the product's owner to review product" do + product_id = Product.first.id + login(users(:one)) + get new_product_review_path(products(:product1)) + must_respond_with :redirect + + post product_reviews_path(products(:product1)), params: {rating: 5, comments: "la la la", product_id: product_id} + must_respond_with :redirect + end + end + + describe "create" do + + it "it won't create a review with bogus data" do + product = Product.create(name:"cat rug",price: 10, user: users(:one), stock: 15) + start = product.reviews.count + post product_reviews_path(product.id), params: {review:{rating: 15, comments: "beautiful"}} + product.reviews.count.must_equal start + must_respond_with :bad_request + end + + it "creates a review with valid data" do + product_id = Product.first.id + review_data = { rating: 5, comments: 'comments', product_id: product_id } + + old_review_count = Review.count + + Review.new(review_data).must_be :valid? + post product_reviews_path(product_id), params: { review: review_data} + + must_respond_with :redirect + must_redirect_to product_path(product_id) + Review.count.must_equal old_review_count + 1 + Review.last.comments.must_equal 'comments' + end + + end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000000..aab84e4fe2 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,72 @@ +require "test_helper" + +describe SessionsController do + describe 'auth_callback' do + it "should create a new user and redirect to root page" do + user = User.new(provider: 'github', uid: 76621, email: 'mail4@me.org', username: 'Lemuel Larsky') + + user.must_be :valid? + original_count = User.count + user.save + # act + login(user) + + # assert + + must_redirect_to root_path + User.count.must_equal original_count + 1 + session[:user_id].must_equal User.last.id + + end + + + it "logs in existing user and redirect to root page" do + # arrange + user = User.first + original_count = User.count + + # act + login(user) + + # assert + + must_redirect_to root_path + User.count.must_equal original_count + session[:user_id].must_equal user.id + + end + + it "does not log in with invalid data" do + user = User.new(provider: 'github', uid: nil , email: 'mail@me.org', username: 'Milkah Lamb') + + user.wont_be :valid? + + original_count = User.count + + # act + login(user) + + # assert + + must_redirect_to root_path + User.count.must_equal original_count + + + end + + describe 'logout' do + it "can logout" do + # Arrange + login(User.first) + + # Act + delete logout_path + + assert_nil nil + + end + + end + + end +end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 0000000000..53f45f2c93 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,59 @@ +require "test_helper" + +describe UsersController do + + describe 'index' do + it 'succeeds when there are users' do + User.count.must_be :>,0 + get users_path + must_respond_with :success + end + end + + describe 'show' do + it 'succeeds for an extant user ID' do + user_id = User.first.id + + get user_path(user_id) + + must_respond_with :success + end + + it 'renders 404 not_found for a bogus user ID' do + user_id = User.last.id + 1 + + get user_path(user_id) + + must_respond_with :not_found + end + end + + describe "new" do + it "succeeds" do + get new_user_path + + must_respond_with :success + end + end + + + describe "edit" do + it "should get edit for valid id" do + user_id = User.first.id + get edit_user_path(user_id) + + must_respond_with :success + + end + + it "renders 404 and does not update DB for bad ID" do + user_id = User.last.id + 1 + + get edit_user_path(user_id) + + must_respond_with :not_found + + end + end + +end diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/categories.yml b/test/fixtures/categories.yml new file mode 100644 index 0000000000..a7b3d721c8 --- /dev/null +++ b/test/fixtures/categories.yml @@ -0,0 +1,10 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +decor: + name: decor + +food: + name: food + +accessory: + name: accessory diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/order_items.yml b/test/fixtures/order_items.yml new file mode 100644 index 0000000000..59254433c3 --- /dev/null +++ b/test/fixtures/order_items.yml @@ -0,0 +1,18 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +orderitem1: + order: order1 + product: product1 + quantity: 10 + + +orderitem2: + order: order2 + product: product2 + quantity: 5 + + +orderitem3: + order: order3 + product: product3 + quantity: 3 diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml new file mode 100644 index 0000000000..628a8c0a17 --- /dev/null +++ b/test/fixtures/orders.yml @@ -0,0 +1,21 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +order1: + status: pending + email: email1 + mail_adr: mail_adr1 + cc_name: cc_name1 + cc_num: 123456789123456 + cc_exp: 11/22 + cc_cvv: 123 + bill_zip: 98075 + +order2: + status: pending + email: email1 + mail_adr: mail_adr1 + cc_name: cc_name1 + cc_num: 123456789123456 + cc_exp: 11/22 + cc_cvv: 123 + bill_zip: 98075 diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml new file mode 100644 index 0000000000..093648dd58 --- /dev/null +++ b/test/fixtures/products.yml @@ -0,0 +1,34 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +product1: + name: tank + stock: 7 + price: 2100 + description: A bullet proof tank for the most wanted of reptiles + pet_type: reptile + photo_url: Pickles.jpg + user: one + + +product2: + name: collar + stock: 25 + price: 1000 + description: A stylish collar for your most tamed canines + pet_type: dog + photo_url: Pickles.jpg + user: one + + +product3: + name: Dog Scarf + stock: 15 + price: 1000 + description: A fabulous scarf for your fabulous pooch + pet_type: dog + photo_url: Pickles.jpg + user: two diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml new file mode 100644 index 0000000000..b05a92f064 --- /dev/null +++ b/test/fixtures/reviews.yml @@ -0,0 +1,16 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + rating: 4 + comments: Great product + product: product2 + +two: + rating: 3 + comments: Love this so much + product: product1 + +three: + rating: 4 + comments: + product: product1 diff --git a/test/fixtures/shopping_carts.yml b/test/fixtures/shopping_carts.yml new file mode 100644 index 0000000000..dc3ee79b5d --- /dev/null +++ b/test/fixtures/shopping_carts.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000000..edde366c54 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,29 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: + username: puppy + email: puppy@petsy.com + uid: 1 + provider: github + +two: + username: lizard + email: lizard@petsy.com + uid: 2 + provider: github + +three: + username: cat + email: neko@petsy.com + uid: 3 + provider: github + +four: + username: Milkah Lamb + email: mail@me.org + uid: 77621 + provider: github diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/models/category_test.rb b/test/models/category_test.rb new file mode 100644 index 0000000000..c4ee452022 --- /dev/null +++ b/test/models/category_test.rb @@ -0,0 +1,50 @@ +require "test_helper" + +describe Category do + describe "relations" do + it "connects product and product_id" do + product = Product.first + category = Category.first + + product.categories << category + + product.category_ids.must_include category.id + end + end + + describe "validations" do + it "must be valid with all required fields" do + category = Category.new(name: "test category") + category.save + category.valid?.must_equal true + end + + it "requires a name" do + category = Category.new(name: nil) + category.save + category.valid?.must_equal false + category.errors.messages.must_include :name + end + + it "allows products to have multiple categoriess" do + category1 = categories(:decor) + category2 = categories(:food) + category1.valid?.must_equal true + category1.valid?.must_equal true + end + + it "must have a unique name" do + category_name = "test category" + new_category = Category.new(name: category_name) + + new_category.save! + + new_category2 = Category.new(name: category_name) + result = new_category2.save + result.must_equal false + new_category2.errors.messages.must_include :name + end + end + + +end diff --git a/test/models/order_item_test.rb b/test/models/order_item_test.rb new file mode 100644 index 0000000000..76b734b18f --- /dev/null +++ b/test/models/order_item_test.rb @@ -0,0 +1,56 @@ +require "test_helper" + +describe OrderItem do + let(:order_item) { OrderItem.new(order: orders(:order1), product: products(:product1), quantity: 7) } + + describe "relations" do + it "has an associated product" do + orderitem = order_items(:orderitem1) + orderitem.product.must_equal products(:product1) + orderitem.product_id = products(:product2).id + orderitem.product.must_equal products(:product2) + end + + it "has associated order" do + orderitem = order_items(:orderitem1) + orderitem.order.must_equal orders(:order1) + orderitem.order_id = orders(:order2).id + orderitem.order.must_equal orders(:order2) + end + end + + describe "validations" do + + it "must have a positive integer quantity" do + [-3, 0].each do |num| + order_item.quantity = num + order_item.valid?.must_equal false + end + (1..5).each do |num| + order_item.quantity = num + order_item.valid?.must_equal true + end + end + it "must be in stock" do + order_item.quantity = 100 + order_item.valid?.must_equal false + end + it "can't make an order product from out of stock product" do + product = products(:product1) + product.stock = 0 + product.save + orderitem = OrderItem.new(order: orders(:order1), product: products(:product1), quantity: 7) + orderitem.valid?.must_equal false + end + end + + describe "custom methods" do + it "returns the subtotal of an orderitem" do + orderitem = OrderItem.new(order: orders(:order1), product: products(:product1), quantity: 7) + result_sub_total = 14700 + orderitem.sub_total.must_equal result_sub_total + end + end + + +end diff --git a/test/models/order_test.rb b/test/models/order_test.rb new file mode 100644 index 0000000000..d0d4ebd2ad --- /dev/null +++ b/test/models/order_test.rb @@ -0,0 +1,151 @@ +require "test_helper" + +describe Order do + let(:order) { Order.new } + let(:order1) { orders(:order1) } + + describe "relations" do + + it "has a list of order_items" do + order1.order_items.each do |item| + item.must_be_instance_of OrderItem + item.order.must_be_instance_of Order + item.order.must_equal order1 + end + end + end + + describe "validations" do + before do + @order = Order.new(email: "rufo@petsy.com", mail_adr: "2615 233rd SE, Sammamish, WA",cc_name: "Rufino Woof", cc_num: "9875632147652345", cc_exp: "09/22", cc_cvv: "987",bill_zip: "98075", status: "paid") + end + + + it "must have a mailing address" do + @order.mail_adr = nil + @order.valid?.must_equal false + end + + it "must have a name in the credit card information" do + @order.cc_name = nil + @order.valid?.must_equal false + @order.cc_name = "Rufino Woof" + @order.valid?.must_equal true + end + + it "must have an email address" do + @order.email.must_equal "rufo@petsy.com" + @order.valid?.must_equal true + @order.email = nil + @order.valid?.must_equal false + end + + it "must have a billing zip code number" do + @order.bill_zip.must_equal "98075" + @order.valid?.must_equal true + + [nil,"","wooof"].each do |num| + @order.bill_zip = num + @order.valid?.must_equal false + end + end + + + it "must have a credit card number of 16 digits" do + @order.cc_num.must_equal "9875632147652345" + @order.valid?.must_equal true + + [nil,"45638","raaaa",""].each do |num| + @order.cc_num = num + @order.valid?.must_equal false + end + end + + it "must have an expiration date" do + @order.cc_exp.must_equal "09/22" + @order.valid?.must_equal true + + @order.cc_exp = nil + @order.valid?.must_equal false + end + + it "must include a CVV number of 3 digits" do + [nil,"18294673","fuw"].each do |num| + @order.cc_cvv = num + @order.valid?.must_equal false + end + + ["345","182","666"].each do |num| + @order.cc_cvv = num + @order.valid?.must_equal true + end + end + + + end + describe "custom methods" do + describe "total_sum" do + before do + @order = Order.new + @order.order_items << OrderItem.first + @order.valid?.must_equal true + @order.save + end + it "returns the total of an order of only one order item " do + order.save + + OrderItem.create(quantity: 1, product_id: products(:product1).id, order_id: order.id) + + order.total_sum.must_be_kind_of Integer + order.total_sum.must_equal (products(:product1).price) + order.total_sum.must_equal 2100 + + end + + it "returns the total of an order of multiple order items " do + order.save + + OrderItem.create(quantity: 1, product_id: products(:product1).id, order_id: order.id) + OrderItem.create(quantity: 1, product_id: products(:product2).id, order_id: order.id) + OrderItem.create(quantity: 1, product_id: products(:product3).id, order_id: order.id) + + order.total_sum.must_be_kind_of Integer + order.total_sum.must_equal (products(:product1).price + products(:product2).price + products(:product3).price) + order.total_sum.must_equal 4100 + end + + it "returns the total of an order of multiple order items " do + order.save + + OrderItem.create(quantity: 0, product_id: products(:product1).id, order_id: order.id) + + order.total_sum.must_be_kind_of Integer + order.total_sum.must_equal 0 + + end + + end + + describe "reduce_inventory" do + it "reduces the inventory of the items purchased" do + order = Order.new + order.save + order_item = order_items(:orderitem1) + order_item.quantity.must_equal 10 + order_item.save + order.order_items << order_item + + + product = order_item.product + product.stock = products(:product2).stock + product.stock.must_equal 25 + order.reduce_inventory + + order.reload + product.reload + + product.stock.must_equal 15 + end + end + end +end diff --git a/test/models/product_test.rb b/test/models/product_test.rb new file mode 100644 index 0000000000..7686cb7eff --- /dev/null +++ b/test/models/product_test.rb @@ -0,0 +1,145 @@ +require "test_helper" + +describe Product do + let(:product) { Product.new } + let(:product1) {products(:product1)} + let(:product2) {users(:product2)} + + describe 'relations' do + it "must belong to a user" do + product = products(:product1) + product.must_respond_to :user + product.must_be_kind_of Product + product.user.must_be_kind_of User + end + + it "must belong to a category" do + product = products(:product1) + product.must_respond_to :categories + + end + + it "has a list of categories" do + product1.categories.each do |category| + category.must_be_instance_of Category + category.products.must_be_instance_of Array + category.products.must_include product1 + end + end + + it "belongs to many categories" do + Product.first.categories << categories(:decor) + Product.first.categories << categories(:food) + Product.last.categories << categories(:decor) + Product.first.categories.must_equal [categories(:decor),categories(:food)] + Product.last.categories.must_equal [categories(:decor)] + end + + it "has reviews" do + product = products(:product1) + product.must_respond_to :reviews + end + + it "has a list of orderitems " do + product1.order_items.each do |order_item| + order_item.must_be_instance_of OrderItem + order_item.product.must_be_instance_of Product + order_item.product.must_equal product1 + end + end + + end + describe 'validations' do + it "must have a name to be valid" do + product1.valid?.must_equal true + product1.name = "" + product1.valid?.must_equal false + product1.errors.messages.must_include :name + end + + it "must have a unique name" do + product_name = "test productname" + new_product = Product.new(name: product_name, price: 50, stock: 10) + + new_product.save! + + new_product2 = Product.new(name: product_name, price: 30, stock: 5) + result = new_product2.save + result.must_equal false + new_product2.errors.messages.must_include :name + end + + it "must have a price to be valid" do + product1.valid?.must_equal true + product1.price = "" + product1.valid?.must_equal false + end + + it "must have a price greater than 0" do + product1.valid?.must_equal true + product1.price = 0 + product1.valid?.must_equal false + product1.price = -5 + product1.valid?.must_equal false + end + + it "must have a stock to be valid" do + product1.valid?.must_equal true + product1.stock = "" + product1.valid?.must_equal false + end + + it "must have an integer as stock" do + product1.valid?.must_equal true + product1.stock = 0.4 + product1.valid?.must_equal false + end + + it "must have as stock a number greater than or equal to 0" do + product1.valid?.must_equal true + product1.stock = 0 + product1.valid?.must_equal true + end + + it "cannot have a negative number as stock" do + product1.valid?.must_equal true + product1.stock = -10 + product1.valid?.must_equal false + end + + end + + describe 'custom methods' do + + it "returns correct average rating" do + product = products(:product1) + product.show_rating.must_equal 3 + + product = products(:product2) + product.show_rating.must_equal 4 + end + + it "returns no reviews when the product does not have reviews" do + product.show_rating.must_equal "No reviews" + end + + + it "returns a collection of products" do + + Product.by_pet_type.must_be_kind_of Hash + end + + + it 'reduces the stock of the product' do + product = Product.first + product.stock = 10 + product.save + + product.stock_reduction(3) + product.reload + + product.stock.must_equal 7 + end + end + +end diff --git a/test/models/review_test.rb b/test/models/review_test.rb new file mode 100644 index 0000000000..4c682168b7 --- /dev/null +++ b/test/models/review_test.rb @@ -0,0 +1,59 @@ +require "test_helper" + +describe Review do + describe "relations" do + it "has a product" do + r = reviews(:one) + r.must_respond_to :product + r.product.must_be_kind_of Product + end + end + + describe "validations" do + it "must be valid with all required fields" do + review = Review.last + review.valid?.must_equal true + end + + it "allows users to review for multiple products" do + review1 = reviews(:one) + review2 = reviews(:two) + review1.valid?.must_equal true + review2.valid?.must_equal true + end + + it "requires a rating" do + review = Review.new(comments: "great product") + review.save + review.valid?.must_equal false + review.errors.messages.must_include :rating + end + + it "requires a rating to be integer" do + review = Review.new(rating: "what") + review.save + review.valid?.must_equal false + review.errors.messages.must_include :rating + end + + it "requires a rating between 1 and 5" do + review = Review.new(rating: 0) + review.save + review.valid?.must_equal false + end + + it "rating cannot be greater than 5" do + review = Review.new(rating: 7) + review.save + review.valid?.must_equal false + review.errors.messages.must_include :rating + end + + it "rating cannot be less than 0" do + review = Review.new(rating: -3) + review.save + review.valid?.must_equal false + review.errors.messages.must_include :rating + end + end +end diff --git a/test/models/shopping_cart_test.rb b/test/models/shopping_cart_test.rb new file mode 100644 index 0000000000..125ee42256 --- /dev/null +++ b/test/models/shopping_cart_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe ShoppingCart do + let(:shopping_cart) { ShoppingCart.new } + + it "must be valid" do + value(shopping_cart).must_be :valid? + end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000000..4d79d06ce7 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,84 @@ +require "test_helper" + +describe User do + let(:user) { User.new } + let(:one) { users(:one) } + + describe "relations" do + it "has a list of products" do + dan = users(:one) + dan.must_respond_to :products + dan.products.each do |product| + product.must_be_kind_of Product + end + dan.products.count.must_equal 2 + end + + it "returns an empty array if user does not have products" do + dan = users(:three) + dan.must_respond_to :products + dan.products.each do |product| + product.must_be_kind_of Product + end + dan.products.must_equal [] + end + end + + describe "validations" do + it "must be valid" do + one.must_be :valid? + end + + it "must have a username" do + user.email = "email" + user.username = " " + user.valid?.must_equal false + user.errors.messages.must_include :username + + user.username = "test username" + user.valid?.must_equal true + end + + it "username must be unique" do + one.username.must_equal "puppy" + user.email = "email2" + user.username = "puppy" + user.valid?.must_equal false + user.errors.messages.must_include :username + end + + it "must have an email" do + user.username = "username" + user.email = " " + user.valid?.must_equal false + user.errors.messages.must_include :email + + user.email = "email3" + user.valid?.must_equal true + end + + it "email must be unique" do + one.email.must_equal "puppy@petsy.com" + user.username = "name2" + user.username = "puppy@petsy.com" + user.valid?.must_equal false + user.errors.messages.must_include :email + end + end + + describe 'custom methods' do + it "builds user from auth_hash" do + auth_hash = { + info: { nickname: "test", email: "test@petsy.com" }, + uid: "124", + provider: "github" + } + user = User.info_from_github(auth_hash) + + user.username.must_equal "test" + user.email.must_equal "test@petsy.com" + user.uid.must_equal 124 + user.provider.must_equal "github" + end + end +end diff --git a/test/system/.keep b/test/system/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000000..9b7a21cfe4 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,67 @@ +require 'simplecov' +SimpleCov.start 'rails' do + add_filter '/bin/' + add_filter '/db/' + add_filter '/spec/' # for rspec + add_filter '/test/' # for minitest +end + + +ENV["RAILS_ENV"] = "test" +SimpleCov.start 'rails' do + add_filter '/bin/' + add_filter '/db/' + add_filter '/spec/' # for rspec + add_filter '/test/' # for minitest +end +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... + # group :test do + # gem 'simplecov', require: false + # end + def setup + # Once you have enabled test mode, all requests + # to OmniAuth will be short circuited to use the mock authentication hash. + # A request to /auth/provider will redirect immediately to /auth/provider/callback. + OmniAuth.config.test_mode = true + end + + def mock_auth_hash(user) + return { + provider: user.provider, + uid: user.uid, + info: { + email: user.email, + username: user.username + } + } + end + + def login(user) + OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new(mock_auth_hash(user)) + get auth_callback_path(:github) + end + +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000000..e69de29bb2