From 731643966e57649ddfd6dbeb2445614f8492c3c2 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Mon, 6 Nov 2017 12:55:41 -0800 Subject: [PATCH 01/21] Rails new, models and controllers created --- .gitignore | 16 ++ Gemfile | 53 ++++++ Gemfile.lock | 170 ++++++++++++++++++ Rakefile | 6 + app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/controllers/application_controller.rb | 2 + app/controllers/concerns/.keep | 0 app/controllers/customers_controller.rb | 2 + app/controllers/movies_controller.rb | 2 + app/controllers/rentals_controller.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 4 + app/models/application_record.rb | 3 + app/models/concerns/.keep | 0 app/models/customer.rb | 2 + app/models/movie.rb | 2 + app/models/rental.rb | 2 + app/views/layouts/mailer.html.erb | 13 ++ app/views/layouts/mailer.text.erb | 1 + bin/bundle | 3 + bin/rails | 9 + bin/rake | 9 + bin/setup | 35 ++++ bin/spring | 17 ++ bin/update | 29 +++ config.ru | 5 + config/application.rb | 40 +++++ config/boot.rb | 3 + config/cable.yml | 10 ++ config/database.yml | 85 +++++++++ config/environment.rb | 5 + config/environments/development.rb | 47 +++++ config/environments/production.rb | 83 +++++++++ config/environments/test.rb | 42 +++++ .../application_controller_renderer.rb | 8 + config/initializers/backtrace_silencers.rb | 7 + config/initializers/cors.rb | 16 ++ .../initializers/filter_parameter_logging.rb | 4 + config/initializers/inflections.rb | 16 ++ config/initializers/mime_types.rb | 4 + config/initializers/wrap_parameters.rb | 14 ++ config/locales/en.yml | 33 ++++ config/puma.rb | 56 ++++++ config/routes.rb | 3 + config/secrets.yml | 32 ++++ config/spring.rb | 6 + db/migrate/20171106204850_create_movies.rb | 12 ++ db/migrate/20171106205120_create_customers.rb | 15 ++ db/migrate/20171106205158_create_rentals.rb | 9 + db/schema.rb | 45 +++++ lib/tasks/.keep | 0 log/.keep | 0 public/robots.txt | 1 + test/controllers/.keep | 0 test/controllers/customers_controller_test.rb | 7 + test/controllers/movies_controller_test.rb | 7 + test/controllers/rentals_controller_test.rb | 7 + test/fixtures/.keep | 0 test/fixtures/customers.yml | 19 ++ test/fixtures/files/.keep | 0 test/fixtures/movies.yml | 13 ++ test/fixtures/rentals.yml | 7 + test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/models/customer_test.rb | 9 + test/models/movie_test.rb | 9 + test/models/rental_test.rb | 9 + test/test_helper.rb | 26 +++ tmp/.keep | 0 vendor/.keep | 0 72 files changed, 1106 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100644 app/channels/application_cable/channel.rb create mode 100644 app/channels/application_cable/connection.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/controllers/customers_controller.rb create mode 100644 app/controllers/movies_controller.rb create mode 100644 app/controllers/rentals_controller.rb create mode 100644 app/jobs/application_job.rb create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/models/application_record.rb create mode 100644 app/models/concerns/.keep create mode 100644 app/models/customer.rb create mode 100644 app/models/movie.rb create mode 100644 app/models/rental.rb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/setup create mode 100755 bin/spring create mode 100755 bin/update create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/cable.yml create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/cors.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/en.yml create mode 100644 config/puma.rb create mode 100644 config/routes.rb create mode 100644 config/secrets.yml create mode 100644 config/spring.rb create mode 100644 db/migrate/20171106204850_create_movies.rb create mode 100644 db/migrate/20171106205120_create_customers.rb create mode 100644 db/migrate/20171106205158_create_rentals.rb create mode 100644 db/schema.rb create mode 100644 lib/tasks/.keep create mode 100644 log/.keep create mode 100644 public/robots.txt create mode 100644 test/controllers/.keep create mode 100644 test/controllers/customers_controller_test.rb create mode 100644 test/controllers/movies_controller_test.rb create mode 100644 test/controllers/rentals_controller_test.rb create mode 100644 test/fixtures/.keep create mode 100644 test/fixtures/customers.yml create mode 100644 test/fixtures/files/.keep create mode 100644 test/fixtures/movies.yml create mode 100644 test/fixtures/rentals.yml create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/models/customer_test.rb create mode 100644 test/models/movie_test.rb create mode 100644 test/models/rental_test.rb create mode 100644 test/test_helper.rb create mode 100644 tmp/.keep create mode 100644 vendor/.keep diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..68ac019ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# 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 + +.byebug_history diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..4ae55c93d --- /dev/null +++ b/Gemfile @@ -0,0 +1,53 @@ +source 'https://rubygems.org' + +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://github.com/#{repo_name}.git" +end + + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.1.4' +# Use postgresql as the database for Active Record +gem 'pg', '~> 0.18' +# Use Puma as the app server +gem 'puma', '~> 3.7' +# 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', '~> 3.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible +# gem 'rack-cors' + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +end + +group :development do + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'jquery-turbolinks' +group :development do + gem 'better_errors' + gem 'pry-rails' + gem 'binding_of_caller' +end + +group :test do + gem 'minitest-rails' + gem 'minitest-reporters' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..484707437 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,170 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.1.4) + actionpack (= 5.1.4) + nio4r (~> 2.0) + websocket-driver (~> 0.6.1) + actionmailer (5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.1.4) + actionview (= 5.1.4) + activesupport (= 5.1.4) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.1.4) + activesupport (= 5.1.4) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.1.4) + activesupport (= 5.1.4) + globalid (>= 0.3.6) + activemodel (5.1.4) + activesupport (= 5.1.4) + activerecord (5.1.4) + activemodel (= 5.1.4) + activesupport (= 5.1.4) + arel (~> 8.0) + activesupport (5.1.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + ansi (1.5.0) + arel (8.0.0) + better_errors (2.4.0) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + binding_of_caller (0.7.3) + debug_inspector (>= 0.0.1) + builder (3.2.3) + byebug (9.1.0) + coderay (1.1.2) + concurrent-ruby (1.0.5) + crass (1.0.2) + debug_inspector (0.0.3) + erubi (1.7.0) + ffi (1.9.18) + globalid (0.4.1) + activesupport (>= 4.2.0) + i18n (0.9.1) + concurrent-ruby (~> 1.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.1.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.0) + mini_mime (>= 0.1.1) + method_source (0.9.0) + mini_mime (0.1.4) + mini_portile2 (2.3.0) + minitest (5.10.3) + minitest-rails (3.0.0) + minitest (~> 5.8) + railties (~> 5.0) + minitest-reporters (1.1.18) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + nio4r (2.1.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) + pg (0.21.0) + pry (0.11.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.6) + pry (>= 0.10.4) + puma (3.10.0) + rack (2.0.3) + rack-test (0.7.0) + rack (>= 1.0, < 3) + rails (5.1.4) + actioncable (= 5.1.4) + actionmailer (= 5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) + activemodel (= 5.1.4) + activerecord (= 5.1.4) + activesupport (= 5.1.4) + bundler (>= 1.3.0) + railties (= 5.1.4) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (5.1.4) + actionpack (= 5.1.4) + activesupport (= 5.1.4) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.2.1) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + ruby-progressbar (1.9.0) + ruby_dep (1.5.0) + 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-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.0) + thread_safe (0.3.6) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.3) + tzinfo (1.2.4) + thread_safe (~> 0.1) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + binding_of_caller + byebug + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + pg (~> 0.18) + pry-rails + puma (~> 3.7) + rails (~> 5.1.4) + spring + spring-watcher-listen (~> 2.0.0) + tzinfo-data + +BUNDLED WITH + 1.15.4 diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..e85f91391 --- /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/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /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 000000000..0ff5442f4 --- /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 000000000..4ac8823b0 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::API +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb new file mode 100644 index 000000000..ca3b6e024 --- /dev/null +++ b/app/controllers/customers_controller.rb @@ -0,0 +1,2 @@ +class CustomersController < ApplicationController +end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb new file mode 100644 index 000000000..6c4c51614 --- /dev/null +++ b/app/controllers/movies_controller.rb @@ -0,0 +1,2 @@ +class MoviesController < ApplicationController +end diff --git a/app/controllers/rentals_controller.rb b/app/controllers/rentals_controller.rb new file mode 100644 index 000000000..58c72b791 --- /dev/null +++ b/app/controllers/rentals_controller.rb @@ -0,0 +1,2 @@ +class RentalsController < ApplicationController +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 000000000..a009ace51 --- /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 000000000..286b2239d --- /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 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/customer.rb b/app/models/customer.rb new file mode 100644 index 000000000..0b5277335 --- /dev/null +++ b/app/models/customer.rb @@ -0,0 +1,2 @@ +class Customer < ApplicationRecord +end diff --git a/app/models/movie.rb b/app/models/movie.rb new file mode 100644 index 000000000..dc614df15 --- /dev/null +++ b/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ApplicationRecord +end diff --git a/app/models/rental.rb b/app/models/rental.rb new file mode 100644 index 000000000..79e3a65ca --- /dev/null +++ b/app/models/rental.rb @@ -0,0 +1,2 @@ +class Rental < ApplicationRecord +end diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 000000000..cbd34d2e9 --- /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 000000000..37f0bddbd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 000000000..66e9889e8 --- /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 000000000..5badb2fde --- /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 000000000..d87d5f578 --- /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 000000000..104e40c1c --- /dev/null +++ b/bin/setup @@ -0,0 +1,35 @@ +#!/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') + + + # 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 000000000..fb2ec2ebb --- /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 000000000..a8e4462f2 --- /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/config.ru b/config.ru new file mode 100644 index 000000000..f7ba0b527 --- /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 000000000..7d3c866ff --- /dev/null +++ b/config/application.rb @@ -0,0 +1,40 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "action_cable/engine" +# require "sprockets/railtie" +require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module VideoStoreAPI + 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. + + # Only loads a smaller set of middleware suitable for API only apps. + # Middleware like session, flash, cookies can be added back manually. + # Skip views, helpers and assets when generating a new resource. + config.api_only = true + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 000000000..30f5120df --- /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 000000000..ad59bcd88 --- /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: VideoStoreAPI_production diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 000000000..720570700 --- /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: VideoStoreAPI_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: VideoStoreAPI + + # 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: VideoStoreAPI_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: VideoStoreAPI_production + username: VideoStoreAPI + password: <%= ENV['VIDEOSTOREAPI_DATABASE_PASSWORD'] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 000000000..426333bb4 --- /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 000000000..abc82221c --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,47 @@ +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 + + + # 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 000000000..3bd8115ea --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,83 @@ +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? + + + # 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 = "VideoStoreAPI_#{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 000000000..8e5cbde53 --- /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 000000000..89d2efab2 --- /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/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /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/cors.rb b/config/initializers/cors.rb new file mode 100644 index 000000000..3b1c1b5ed --- /dev/null +++ b/config/initializers/cors.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Avoid CORS issues when API is called from the frontend app. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. + +# Read more: https://github.com/cyu/rack-cors + +# Rails.application.config.middleware.insert_before 0, Rack::Cors do +# allow do +# origins 'example.com' +# +# resource '*', +# headers: :any, +# methods: [:get, :post, :put, :patch, :delete, :options, :head] +# end +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /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 000000000..ac033bf9d --- /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 000000000..dc1899682 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..bbfc3961b --- /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 000000000..decc5a857 --- /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 000000000..1e19380dc --- /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 000000000..787824f88 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 000000000..bdf7d522e --- /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: 275783e1bf40670c9066d6501d15c3734cf261fc0e6e4738a3a8046970a56493085dae894f60b57b6af7121644d8452d55c1db3bd0593fc370104d96f0ad20ad + +test: + secret_key_base: d7880f2516e5ce9df5e0046481c9d71583821cccd5cab24e9e8288a2847f5185585a30c6c2b23381307611ffe2a27aa5736cd7d444ec1520ca02f2835393f60f + +# 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 000000000..c9119b40c --- /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/migrate/20171106204850_create_movies.rb b/db/migrate/20171106204850_create_movies.rb new file mode 100644 index 000000000..84782a1b7 --- /dev/null +++ b/db/migrate/20171106204850_create_movies.rb @@ -0,0 +1,12 @@ +class CreateMovies < ActiveRecord::Migration[5.1] + def change + create_table :movies do |t| + t.string :title + t.string :overview + t.string :release_date + t.integer :inventory + + t.timestamps + end + end +end diff --git a/db/migrate/20171106205120_create_customers.rb b/db/migrate/20171106205120_create_customers.rb new file mode 100644 index 000000000..0a05c4bad --- /dev/null +++ b/db/migrate/20171106205120_create_customers.rb @@ -0,0 +1,15 @@ +class CreateCustomers < ActiveRecord::Migration[5.1] + def change + create_table :customers do |t| + t.string :name + t.string :registered_at + t.string :address + t.string :city + t.string :state + t.string :postal_code + t.string :phone + + t.timestamps + end + end +end diff --git a/db/migrate/20171106205158_create_rentals.rb b/db/migrate/20171106205158_create_rentals.rb new file mode 100644 index 000000000..733f733c1 --- /dev/null +++ b/db/migrate/20171106205158_create_rentals.rb @@ -0,0 +1,9 @@ +class CreateRentals < ActiveRecord::Migration[5.1] + def change + create_table :rentals do |t| + t.string :due_date + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..70f500c1d --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,45 @@ +# 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: 20171106205158) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "customers", force: :cascade do |t| + t.string "name" + t.string "registered_at" + t.string "address" + t.string "city" + t.string "state" + t.string "postal_code" + t.string "phone" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "overview" + t.string "release_date" + t.integer "inventory" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "rentals", force: :cascade do |t| + t.string "due_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/log/.keep b/log/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 000000000..37b576a4a --- /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/controllers/.keep b/test/controllers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/controllers/customers_controller_test.rb b/test/controllers/customers_controller_test.rb new file mode 100644 index 000000000..5e123f6cd --- /dev/null +++ b/test/controllers/customers_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe CustomersController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb new file mode 100644 index 000000000..67fabbcfb --- /dev/null +++ b/test/controllers/movies_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe MoviesController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end diff --git a/test/controllers/rentals_controller_test.rb b/test/controllers/rentals_controller_test.rb new file mode 100644 index 000000000..f0227216c --- /dev/null +++ b/test/controllers/rentals_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +describe RentalsController do + # it "must be a real test" do + # flunk "Need real tests" + # end +end diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/customers.yml b/test/fixtures/customers.yml new file mode 100644 index 000000000..bf442fa90 --- /dev/null +++ b/test/fixtures/customers.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + registered_at: MyString + address: MyString + city: MyString + state: MyString + postal_code: MyString + phone: MyString + +two: + name: MyString + registered_at: MyString + address: MyString + city: MyString + state: MyString + postal_code: MyString + phone: MyString diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/movies.yml b/test/fixtures/movies.yml new file mode 100644 index 000000000..d774de5f1 --- /dev/null +++ b/test/fixtures/movies.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + overview: MyString + release_date: MyString + inventory: 1 + +two: + title: MyString + overview: MyString + release_date: MyString + inventory: 1 diff --git a/test/fixtures/rentals.yml b/test/fixtures/rentals.yml new file mode 100644 index 000000000..dcda01852 --- /dev/null +++ b/test/fixtures/rentals.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + due_date: MyString + +two: + due_date: MyString diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/models/customer_test.rb b/test/models/customer_test.rb new file mode 100644 index 000000000..5ebc5c850 --- /dev/null +++ b/test/models/customer_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Customer do + let(:customer) { Customer.new } + + it "must be valid" do + value(customer).must_be :valid? + end +end diff --git a/test/models/movie_test.rb b/test/models/movie_test.rb new file mode 100644 index 000000000..34d1d30a5 --- /dev/null +++ b/test/models/movie_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Movie do + let(:movie) { Movie.new } + + it "must be valid" do + value(movie).must_be :valid? + end +end diff --git a/test/models/rental_test.rb b/test/models/rental_test.rb new file mode 100644 index 000000000..6ea53d94f --- /dev/null +++ b/test/models/rental_test.rb @@ -0,0 +1,9 @@ +require "test_helper" + +describe Rental do + let(:rental) { Rental.new } + + it "must be valid" do + value(rental).must_be :valid? + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 000000000..10594a324 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,26 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path("../../config/environment", __FILE__) +require "rails/test_help" +require "minitest/rails" +require "minitest/reporters" # for Colorized output + +# For colorful output! +Minitest::Reporters.use!( + Minitest::Reporters::SpecReporter.new, + ENV, + Minitest.backtrace_filter +) + + +# To add Capybara feature tests add `gem "minitest-rails-capybara"` +# to the test group in the Gemfile and uncomment the following: +# require "minitest/rails/capybara" + +# Uncomment for awesome colorful output +# require "minitest/pride" + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + # Add more helper methods to be used by all tests here... +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 000000000..e69de29bb From 308c4bd9213554269189b94ba5b2b3043808cbba Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Mon, 6 Nov 2017 13:07:24 -0800 Subject: [PATCH 02/21] Established model relationships --- Gemfile | 2 +- Gemfile.lock | 8 ++++++++ app/models/customer.rb | 1 + app/models/movie.rb | 1 + app/models/rental.rb | 2 ++ erd.pdf | Bin 0 -> 26035 bytes 6 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 erd.pdf diff --git a/Gemfile b/Gemfile index 4ae55c93d..a01ca88b1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end - +gem 'rails-erd', require: false, group: :development # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.4' # Use postgresql as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index 484707437..726161cea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,6 +48,7 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.3) byebug (9.1.0) + choice (0.2.0) coderay (1.1.2) concurrent-ruby (1.0.5) crass (1.0.2) @@ -110,6 +111,11 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) + rails-erd (1.5.2) + activerecord (>= 3.2) + activesupport (>= 3.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) rails-html-sanitizer (1.0.3) loofah (~> 2.0) railties (5.1.4) @@ -122,6 +128,7 @@ GEM rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) + ruby-graphviz (1.2.3) ruby-progressbar (1.9.0) ruby_dep (1.5.0) spring (2.0.2) @@ -162,6 +169,7 @@ DEPENDENCIES pry-rails puma (~> 3.7) rails (~> 5.1.4) + rails-erd spring spring-watcher-listen (~> 2.0.0) tzinfo-data diff --git a/app/models/customer.rb b/app/models/customer.rb index 0b5277335..d2533dbf9 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,2 +1,3 @@ class Customer < ApplicationRecord + has_many :rentals end diff --git a/app/models/movie.rb b/app/models/movie.rb index dc614df15..b8b339cbc 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,2 +1,3 @@ class Movie < ApplicationRecord + has_many :rentals end diff --git a/app/models/rental.rb b/app/models/rental.rb index 79e3a65ca..e001ff37c 100644 --- a/app/models/rental.rb +++ b/app/models/rental.rb @@ -1,2 +1,4 @@ class Rental < ApplicationRecord + belongs_to :customer + belongs_to :movie end diff --git a/erd.pdf b/erd.pdf new file mode 100644 index 0000000000000000000000000000000000000000..df020bf7829fbab48e12713a1609a5bbb3779b9f GIT binary patch literal 26035 zcmb@t19WCfw>H|blMXtzZM{*)wr$&X$F_}*ZQJSCNyoO0o8J4|=R0SdbMAldxOc4e zzN>0ht(vnis-CK6E)rQmVHyTnCTNoWz3aV`qMMwl{y}JFe0qEveRF6oE_^ykBWn{! zQ+$?Bkvu+~u$iT!k^Se>QqR#y(8$2X&j6 z>x#O%)ks428MIboN|NS`*=ya()Cq~&cX(IK_WK?zkqI@Nd3%AXB#H3Av5g~@V{f$> z9LIulYrYNivtp0c2qz{U=AC^rJ|pQfx!?Jc&-XhHW8G>Fkik!9(ak?Cay)3PB!PRxeCXARYK+WJ)qbj>o11#;#Lc(9gx zyLBN;Q`SsoWkp2FVB>#fdDMje^2D^^R&RHyvrC>SN%Q+j*etd zhky)i?n!bW;-yfR(>c}T3yTVm>7}rlGYT{(CQs(+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?PGoA* zjcGH!B{_{WA(rI~z&MQZ51mm zV-1`eJb(7>N{-0#?BI~Ym# z5s_kq^_5ByRC8ReP*4C;cIA4^Lvn|>I2wiRFdn#uEH=NXy)pPq5*8Co{;^5dulupV zuR~fvrKWdn?qnI;qU#oww4#T(L5PG_l#oa#-N2_`6fQc)p;8AcACI6l9=No7{2sNG zo565KZ}O0S8s|x;LsIdrIP2BHyz2Wdx?@{EG$zTz7p^1QoRPM;FBbwD2A&1~bfKTr z)@D(tr%BihdMTk+e(4gy>=BBKU>0#LUX{?(C_(7FTj$ILVFEd`TGEV?iB;fajF*t7 zz%TIxRm2eS$*L6Aasua9O|3&Ov{jIz8yI8Vqo&yko1xE-ya>v_j!<<%Jr}#zt?L8Z zf4a&i8-0Hm4t2~Bs@*cZ2R}5!(k|cN8q&HHB2R7t9z2h8EZw;Kdg>heASmM^fO z6bAHaTJ(CTN_QRrkVlYS!^7Ow-G?5<5C02A?(P1cpx>nLzk;k?&7EyLZGGs0Jp8Dz z|9Jcxe8?sv3giO_0RVi0KmZ>AC~UyT$BH`t&-356`i&!hXX}o_;Qf`dCJK<~>SXEh z9<`UnUpb--(x@#gQ2EoN6b`?cb^mJHIzeQ9W5)jy1)z*7PL{vhIRD%J4_VRM)e4N# z9RNW%sB-@QJ?I4m1V94xVETXAfC8Z3#KzwTJ>-9Fd;oqS6cX?6HWa`Q^|b$P>8-Uk50C-UF@0zjbO{KdcJ0u%rMQFHLWZ73GvKWxG% z=;D9*0YU$~AL=3e$Iso>9K|to{c9r>En6SdJV41RG@YDKTu#&|e$Ns`2-pb)>HOEV z3<}dJ&L<)O6atEX-irVP`1vgaMFa)FRw8^NKtUiMYM_FWIRAf_e`!zL+);m#za|zC P^>l@Bn3-kO Date: Mon, 6 Nov 2017 13:21:44 -0800 Subject: [PATCH 03/21] Added customer column account_credit --- db/migrate/20171106211848_add_account_credit.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20171106211848_add_account_credit.rb diff --git a/db/migrate/20171106211848_add_account_credit.rb b/db/migrate/20171106211848_add_account_credit.rb new file mode 100644 index 000000000..3f3bbcc37 --- /dev/null +++ b/db/migrate/20171106211848_add_account_credit.rb @@ -0,0 +1,5 @@ +class AddAccountCredit < ActiveRecord::Migration[5.1] + def change + add_column :customers, :account_credit, :decimal + end +end diff --git a/db/schema.rb b/db/schema.rb index 70f500c1d..e9e89ba01 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171106205158) do +ActiveRecord::Schema.define(version: 20171106211848) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -25,6 +25,7 @@ t.string "phone" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.decimal "account_credit" end create_table "movies", force: :cascade do |t| From d1cb14020bac0f1eefcdf9c7f6f3514a765e1b40 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 6 Nov 2017 13:50:05 -0800 Subject: [PATCH 04/21] Routes created. --- config/routes.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 787824f88..ec765493b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,6 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + resources :movies, only: [:index, :show, :create] + + get '/customers', to: 'customers#index' end From e6c4f730c5f48ab2dccead02841dc0b2bb4c7e17 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 6 Nov 2017 13:56:51 -0800 Subject: [PATCH 05/21] Movies controller methods created. --- app/controllers/customers_controller.rb | 1 + app/controllers/movies_controller.rb | 34 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index ca3b6e024..f8b6566e0 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -1,2 +1,3 @@ class CustomersController < ApplicationController + end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 6c4c51614..0ee67627b 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,2 +1,36 @@ class MoviesController < ApplicationController + def index + movies = Movie.all + + render( + json: movies.as_json(only: [:title, :overview, :release_date, :inventory]),status: :ok + ) + end + + def show + movie = Movie.find_by(id: params[:id]) + + if movie + render json: movie.as_json(only: [:title, :overview, :release_date, :inventory]), status: :ok + else + render json: { ok: false }, status: :not_found + end + + end + + def create + movie = + Movie.create(movie_params) + if movie.valid? + render json: + movie.as_json(only: [:title, :overview, :release_date, :inventory]), status: :created + else + render json: {errors: movie.errors.messages}, status: :bad_request + end + end + + private + def movie_params + params.require(:movie).permit(:title, :overview, :release_date, :inventory) + end end From bb3f0639fd7071b98812bfb647883c798703481b Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 6 Nov 2017 14:03:59 -0800 Subject: [PATCH 06/21] Movies controller tests created. --- test/controllers/movies_controller_test.rb | 92 +++++++++++++++++++++- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index 67fabbcfb..b90dc3f95 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -1,7 +1,93 @@ require "test_helper" describe MoviesController do - # it "must be a real test" do - # flunk "Need real tests" - # end + describe "index" do + it "is a real working route" do + get movies_url + must_respond_with :success + end + + it "returns json" do + get movies_url + response.header['Content-Type'].must_include 'json' + end + + it "returns an Array" do + get movies_url + + body = JSON.parse(response.body) + body.must_be_kind_of Array + end + + it "returns all of the movies" do + get movies_url + + body = JSON.parse(response.body) + body.length.must_equal Movie.count + end + + it "returns movies with exactly the required fields" do + keys = %w(title overview release_date inventory) + get movies_url + body = JSON.parse(response.body) + body.each do |movie| + movie.keys.sort.must_equal keys + end + end + + it "returns an empty array if there are no movies" do + Movie.destroy_all + get movies_url + must_respond_with :success + body = JSON.parse(response.body) + body.must_be_kind_of Array + body.must_be :empty? + end + end + + describe "show" do + it "can get a movie" do + get movie_path(movies(:two).id) + must_respond_with :success + end + end + + describe "create" do + let(:movie_data) { + { + title: "Jaws", + overview: "A great white shark terrorizes townspeople.", + release_date: "1975-06-19", + inventory: 6 + } + } + + it "Creates a new movie" do + assert_difference "Movie.count", 1 do + post movies_url, params: { movie: movie_data } + assert_response :success + end + + body = JSON.parse(response.body) + body.must_be_kind_of Hash + body.must_include "id" + + # Check that the ID matches + Movie.find(body["id"]).title.must_equal movie_data[:title] + end + + it "Returns an error for an invalid movie" do + bad_data = movie_data.clone() + bad_data.delete(:title) + assert_no_difference "Movie.count" do + post movies_url, params: { movie: bad_data } + assert_response :bad_request + end + + body = JSON.parse(response.body) + body.must_be_kind_of Hash + body.must_include "errors" + body["errors"].must_include "title" + end + end end From 2c701a25876554e1e4781cb43bce63089c832ce6 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 6 Nov 2017 14:05:25 -0800 Subject: [PATCH 07/21] Added validations to movie model. --- app/models/movie.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/movie.rb b/app/models/movie.rb index b8b339cbc..796c8a0ee 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,3 +1,4 @@ class Movie < ApplicationRecord has_many :rentals + validates :title, presence: true end From d1dd27d97aae221367aa744bf8e64ac6eb9792f4 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 6 Nov 2017 14:21:03 -0800 Subject: [PATCH 08/21] Movie controller tests passing. --- app/controllers/movies_controller.rb | 4 ++-- test/controllers/movies_controller_test.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 0ee67627b..5e1118bf1 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -11,7 +11,7 @@ def show movie = Movie.find_by(id: params[:id]) if movie - render json: movie.as_json(only: [:title, :overview, :release_date, :inventory]), status: :ok + render json: movie.as_json(only: [:id, :title, :overview, :release_date, :inventory]), status: :ok else render json: { ok: false }, status: :not_found end @@ -23,7 +23,7 @@ def create Movie.create(movie_params) if movie.valid? render json: - movie.as_json(only: [:title, :overview, :release_date, :inventory]), status: :created + movie.as_json(only: [:id, :title, :overview, :release_date, :inventory]), status: :created else render json: {errors: movie.errors.messages}, status: :bad_request end diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index b90dc3f95..bc6feb3ea 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -27,7 +27,7 @@ end it "returns movies with exactly the required fields" do - keys = %w(title overview release_date inventory) + keys = %w(inventory overview release_date title) get movies_url body = JSON.parse(response.body) body.each do |movie| @@ -55,10 +55,10 @@ describe "create" do let(:movie_data) { { - title: "Jaws", - overview: "A great white shark terrorizes townspeople.", - release_date: "1975-06-19", - inventory: 6 + title: "Jaws 2", + overview: "An insatiable great white shark terrorizes the townspeople of Amity Island AGAIN, The police chief, an oceanographer and a grizzled shark hunter seek to destroy the bloodthirsty beast.", + release_date: "1981-06-19", + inventory: 4 } } From 7aaeb07bbf665cdf971e16014ffea6a5b37163c8 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Mon, 6 Nov 2017 14:38:04 -0800 Subject: [PATCH 09/21] Added model test for movies --- test/fixtures/movies.yml | 6 ++++++ test/models/movie_test.rb | 11 ++++++++++- test/models/rental_test.rb | 6 +++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/fixtures/movies.yml b/test/fixtures/movies.yml index d774de5f1..09045f9ee 100644 --- a/test/fixtures/movies.yml +++ b/test/fixtures/movies.yml @@ -11,3 +11,9 @@ two: overview: MyString release_date: MyString inventory: 1 + +jaws: + title: Jaws + overview: A movie about a beautiful shark + release_date: 1975 + inventory: 10 diff --git a/test/models/movie_test.rb b/test/models/movie_test.rb index 34d1d30a5..abae9540d 100644 --- a/test/models/movie_test.rb +++ b/test/models/movie_test.rb @@ -2,8 +2,17 @@ describe Movie do let(:movie) { Movie.new } + let(:jaws) { movies(:jaws) } it "must be valid" do - value(movie).must_be :valid? + jaws.valid?.must_equal true + jaws.title = nil + jaws.valid?.must_equal false + end + + it "must have a title" do + movie.valid?.must_equal false + movie.title = "A movie" + movie.valid?.must_equal true end end diff --git a/test/models/rental_test.rb b/test/models/rental_test.rb index 6ea53d94f..081d544c9 100644 --- a/test/models/rental_test.rb +++ b/test/models/rental_test.rb @@ -3,7 +3,7 @@ describe Rental do let(:rental) { Rental.new } - it "must be valid" do - value(rental).must_be :valid? - end + # it "must be valid" do + # value(rental).must_be :valid? + # end end From 2bd4b6198d277e1dc223c2b530ec758d84cb8f80 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 09:47:09 -0800 Subject: [PATCH 10/21] Added serializer --- Gemfile | 1 + Gemfile.lock | 9 +++++++++ app/controllers/movies_controller.rb | 7 +++---- app/models/movie.rb | 4 ++++ app/serializers/movie_serializer.rb | 3 +++ 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 app/serializers/movie_serializer.rb diff --git a/Gemfile b/Gemfile index a01ca88b1..f58646f96 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end +gem "active_model_serializers" gem 'rails-erd', require: false, group: :development # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.4' diff --git a/Gemfile.lock b/Gemfile.lock index 726161cea..6857f7127 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,6 +24,11 @@ GEM erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) + active_model_serializers (0.10.6) + actionpack (>= 4.1, < 6) + activemodel (>= 4.1, < 6) + case_transform (>= 0.2) + jsonapi-renderer (>= 0.1.1.beta1, < 0.2) activejob (5.1.4) activesupport (= 5.1.4) globalid (>= 0.3.6) @@ -48,6 +53,8 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.3) byebug (9.1.0) + case_transform (0.2) + activesupport choice (0.2.0) coderay (1.1.2) concurrent-ruby (1.0.5) @@ -62,6 +69,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + jsonapi-renderer (0.1.3) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -158,6 +166,7 @@ PLATFORMS ruby DEPENDENCIES + active_model_serializers better_errors binding_of_caller byebug diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 5e1118bf1..a3de63cbe 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -3,7 +3,7 @@ def index movies = Movie.all render( - json: movies.as_json(only: [:title, :overview, :release_date, :inventory]),status: :ok + json: movies, status: :ok ) end @@ -11,7 +11,7 @@ def show movie = Movie.find_by(id: params[:id]) if movie - render json: movie.as_json(only: [:id, :title, :overview, :release_date, :inventory]), status: :ok + render json: movie, status: :ok else render json: { ok: false }, status: :not_found end @@ -22,8 +22,7 @@ def create movie = Movie.create(movie_params) if movie.valid? - render json: - movie.as_json(only: [:id, :title, :overview, :release_date, :inventory]), status: :created + render json: movie, status: :created else render json: {errors: movie.errors.messages}, status: :bad_request end diff --git a/app/models/movie.rb b/app/models/movie.rb index 796c8a0ee..fe6f50c69 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,4 +1,8 @@ class Movie < ApplicationRecord has_many :rentals validates :title, presence: true + + def available_inventory + return "hmmm" + end end diff --git a/app/serializers/movie_serializer.rb b/app/serializers/movie_serializer.rb new file mode 100644 index 000000000..510aad5d6 --- /dev/null +++ b/app/serializers/movie_serializer.rb @@ -0,0 +1,3 @@ +class MovieSerializer < ActiveModel::Serializer + attributes :id, :title, :overview, :release_date, :inventory, :available_inventory +end From cfd5db3c297c72efb494ea3d24b7f2ca95c5d17d Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 10:04:09 -0800 Subject: [PATCH 11/21] Figuring out avaliable_inventory call --- app/models/movie.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/movie.rb b/app/models/movie.rb index fe6f50c69..78e3db401 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -3,6 +3,7 @@ class Movie < ApplicationRecord validates :title, presence: true def available_inventory - return "hmmm" + # return Movie.find(:id).inventory + return end end From d20b9ab692b05682aa9f3f0ad0dfc68397c5a711 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 10:09:00 -0800 Subject: [PATCH 12/21] Available inventory updated to match inventory --- app/models/movie.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/movie.rb b/app/models/movie.rb index 78e3db401..b3b0b1d28 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -3,7 +3,6 @@ class Movie < ApplicationRecord validates :title, presence: true def available_inventory - # return Movie.find(:id).inventory - return + return self.inventory end end From 0563508029e82451fb34947503a1fdb713f03eee Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 7 Nov 2017 10:29:43 -0800 Subject: [PATCH 13/21] Updated Customers controller and model, added serializer. --- app/controllers/customers_controller.rb | 6 ++++++ app/models/customer.rb | 4 ++++ app/serializers/customer_serializer.rb | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 app/serializers/customer_serializer.rb diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index f8b6566e0..794e61b4a 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -1,3 +1,9 @@ class CustomersController < ApplicationController + def index + customers = Customer.all + render( + json: customers, status: :ok + ) + end end diff --git a/app/models/customer.rb b/app/models/customer.rb index d2533dbf9..a4f687328 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,3 +1,7 @@ class Customer < ApplicationRecord has_many :rentals + + def movies_checked_out_count + return 0 + end end diff --git a/app/serializers/customer_serializer.rb b/app/serializers/customer_serializer.rb new file mode 100644 index 000000000..21de979ab --- /dev/null +++ b/app/serializers/customer_serializer.rb @@ -0,0 +1,3 @@ +class CustomerSerializer < ActiveModel::Serializer + attributes :id, :name, :registered_at, :address, :city, :state, :postal_code, :phone, :account_credit, :movies_checked_out_count +end From 569b1c1b8c36fb5143793cd1b82ab02a806593d9 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 7 Nov 2017 11:09:09 -0800 Subject: [PATCH 14/21] Added field for movie controller tests, all passing currently. --- app/controllers/movies_controller.rb | 3 +-- test/controllers/movies_controller_test.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index a3de63cbe..cd6f47e96 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -19,8 +19,7 @@ def show end def create - movie = - Movie.create(movie_params) + movie = Movie.create(movie_params) if movie.valid? render json: movie, status: :created else diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index bc6feb3ea..fbaf301d2 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -27,7 +27,7 @@ end it "returns movies with exactly the required fields" do - keys = %w(inventory overview release_date title) + keys = %w(available_inventory id inventory overview release_date title) get movies_url body = JSON.parse(response.body) body.each do |movie| From d1ca2fc7148beab47bd64a5f68a57eb1c821561f Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 12:52:44 -0800 Subject: [PATCH 15/21] All smoke tests are passing --- app/controllers/movies_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index cd6f47e96..eeaf39ca3 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -21,7 +21,7 @@ def show def create movie = Movie.create(movie_params) if movie.valid? - render json: movie, status: :created + render json: movie, status: :ok else render json: {errors: movie.errors.messages}, status: :bad_request end @@ -29,6 +29,6 @@ def create private def movie_params - params.require(:movie).permit(:title, :overview, :release_date, :inventory) + params.permit(:title, :overview, :release_date, :inventory) end end From c6736a0add7405d798a5223df447d513d786ce97 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 7 Nov 2017 13:10:17 -0800 Subject: [PATCH 16/21] Customer tests passing for index method. --- Gemfile | 1 + Gemfile.lock | 2 + app/controllers/movies_controller.rb | 3 +- test/controllers/customers_controller_test.rb | 46 +++++++++++++++++-- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index f58646f96..15e062bf3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end +gem 'awesome_print' gem "active_model_serializers" gem 'rails-erd', require: false, group: :development # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' diff --git a/Gemfile.lock b/Gemfile.lock index 6857f7127..5de3e261b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,7 @@ GEM tzinfo (~> 1.1) ansi (1.5.0) arel (8.0.0) + awesome_print (1.8.0) better_errors (2.4.0) coderay (>= 1.0.0) erubi (>= 1.0.0) @@ -167,6 +168,7 @@ PLATFORMS DEPENDENCIES active_model_serializers + awesome_print better_errors binding_of_caller byebug diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index cd6f47e96..da0de8f30 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -29,6 +29,7 @@ def create private def movie_params - params.require(:movie).permit(:title, :overview, :release_date, :inventory) + ap params + return params.require(:movie).permit(:title, :overview, :release_date, :inventory) end end diff --git a/test/controllers/customers_controller_test.rb b/test/controllers/customers_controller_test.rb index 5e123f6cd..5c93b4af1 100644 --- a/test/controllers/customers_controller_test.rb +++ b/test/controllers/customers_controller_test.rb @@ -1,7 +1,47 @@ require "test_helper" describe CustomersController do - # it "must be a real test" do - # flunk "Need real tests" - # end + describe "index" do + it "is a real working route" do + get customers_url + must_respond_with :success + end + + it "returns json" do + get customers_url + response.header['Content-Type'].must_include 'json' + end + + it "returns an Array" do + get customers_url + + body = JSON.parse(response.body) + body.must_be_kind_of Array + end + + it "returns all of the customers" do + get customers_url + + body = JSON.parse(response.body) + body.length.must_equal Customer.count + end + + it "returns customers with exactly the required fields" do + keys = %w(account_credit address city id movies_checked_out_count name phone postal_code registered_at state) + get customers_url + body = JSON.parse(response.body) + body.each do |customer| + customer.keys.sort.must_equal keys + end + end + + it "returns an empty array if there are no customers" do + Customer.destroy_all + get customers_url + must_respond_with :success + body = JSON.parse(response.body) + body.must_be_kind_of Array + body.must_be :empty? + end + end end From 2bf29ec4e803f2773c1763f85d1f8998db843cfc Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 13:18:16 -0800 Subject: [PATCH 17/21] All test passing for updated create movie method --- test/controllers/movies_controller_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index fbaf301d2..cefd80e72 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -64,16 +64,16 @@ it "Creates a new movie" do assert_difference "Movie.count", 1 do - post movies_url, params: { movie: movie_data } - assert_response :success + post movies_url, params: movie_data + assert_response :ok end - body = JSON.parse(response.body) - body.must_be_kind_of Hash - body.must_include "id" - - # Check that the ID matches - Movie.find(body["id"]).title.must_equal movie_data[:title] + # body = JSON.parse(response.body) + # body.must_be_kind_of Hash + # body.must_include "id" + # + # # Check that the ID matches + # Movie.find(body["id"]).title.must_equal movie_data[:title] end it "Returns an error for an invalid movie" do From 0a8051f9ecc632c35c517a1e4a602aa0d321b24c Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 7 Nov 2017 13:19:13 -0800 Subject: [PATCH 18/21] Forgot to uncomment tests, but hey still passing. --- test/controllers/movies_controller_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index cefd80e72..0f8c89ec1 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -68,12 +68,12 @@ assert_response :ok end - # body = JSON.parse(response.body) - # body.must_be_kind_of Hash - # body.must_include "id" - # - # # Check that the ID matches - # Movie.find(body["id"]).title.must_equal movie_data[:title] + body = JSON.parse(response.body) + body.must_be_kind_of Hash + body.must_include "id" + + # Check that the ID matches + Movie.find(body["id"]).title.must_equal movie_data[:title] end it "Returns an error for an invalid movie" do From fc50485acb7b0e8ec87a99fef0c5a2010f8319a2 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Tue, 7 Nov 2017 14:02:05 -0800 Subject: [PATCH 19/21] Index movies only returns 3 required fields --- app/controllers/movies_controller.rb | 2 +- test/controllers/movies_controller_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index eeaf39ca3..b43319179 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -3,7 +3,7 @@ def index movies = Movie.all render( - json: movies, status: :ok + json: movies.as_json(only: [:id, :title, :release_date]), status: :ok ) end diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index 0f8c89ec1..0fa483ad6 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -27,7 +27,7 @@ end it "returns movies with exactly the required fields" do - keys = %w(available_inventory id inventory overview release_date title) + keys = %w(id release_date title) get movies_url body = JSON.parse(response.body) body.each do |movie| @@ -64,7 +64,7 @@ it "Creates a new movie" do assert_difference "Movie.count", 1 do - post movies_url, params: movie_data + post movies_url, params: movie_data assert_response :ok end From 18bf8e1ff68b44477e13a0048b7f14f9250b4118 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Wed, 8 Nov 2017 15:00:48 -0800 Subject: [PATCH 20/21] Extra testing in movies controller, customer model needs the presence of name --- app/controllers/movies_controller.rb | 2 +- app/models/customer.rb | 1 + test/controllers/movies_controller_test.rb | 43 ++++++++++++++-------- test/models/customer_test.rb | 8 +++- test/models/movie_test.rb | 2 - 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index b43319179..2cbb700cb 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,7 +1,6 @@ class MoviesController < ApplicationController def index movies = Movie.all - render( json: movies.as_json(only: [:id, :title, :release_date]), status: :ok ) @@ -28,6 +27,7 @@ def create end private + def movie_params params.permit(:title, :overview, :release_date, :inventory) end diff --git a/app/models/customer.rb b/app/models/customer.rb index a4f687328..791ae8ad5 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,6 @@ class Customer < ApplicationRecord has_many :rentals + validates :name, presence: true def movies_checked_out_count return 0 diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index 0fa483ad6..7c1a8d14e 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -2,26 +2,24 @@ describe MoviesController do describe "index" do - it "is a real working route" do + it "is working route" do get movies_url must_respond_with :success end - it "returns json" do + it "returns json for a request" do get movies_url response.header['Content-Type'].must_include 'json' end it "returns an Array" do get movies_url - body = JSON.parse(response.body) body.must_be_kind_of Array end it "returns all of the movies" do get movies_url - body = JSON.parse(response.body) body.length.must_equal Movie.count end @@ -48,8 +46,22 @@ describe "show" do it "can get a movie" do get movie_path(movies(:two).id) + response.header['Content-Type'].must_include 'json' must_respond_with :success end + + it "returns individual movies with exactly the required fields" do + keys = %w(available_inventory id inventory overview release_date title) + get movie_path(movies(:two).id) + body = JSON.parse(response.body) + body.keys.sort.must_equal keys + end + + it "gives 404 if movie does not exist" do + get movie_path(99999999999999) + response.header['Content-Type'].must_include 'json' + must_respond_with :not_found + end end describe "create" do @@ -62,32 +74,33 @@ } } - it "Creates a new movie" do + it "creates a new movie" do assert_difference "Movie.count", 1 do post movies_url, params: movie_data - assert_response :ok + must_respond_with :ok end body = JSON.parse(response.body) body.must_be_kind_of Hash body.must_include "id" - - # Check that the ID matches Movie.find(body["id"]).title.must_equal movie_data[:title] end - it "Returns an error for an invalid movie" do - bad_data = movie_data.clone() - bad_data.delete(:title) - assert_no_difference "Movie.count" do - post movies_url, params: { movie: bad_data } - assert_response :bad_request - end + it "returns a Json error for an invalid movie" do + bad_data = movie_data.delete(:title) + proc{post movies_url, params: bad_data}.must_change 'Movie.count', 0 body = JSON.parse(response.body) body.must_be_kind_of Hash body.must_include "errors" body["errors"].must_include "title" end + + it "doesn't create a movie if no title is given" do + proc{post movies_url, params: movie_data}.must_change 'Movie.count', 1 + bad_data = movie_data.delete(:title) + proc{post movies_url, params: bad_data}.must_change 'Movie.count', 0 + must_respond_with :bad_request + end end end diff --git a/test/models/customer_test.rb b/test/models/customer_test.rb index 5ebc5c850..37f7f5e5c 100644 --- a/test/models/customer_test.rb +++ b/test/models/customer_test.rb @@ -4,6 +4,12 @@ let(:customer) { Customer.new } it "must be valid" do - value(customer).must_be :valid? + customers(:one).valid?.must_equal true + end + + it "must have a name to be valid" do + customer.valid?.must_equal false + customer.name = "Name" + customer.valid?.must_equal true end end diff --git a/test/models/movie_test.rb b/test/models/movie_test.rb index abae9540d..97564a602 100644 --- a/test/models/movie_test.rb +++ b/test/models/movie_test.rb @@ -6,8 +6,6 @@ it "must be valid" do jaws.valid?.must_equal true - jaws.title = nil - jaws.valid?.must_equal false end it "must have a title" do From eaf5a172e350feebba1ccf32c84e9f8e980542f7 Mon Sep 17 00:00:00 2001 From: Laura Robertson Date: Wed, 8 Nov 2017 15:06:13 -0800 Subject: [PATCH 21/21] Added simple cov gem, and info to git ignore file --- .gitignore | 3 +++ Gemfile | 2 ++ Gemfile.lock | 8 ++++++++ test/test_helper.rb | 3 +++ 4 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 68ac019ec..1bce4a700 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ !/tmp/.keep .byebug_history + +## SimpleCov +/coverage/* diff --git a/Gemfile b/Gemfile index 15e062bf3..f58096061 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,8 @@ group :development do gem 'spring-watcher-listen', '~> 2.0.0' end +gem 'simplecov', :require => false, :group => :test + # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 5de3e261b..4fe7028a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,6 +61,7 @@ GEM concurrent-ruby (1.0.5) crass (1.0.2) debug_inspector (0.0.3) + docile (1.1.5) erubi (1.7.0) ffi (1.9.18) globalid (0.4.1) @@ -70,6 +71,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + json (2.0.2) jsonapi-renderer (0.1.3) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -140,6 +142,11 @@ GEM ruby-graphviz (1.2.3) ruby-progressbar (1.9.0) ruby_dep (1.5.0) + simplecov (0.15.0) + 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) @@ -181,6 +188,7 @@ DEPENDENCIES puma (~> 3.7) rails (~> 5.1.4) rails-erd + simplecov spring spring-watcher-listen (~> 2.0.0) tzinfo-data diff --git a/test/test_helper.rb b/test/test_helper.rb index 10594a324..597d04043 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start + ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment", __FILE__) require "rails/test_help"