+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+=======
+
+
+
+
+
+
+
+<<<<<<< HEAD
+>>>>>>> master
+
+
+
+
+=======
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> test/api_tests
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+=======
+<<<<<<< HEAD
+
+=======
+
+
+
+
+
+
+
+
+>>>>>>> test/api_tests
+>>>>>>> master
+
+
+
+
+
+
+<<<<<<< HEAD
+=======
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> master
+
+<<<<<<< HEAD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+=======
+
+
+=======
+
+
+
+>>>>>>> test/api_tests
+>>>>>>> master
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+=======
+<<<<<<< HEAD
+
+
+=======
+
+
+>>>>>>> test/api_tests
+>>>>>>> master
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+=======
+<<<<<<< HEAD
+
+
+>>>>>>> master
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+=======
+
+
+=======
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> test/api_tests
+>>>>>>> master
+
+
+
+
+
\ No newline at end of file
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 000000000..25c81fe39
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+ruby-2.5.1
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 000000000..8438dd596
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,58 @@
+source 'https://rubygems.org'
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
+
+ruby '2.5.1'
+gem 'rabl'
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '~> 5.2.1'
+# Use postgresql as the database for Active Record
+gem 'pg', '>= 0.18', '< 2.0'
+# Use Puma as the app server
+gem 'puma', '~> 3.11'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+# gem 'jbuilder', '~> 2.5'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 4.0'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use ActiveStorage variant
+# gem 'mini_magick', '~> 4.8'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+gem 'rabl'
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', '>= 1.1.0', require: false
+
+# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
+# gem 'rack-cors'
+gem 'will_paginate', '~> 3.1.0'
+
+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]
+
+group :development, :test do
+ gem 'pry-rails'
+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 000000000..1a4f29513
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,182 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (5.2.1)
+ actionpack (= 5.2.1)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ actionmailer (5.2.1)
+ actionpack (= 5.2.1)
+ actionview (= 5.2.1)
+ activejob (= 5.2.1)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.2.1)
+ actionview (= 5.2.1)
+ activesupport (= 5.2.1)
+ rack (~> 2.0)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ actionview (5.2.1)
+ activesupport (= 5.2.1)
+ builder (~> 3.1)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.2.1)
+ activesupport (= 5.2.1)
+ globalid (>= 0.3.6)
+ activemodel (5.2.1)
+ activesupport (= 5.2.1)
+ activerecord (5.2.1)
+ activemodel (= 5.2.1)
+ activesupport (= 5.2.1)
+ arel (>= 9.0)
+ activestorage (5.2.1)
+ actionpack (= 5.2.1)
+ activerecord (= 5.2.1)
+ marcel (~> 0.3.1)
+ activesupport (5.2.1)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ ansi (1.5.0)
+ arel (9.0.0)
+ bootsnap (1.3.2)
+ msgpack (~> 1.0)
+ builder (3.2.3)
+ byebug (10.0.2)
+ coderay (1.1.2)
+ concurrent-ruby (1.1.1)
+ crass (1.0.4)
+ docile (1.3.1)
+ erubi (1.7.1)
+ ffi (1.9.25)
+ globalid (0.4.1)
+ activesupport (>= 4.2.0)
+ i18n (1.1.1)
+ concurrent-ruby (~> 1.0)
+ json (2.1.0)
+ 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.3)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.7.1)
+ mini_mime (>= 0.1.1)
+ marcel (0.3.3)
+ mimemagic (~> 0.3.2)
+ method_source (0.9.1)
+ mimemagic (0.3.2)
+ mini_mime (1.0.1)
+ mini_portile2 (2.3.0)
+ minitest (5.11.3)
+ minitest-rails (3.0.0)
+ minitest (~> 5.8)
+ railties (~> 5.0)
+ minitest-reporters (1.3.5)
+ ansi
+ builder
+ minitest (>= 5.0)
+ ruby-progressbar
+ msgpack (1.2.4)
+ nio4r (2.3.1)
+ nokogiri (1.8.5)
+ mini_portile2 (~> 2.3.0)
+ pg (1.1.3)
+ pry (0.12.0)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ pry-rails (0.3.6)
+ pry (>= 0.10.4)
+ puma (3.12.0)
+ rabl (0.14.0)
+ activesupport (>= 2.3.14)
+ rack (2.0.6)
+ rack-test (1.1.0)
+ rack (>= 1.0, < 3)
+ rails (5.2.1)
+ actioncable (= 5.2.1)
+ actionmailer (= 5.2.1)
+ actionpack (= 5.2.1)
+ actionview (= 5.2.1)
+ activejob (= 5.2.1)
+ activemodel (= 5.2.1)
+ activerecord (= 5.2.1)
+ activestorage (= 5.2.1)
+ activesupport (= 5.2.1)
+ bundler (>= 1.3.0)
+ railties (= 5.2.1)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.0.4)
+ loofah (~> 2.2, >= 2.2.2)
+ railties (5.2.1)
+ actionpack (= 5.2.1)
+ activesupport (= 5.2.1)
+ method_source
+ rake (>= 0.8.7)
+ thor (>= 0.19.0, < 2.0)
+ rake (12.3.1)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
+ ruby-progressbar (1.10.0)
+ ruby_dep (1.5.0)
+ simplecov (0.16.1)
+ docile (~> 1.1)
+ 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.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ thor (0.20.0)
+ thread_safe (0.3.6)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ websocket-driver (0.7.0)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.3)
+ will_paginate (3.1.6)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bootsnap (>= 1.1.0)
+ byebug
+ listen (>= 3.0.5, < 3.2)
+ minitest-rails
+ minitest-reporters
+ pg (>= 0.18, < 2.0)
+ pry-rails
+ puma (~> 3.11)
+ rabl
+ rails (~> 5.2.1)
+ simplecov
+ spring
+ spring-watcher-listen (~> 2.0.0)
+ tzinfo-data
+ will_paginate (~> 3.1.0)
+
+RUBY VERSION
+ ruby 2.5.1p57
+
+BUNDLED WITH
+ 1.17.1
diff --git a/Guardfile b/Guardfile
new file mode 100644
index 000000000..e34f706f4
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,9 @@
+guard :minitest, autorun: false, spring: true do
+ watch(%r{^app/(.+).rb$}) { |m| "test/#{m[1]}_test.rb" }
+ watch(%r{^app/controllers/application_controller.rb$}) { 'test/controllers' }
+ watch(%r{^app/controllers/(.+)_controller.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
+ watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
+ watch(%r{^lib/(.+).rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
+ watch(%r{^test/.+_test.rb$})
+ watch(%r{^test/test_helper.rb$}) { 'test' }
+end
diff --git a/README.md b/README.md
index 53ab809c5..50db07891 100644
--- a/README.md
+++ b/README.md
@@ -308,4 +308,4 @@ Fields to return:
## What We're Looking For
-Check the [feedback template](./feedback.md) to see how we will evaluate your project.
+Check the [feedback template](feedback.md) to see how we will evaluate your project.
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..b1ef16702
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,111 @@
+class ApplicationController < ActionController::API
+ require 'cgi'
+
+private
+
+# User story: Any endpoint that returns a list should accept 3 optional query
+# parameters.
+#
+# The methods called within get_query_params parse query params
+# and return permitted params as instance variables.
+# To run this code before any controller action (and access these instance
+# variables), add this to the top of your controller class:
+# ` before_action :get_query_params, only: [ ] `
+ def get_query_params
+ @sorters = permit_sort_params
+ @page = permit_p_param
+ @num = permit_n_param
+ end
+
+ # This method returns a 1-D ordered Array of 1+ unique "sorters" (String)
+ # that are permitted for the controller calling this method.
+ # A "sorter" is the name of the JSON field to sort by.
+ # Each controller action permits different sort fields (@valid_sorters).
+ # You can't apply the same sorter more than once (occurrences after the first
+ # will be ignored).
+ # If there are multiple sorters, they are applied L --> R.
+ # The default sorter is "id".
+ def permit_sort_params
+ return [:id] unless params[:sort]
+ valid_sorters = {
+ 'customers' =>
+ { 'index' => %w(name registered_at postal_code),
+ 'history' => %w(checkout_date due_date title)
+ },
+ 'movies' =>
+ { 'index' => %w(title release_date),
+ 'history' => %w(checkout_date due_date name)
+ },
+ 'rentals' =>
+ { 'overdue' => %w(checkout_date due_date title name)
+ }
+ }
+
+ sorters = CGI.parse(request.query_string)["sort"].uniq
+ sorters = sorters.map{|sorter| sorter.gsub(' ', '_')}
+ sorters = sorters.select { |sorter| valid_sorters[controller_name][action_name].include?(sorter) }
+ return sorters.empty? ? ["id"] : sorters
+ end
+
+ def permit_n_param
+ if params[:n]
+ num = CGI.parse(request.query_string)["n"].uniq
+ num = num.map{|np| np.gsub(' ', '')}
+ # binding.pry
+ return num.empty? ? 1 : num.first.to_i
+ end
+ end
+
+ def permit_p_param
+ if params[:p]
+ # return 1 integer (see will_paginate gem)
+ page = CGI.parse(request.query_string)["p"].uniq
+ page = page.map{|p| p.gsub(' ', '')}
+ # binding.pry
+ return page.empty? ? 10 : page.first.to_i
+ end
+ end
+end
+
+# Note on CGI.parse:
+ # CGI.parse knows what to do if a query param appears > once in the url.
+ # it just adds it to the array!
+ # url = 'http://www.foo.com?id=4&empid=6'
+ # uri = URI.parse(url)
+ # params = CGI.parse(uri.query)
+ # params is now {"id"=>["4"], "empid"=>["6"]}
+# An example based on this app would be:
+# request.query_string = "sort=title&sort=title&sort=name&sort=bogus!& \
+# sort=registered%20at&p=3&p=-1&p=i+love+bubble+tea"
+# params = CGI.parse(request.query_string)
+# which would return:
+# { "sort"=>["title", "title", "name", "bogus!", "registered at"],
+# "p" => ["3", "-1", "i love bubble tea"] }
+#
+#
+#
+#
+# From README:
+# Any endpoint that returns a list should accept 3 optional query parameters:
+#
+# Name Value Description
+# sort string Sort objects by this field, in ascending order
+# n integer Number of responses to return per page
+# p integer Page of responses to return
+# So, for an API endpoint like GET /customers, the following requests should be valid:
+#
+# GET /customers: All customers, sorted by ID
+# GET /customers?sort=name: All customers, sorted by name
+# GET /customers?n=10&p=2: Customers 10-19, sorted by ID
+# GET /customers?sort=name&n=10&p=2: Customers 10-19, sorted by name
+# Of course, adding new features means you should be adding new controller tests to verify them.
+#
+# Things to note:
+#
+# Sorting by ID is the rails default
+# Possible sort fields:
+# Customers can be sorted by name, registered_at and postal_code
+# Movies can be sorted by title and release_date
+# Overdue rentals can be sorted by title, name, checkout_date and due_date
+# If the client requests both sorting and pagination, pagination should be relative to the sorted order
+# Check out the will_paginate gem
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..49415d39e
--- /dev/null
+++ b/app/controllers/customers_controller.rb
@@ -0,0 +1,45 @@
+class CustomersController < ApplicationController
+ before_action :get_query_params, only: [:index] # TODO: add :current and :history
+
+ def index
+ if @page || @num
+ @page ||= 1
+ @num ||= Customer.count
+ customers = Customer.all.paginate(:page => @page, :per_page => @num)
+ else
+ customers = Customer.all
+ end
+
+ @sorters.each do |sorter|
+ customers = customers.order(sorter.to_sym => :asc) # asc is default - just being explicit
+ end
+ @customers = customers
+ end
+
+# TODO: @sorters (user stories do not specify which fields must be sortable)
+# SJL: I'm thinking %w(checkout_date due_date title)
+ def current
+ @customer = Customer.find_by(id: params[:id])
+ @current = @customer.rentals.where(checkin_date: nil)
+
+ if @current.length == 0
+ render json: { ok: true, cause: "#{@customer.name} has no movies checked out" }, status: :ok
+ else
+ @current
+ end
+ end
+
+# TODO: @sorters (user stories do not specify which fields must be sortable)
+# SJL: I'm thinking %w(checkout_date due_date title)
+ def history
+ @customer = Customer.find_by(id: params[:id])
+ @history = @customer.rentals.where.not(checkin_date: nil)
+ # binding.pry
+ if @history.length == 0
+ render json: { ok: true, cause: "#{@customer.name} has no completed rental history" }, status: :ok
+ else
+ @history
+ end
+ end
+
+end
diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb
new file mode 100644
index 000000000..35ec34d92
--- /dev/null
+++ b/app/controllers/movies_controller.rb
@@ -0,0 +1,60 @@
+class MoviesController < ApplicationController
+ before_action :get_query_params, only: [:index] # TODO: add :current and :history
+
+ def index
+ movies = Movie.all
+ @sorters.each do |sorter|
+ movies = movies.order(sorter => :asc) # asc is default - just being explicit
+ end
+
+ @movies = movies
+ end
+
+ def show
+ @movie = Movie.find_by(id: params[:id])
+ render json: { ok: false, cause: :not_found }, status: :not_found if @movie.nil?
+ end
+
+ def create
+ movie_params[:inventory_available] = movie_params[:inventory]
+ @movie = Movie.new(movie_params)
+ unless @movie.save
+ render json: {ok: false, cause: "validation errors", errors: @movie.errors}, status: :bad_request
+ end
+ end
+
+# TODO: @sorters (user stories do not specify which fields must be sortable)
+# SJL: I'm thinking %w(checkout_date due_date name)
+
+ # get '/movies/:id/current'
+ def current
+ @movie = Movie.find_by(id: params[:id])
+ @current = @movie.rentals.where(checkin_date: nil)
+ # binding.pry
+ if @current.length == 0
+ render json: { ok: true, cause: "All copies of #{@movie.title} are checked in" }, status: :ok
+ else
+ @current
+ end
+ end
+
+# TODO: @sorters (user stories do not specify which fields must be sortable)
+# SJL: I'm thinking %w(checkout_date due_date name)
+ def history
+ @movie = Movie.find_by(id: params[:id])
+ @history = @movie.rentals.where.not(checkin_date: nil)
+ # binding.pry
+ if @history.length == 0
+ render json: { ok: true, cause: "#{@movie.title} has no completed rental history" }, status: :ok
+ else
+ @history
+ end
+ end
+
+ private
+
+ def movie_params
+ return params.permit(:title, :overview, :release_date, :inventory)
+ end
+
+end
diff --git a/app/controllers/rentals_controller.rb b/app/controllers/rentals_controller.rb
new file mode 100644
index 000000000..1db6f1586
--- /dev/null
+++ b/app/controllers/rentals_controller.rb
@@ -0,0 +1,44 @@
+class RentalsController < ApplicationController
+ before_action :get_query_params, only: [:overdue]
+
+ def zomg
+ render json: {message: "it works"}
+ end
+
+ def check_out
+ @rental = Rental.new(rental_params)
+ unless @rental.checkout_data && @rental.save
+ render json: {ok: false, cause: "validation errors", errors: @rental.errors.messages}, status: :bad_request
+ end
+ end
+
+ def check_in
+ @rental = Rental.find_by(movie_id: params[:movie_id], customer_id: params[:customer_id], checkin_date: nil)
+ unless @rental.checkin_data && @rental.save
+ render json: {ok: false, cause: "validation errors", errors: @rental.errors.messages}, status: :bad_request
+ end
+ end
+
+ def overdue
+ overdue_rentals = Rental.includes(:movie).includes(:customer).where(checkin_date: nil).where("rentals.due_date < ?", Date.current)
+
+ # @sorters will always be a 1-d ordered array of unique values.
+ @sorters.each do |sorter|
+ if sorter == "checkout_date" || sorter == "due_date"
+ overdue_rentals = overdue_rentals.order(sorter => :asc) # asc is default - just being explicit
+ elsif sorter == "title"
+ overdue_rentals = overdue_rentals.order("movies.title asc")
+ elsif sorter == "name"
+ overdue_rentals = overdue_rentals.order("customers.name asc")
+ end
+ end
+ @overdue_rentals = overdue_rentals
+ end
+
+ private
+
+ def rental_params
+ return params.permit(:customer_id, :movie_id)
+ end
+
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
new file mode 100644
index 000000000..de6be7945
--- /dev/null
+++ b/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/app/helpers/customers_helper.rb b/app/helpers/customers_helper.rb
new file mode 100644
index 000000000..c5a23daeb
--- /dev/null
+++ b/app/helpers/customers_helper.rb
@@ -0,0 +1,7 @@
+module CustomersHelper
+
+ def movies_out_count(customer)
+ return customer.rentals.where({checkin_date: nil}).count
+ end
+
+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..01367be86
--- /dev/null
+++ b/app/models/customer.rb
@@ -0,0 +1,12 @@
+class Customer < ApplicationRecord
+ # relationships
+ has_many :rentals, dependent: :nullify
+ has_many :movies, :through => :rentals
+
+ # validations
+ validates :name, presence: true
+ validates :registered_at, presence: true
+ validates :postal_code, presence: true
+ validates :phone, presence: true
+
+end
diff --git a/app/models/movie.rb b/app/models/movie.rb
new file mode 100644
index 000000000..625b61a9b
--- /dev/null
+++ b/app/models/movie.rb
@@ -0,0 +1,11 @@
+class Movie < ApplicationRecord
+ # relationships
+ has_many :rentals
+ has_many :customers, :through => :rentals
+
+ # validations
+ validates :overview, presence: true
+ validates :title, presence: true
+ validates :release_date, presence: true
+ validates :inventory, presence: true
+end
diff --git a/app/models/rental.rb b/app/models/rental.rb
new file mode 100644
index 000000000..c8927592d
--- /dev/null
+++ b/app/models/rental.rb
@@ -0,0 +1,74 @@
+class Rental < ApplicationRecord
+ # relationships
+ belongs_to :customer
+ belongs_to :movie
+
+ # validations
+ validates :checkout_date, presence: true
+ validates :due_date, presence: true
+
+ # custom model methods
+ def complete?
+ return !self.checkin_date.nil?
+ end
+
+ def checkout_data
+ if valid_movie? && valid_cust? && movie_available?
+ self.checkout_date = Date.current
+ self.due_date = Date.current + 7
+ self.checkin_date = nil
+ # self.save
+ return self
+ end
+ return self
+ end
+
+ def checkin_data
+ if valid_movie? && valid_cust?
+ movie_id = self[:movie_id]
+ rented = Movie.find_by(id: movie_id)
+ rented.inventory_available += 1
+ rented.save
+ self.checkin_date = Date.current
+ return self
+ end
+ return self
+
+ end
+
+ private
+
+ def valid_cust?
+ cust_id = self[:customer_id]
+ cust = Customer.find_by(id: cust_id)
+ if cust.nil?
+ errors.add(:customer, "customer id not in database")
+ return false
+ end
+ return true
+ end
+
+ def valid_movie?
+ movie_id = self[:movie_id]
+ rentable = Movie.find_by(id: movie_id)
+ if rentable.nil?
+ errors.add(:movie, "movie id not in database")
+ return false
+ end
+ return true
+ end
+
+ def movie_available?
+ movie_id = self[:movie_id]
+ rentable = Movie.find_by(id: movie_id)
+
+ if rentable.inventory_available > 0
+ rentable.inventory_available -= 1
+ rentable.save
+ else
+ errors.add(:movie, "all copies are currently checked out")
+ return false
+ end
+ return true
+ end
+end
diff --git a/app/views/customers/current.rabl b/app/views/customers/current.rabl
new file mode 100644
index 000000000..dfd01162a
--- /dev/null
+++ b/app/views/customers/current.rabl
@@ -0,0 +1,8 @@
+# collection of all customer(:id)'s current rentals
+collection @current
+attributes :id => :rental_id, :checkout_date => :checked_out, :due_date => :due, :checkin_date => :returned
+
+
+child :movie do
+ attribute :title
+end
diff --git a/app/views/customers/history.rabl b/app/views/customers/history.rabl
new file mode 100644
index 000000000..d16d85104
--- /dev/null
+++ b/app/views/customers/history.rabl
@@ -0,0 +1,2 @@
+collection @history
+extends 'customers/current'
diff --git a/app/views/customers/index.rabl b/app/views/customers/index.rabl
new file mode 100644
index 000000000..5aabc8f8f
--- /dev/null
+++ b/app/views/customers/index.rabl
@@ -0,0 +1,3 @@
+collection @customers
+attributes :id, :name, :registered_at, :postal_code, :phone
+node(:movies_checked_out_count) { |customer| movies_out_count(customer) }
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/app/views/movies/create.rabl b/app/views/movies/create.rabl
new file mode 100644
index 000000000..c01c0356e
--- /dev/null
+++ b/app/views/movies/create.rabl
@@ -0,0 +1,2 @@
+object @movie
+attributes :id
diff --git a/app/views/movies/current.rabl b/app/views/movies/current.rabl
new file mode 100644
index 000000000..db898c8ce
--- /dev/null
+++ b/app/views/movies/current.rabl
@@ -0,0 +1,19 @@
+# collection of all movies with in progress rentals
+collection @current
+attributes :id => :rental_id, :checkout_date => :checked_out, :due_date => :due, :checkin_date => :returned
+
+child :customer do
+ attributes :customer_id, :name, :postal_code
+end
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/movies/history.rabl b/app/views/movies/history.rabl
new file mode 100644
index 000000000..f177a2a2c
--- /dev/null
+++ b/app/views/movies/history.rabl
@@ -0,0 +1,8 @@
+collection @history
+extends 'movies/current'
+
+# customer_id
+# name
+# postal_code
+# checkout_date
+# due_date
diff --git a/app/views/movies/index.rabl b/app/views/movies/index.rabl
new file mode 100644
index 000000000..b69f48197
--- /dev/null
+++ b/app/views/movies/index.rabl
@@ -0,0 +1,7 @@
+
+## use collection when dealing w/ multiple objects
+collection @movies
+attributes :id, :title, :release_date
+
+## extend calls the same attributes used in the show action
+# extends "movies/show"
diff --git a/app/views/movies/show.rabl b/app/views/movies/show.rabl
new file mode 100644
index 000000000..a83a5bda2
--- /dev/null
+++ b/app/views/movies/show.rabl
@@ -0,0 +1,2 @@
+object @movie
+attributes :id, :title, :overview, :release_date, :inventory, :inventory_available
diff --git a/app/views/rentals/check_in.rabl b/app/views/rentals/check_in.rabl
new file mode 100644
index 000000000..88fba2597
--- /dev/null
+++ b/app/views/rentals/check_in.rabl
@@ -0,0 +1,3 @@
+object @rental
+attributes :id, :customer_id, :movie_id, :checkout_date, :checkin_date, :due_date
+# extends "rentals/check_out"
\ No newline at end of file
diff --git a/app/views/rentals/check_out.rabl b/app/views/rentals/check_out.rabl
new file mode 100644
index 000000000..0edfd8bf2
--- /dev/null
+++ b/app/views/rentals/check_out.rabl
@@ -0,0 +1,2 @@
+object @rental
+attributes :id, :customer_id, :movie_id, :checkout_date, :checkin_date, :due_date
\ No newline at end of file
diff --git a/app/views/rentals/overdue.rabl b/app/views/rentals/overdue.rabl
new file mode 100644
index 000000000..1ea186341
--- /dev/null
+++ b/app/views/rentals/overdue.rabl
@@ -0,0 +1,33 @@
+collection @overdue_rentals
+attributes :movie_id, :customer_id, :checkout_date, :due_date
+child(:movie) { attributes :title }
+child(:customer) { attributes :name, :postal_code }
+
+# [
+# {
+# movie_id: 3,
+# customer_id: 3,
+# checkout_date: "2018-11-05",
+# due_date: "2018-11-06",
+# movie: {
+# title: "Rats And Strangers"
+# },
+# customer: {
+# name: "Roanna Robinson",
+# postal_code: "15867"
+# }
+# }
+# ]
+
+# Fields to return:
+# - `movie_id`
+# - `title` ########
+# - `customer_id`
+# - `name` ###########
+# - `postal_code` ##########
+# - `checkout_date`
+# - `due_date`
+
+# - Customers can be sorted by `name`, `registered_at` and `postal_code`
+# - Movies can be sorted by `title` and `release_date`
+# - Overdue rentals can be sorted by `title`, `name`, `checkout_date` and `due_date`
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 000000000..f19acf5b5
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 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..a334d86a6
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # 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..67d0d4964
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ 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..641b5d08c
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,41 @@
+require_relative 'boot'
+
+require "rails"
+# Pick the frameworks you want:
+require "active_model/railtie"
+require "active_job/railtie"
+require "active_record/railtie"
+require "active_storage/engine"
+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.2
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration can go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded after loading
+ # the framework and any gems in your application.
+
+ # 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..b9e460cef
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,4 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 000000000..0d86702e8
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: VideoStoreAPI_production
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
new file mode 100644
index 000000000..883c181fc
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+/A3wCN2mBAUxCZIB/JfQITgN9GhsQavCvZwaefkulNXHBcJd5bBncVVeuEhUMARlnsO6yfWPcilFEt86NP6BdFc//DbcBa8kQjiLjN98TINHAbdKuNvGSTh+PF5JEYRB3vFH1FAXpFmI6FaNtFZfHNT8BuWmrVfkEQPKxOI+jJN4vt1O0bn5ahRrH0ohNEJLPIKBJXKo3vOo3y8V7xbz55t9jXbEsYLqvSy3DOkgIuVTy+zKyp4QhDJSfxbtrihFBMHG52SY/RH6taeW6KlPjSfRyeuI0FWsrUTpSzXmKt78XaoGmsMGd3BvAxRn2RR7bJlc3H9SkZGgI4CPdgOpsgOtaaXC7kHrujpsX13A4+DYsFU1sgvPO3tTCVnmt38/4YlbKlFcQWYHoSVibDa8oW+w8PYpoVeI/Kzi--msES8F6h9HnVJ3hW--AXSJLx1/2G3+977ThMsyBg==
\ No newline at end of file
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..d52ec9efb
--- /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.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+
+ # 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..5f44b9bda
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,85 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "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..0a38fd3ce
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,46 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 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/rabl_config.rb b/config/initializers/rabl_config.rb
new file mode 100644
index 000000000..5e878de29
--- /dev/null
+++ b/config/initializers/rabl_config.rb
@@ -0,0 +1,4 @@
+Rabl.configure do |config|
+ config.include_json_root = false
+end
+
diff --git a/config/initializers/time_zone.rb b/config/initializers/time_zone.rb
new file mode 100644
index 000000000..7600940ce
--- /dev/null
+++ b/config/initializers/time_zone.rb
@@ -0,0 +1 @@
+Time.zone = "America/Los_Angeles"
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..a5eccf816
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,34 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory.
+#
+# preload_app!
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 000000000..b3bbb8f96
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,19 @@
+# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+Rails.application.routes.draw do
+ get '/zomg', to: 'rentals#zomg', as: 'zomg'
+
+ post '/rentals/check-out', to: 'rentals#check_out', as: 'check_out'
+ post '/rentals/check-in', to: 'rentals#check_in', as: 'check_in'
+ get '/rentals/overdue', to: 'rentals#overdue', as: 'overdue'
+
+ get '/movies/:id/current', to: 'movies#current'
+ get '/movies/:id/history', to: 'movies#history'
+
+ get '/customers/:id/current', to: 'customers#current'
+ get '/customers/:id/history', to: 'customers#history'
+
+ resources :customers, only: [:index]
+ resources :movies, only: [:index, :show, :create]
+
+end
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 000000000..9fa7863f9
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w[
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+].each { |path| Spring.watch(path) }
diff --git a/config/storage.yml b/config/storage.yml
new file mode 100644
index 000000000..d32f76e8f
--- /dev/null
+++ b/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket
+
+# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/db/migrate/20181105203219_create_customers.rb b/db/migrate/20181105203219_create_customers.rb
new file mode 100644
index 000000000..48cb222bf
--- /dev/null
+++ b/db/migrate/20181105203219_create_customers.rb
@@ -0,0 +1,15 @@
+class CreateCustomers < ActiveRecord::Migration[5.2]
+ def change
+ create_table :customers do |t|
+ t.string :name
+ t.datetime :registered_at
+ t.string :address
+ t.string :state
+ t.string :postal_code
+ t.string :phone
+ t.integer :movies_out_count
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181105203750_create_rentals.rb b/db/migrate/20181105203750_create_rentals.rb
new file mode 100644
index 000000000..34378d9e7
--- /dev/null
+++ b/db/migrate/20181105203750_create_rentals.rb
@@ -0,0 +1,11 @@
+class CreateRentals < ActiveRecord::Migration[5.2]
+ def change
+ create_table :rentals do |t|
+ t.date :checkout_date
+ t.date :checkin_date
+ t.date :due_date
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181105203957_create_movies.rb b/db/migrate/20181105203957_create_movies.rb
new file mode 100644
index 000000000..acf6962ef
--- /dev/null
+++ b/db/migrate/20181105203957_create_movies.rb
@@ -0,0 +1,12 @@
+class CreateMovies < ActiveRecord::Migration[5.2]
+ def change
+ create_table :movies do |t|
+ t.string :title
+ t.string :overview
+ t.date :release_date
+ t.integer :inventory
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20181105204725_fix_address_cols.rb b/db/migrate/20181105204725_fix_address_cols.rb
new file mode 100644
index 000000000..3bfe7248d
--- /dev/null
+++ b/db/migrate/20181105204725_fix_address_cols.rb
@@ -0,0 +1,6 @@
+class FixAddressCols < ActiveRecord::Migration[5.2]
+ def change
+ add_column :customers, :city, :string
+
+ end
+end
diff --git a/db/migrate/20181105205256_add_refs_to_rental.rb b/db/migrate/20181105205256_add_refs_to_rental.rb
new file mode 100644
index 000000000..5110bae28
--- /dev/null
+++ b/db/migrate/20181105205256_add_refs_to_rental.rb
@@ -0,0 +1,6 @@
+class AddRefsToRental < ActiveRecord::Migration[5.2]
+ def change
+ add_column :rentals, :customer_id, :integer
+ add_column :rentals, :movie_id, :integer
+ end
+end
diff --git a/db/migrate/20181105205609_rm_refs_rentals.rb b/db/migrate/20181105205609_rm_refs_rentals.rb
new file mode 100644
index 000000000..ed07d7fe1
--- /dev/null
+++ b/db/migrate/20181105205609_rm_refs_rentals.rb
@@ -0,0 +1,6 @@
+class RmRefsRentals < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :rentals, :customer_id
+ remove_column :rentals, :movie_id
+ end
+end
diff --git a/db/migrate/20181105205816_add_refs_to_rental_proper_way.rb b/db/migrate/20181105205816_add_refs_to_rental_proper_way.rb
new file mode 100644
index 000000000..bc6481faf
--- /dev/null
+++ b/db/migrate/20181105205816_add_refs_to_rental_proper_way.rb
@@ -0,0 +1,8 @@
+class AddRefsToRentalProperWay < ActiveRecord::Migration[5.2]
+ def change
+ add_column :rentals, :customer_id, :integer
+ add_column :rentals, :movie_id, :integer
+ add_foreign_key :rentals, :customers
+ add_foreign_key :rentals, :movies
+ end
+end
diff --git a/db/migrate/20181105214043_add_default_0_to_customer_checked_out.rb b/db/migrate/20181105214043_add_default_0_to_customer_checked_out.rb
new file mode 100644
index 000000000..68c6de62c
--- /dev/null
+++ b/db/migrate/20181105214043_add_default_0_to_customer_checked_out.rb
@@ -0,0 +1,5 @@
+class AddDefault0ToCustomerCheckedOut < ActiveRecord::Migration[5.2]
+ def change
+ change_column :customers, :movies_out_count, :integer, default: 0
+ end
+end
diff --git a/db/migrate/20181105215028_add_inventory_available_col_to_movies.rb b/db/migrate/20181105215028_add_inventory_available_col_to_movies.rb
new file mode 100644
index 000000000..ab6f2057b
--- /dev/null
+++ b/db/migrate/20181105215028_add_inventory_available_col_to_movies.rb
@@ -0,0 +1,5 @@
+class AddInventoryAvailableColToMovies < ActiveRecord::Migration[5.2]
+ def change
+ add_column :movies, :inventory_available, :integer
+ end
+end
diff --git a/db/migrate/20181105215959_add_default_0_to_inventory_available_movies.rb b/db/migrate/20181105215959_add_default_0_to_inventory_available_movies.rb
new file mode 100644
index 000000000..c522c9754
--- /dev/null
+++ b/db/migrate/20181105215959_add_default_0_to_inventory_available_movies.rb
@@ -0,0 +1,5 @@
+class AddDefault0ToInventoryAvailableMovies < ActiveRecord::Migration[5.2]
+ def change
+ change_column :movies, :inventory_available, :integer, default: 0
+ end
+end
diff --git a/db/migrate/20181105231519_remove_movies_out_count_from_customers.rb b/db/migrate/20181105231519_remove_movies_out_count_from_customers.rb
new file mode 100644
index 000000000..721213b74
--- /dev/null
+++ b/db/migrate/20181105231519_remove_movies_out_count_from_customers.rb
@@ -0,0 +1,5 @@
+class RemoveMoviesOutCountFromCustomers < ActiveRecord::Migration[5.2]
+ def change
+ remove_column :customers, :movies_out_count
+ end
+end
diff --git a/db/migrate/20181106215340_update_avail_inv_movies_to_match_inv.rb b/db/migrate/20181106215340_update_avail_inv_movies_to_match_inv.rb
new file mode 100644
index 000000000..d417b7a28
--- /dev/null
+++ b/db/migrate/20181106215340_update_avail_inv_movies_to_match_inv.rb
@@ -0,0 +1,11 @@
+class UpdateAvailInvMoviesToMatchInv < ActiveRecord::Migration[5.2]
+ def self.up
+ Movie.update_all("inventory_available=inventory")
+ end
+
+ def self.down
+ # rollback if update does not work
+ end
+end
+
+
diff --git a/db/migrate/20181107194538_change_col_default_movies.rb b/db/migrate/20181107194538_change_col_default_movies.rb
new file mode 100644
index 000000000..3f3fe078f
--- /dev/null
+++ b/db/migrate/20181107194538_change_col_default_movies.rb
@@ -0,0 +1,5 @@
+class ChangeColDefaultMovies < ActiveRecord::Migration[5.2]
+ def change
+ change_column_default(:movies, :inventory_available, nil)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 000000000..2ec90e243
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,52 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 2018_11_07_194538) 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.datetime "registered_at"
+ t.string "address"
+ t.string "state"
+ t.string "postal_code"
+ t.string "phone"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "city"
+ end
+
+ create_table "movies", force: :cascade do |t|
+ t.string "title"
+ t.string "overview"
+ t.date "release_date"
+ t.integer "inventory"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "inventory_available"
+ end
+
+ create_table "rentals", force: :cascade do |t|
+ t.date "checkout_date"
+ t.date "checkin_date"
+ t.date "due_date"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "customer_id"
+ t.integer "movie_id"
+ end
+
+ add_foreign_key "rentals", "customers"
+ add_foreign_key "rentals", "movies"
+end
diff --git a/db/seeds.rb b/db/seeds.rb
index 5322340ba..4a0227d12 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -2,6 +2,17 @@
Customer.create!(customer)
end
-JSON.parse(File.read('db/seeds/movies.json')).each do |movie|
- Movie.create!(movie)
+JSON.parse(File.read('db/seeds/movies.json')).each_with_index do |movie, index|
+ movie["inventory_available"] = movie["inventory"]
+ unless Movie.create(movie)
+ puts "failed to create Movie #{index}: #{movie["title"]}"
+ end
+end
+
+# Movie.update_all("inventory_available=inventory")
+
+JSON.parse(File.read('db/seeds/rentals.json'), :quirks_mode => true).each do |rental|
+ unless Rental.create(rental)
+ puts "failed to create rental #{index}: #{rental["movie_id"]}"
+ end
end
diff --git a/db/seeds/movies.json b/db/seeds/movies.json
index de0db0c5e..88f6ca110 100644
--- a/db/seeds/movies.json
+++ b/db/seeds/movies.json
@@ -1,542 +1 @@
-[
- {
- "title":"Blacksmith Of The Banished",
- "overview":"The unexciting life of a boy will be permanently altered as a strange woman enters his life.",
- "release_date":"1979-01-18",
- "inventory":10
- },
- {
- "title":"Savior Of The Curse",
- "overview":"The strange woman claims the boy has a DNA strain which very likely offers the key to cure several crippling diseases. Tests will have to be done, but the key to save millions of lives is within the grasp of science through this DNA strain. Unsure what to think of all this and of this strange woman, the boy hesitantly agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.",
- "release_date":"2010-11-05",
- "inventory":1
- },
- {
- "title":"Women Of Destruction",
- "overview":"But what if this strange woman is a con artist. Or what if everything told is completely true. How could an ordinary boy be relied upon in something this big. Time will tell.",
- "release_date":"2006-10-01",
- "inventory":1
- },
- {
- "title":"Robots Of Eternity",
- "overview":"The laid-back life of a woman is going in a different direction as a childhood friend enters her life.",
- "release_date":"2007-10-10",
- "inventory":7
- },
- {
- "title":"Rats And Strangers",
- "overview":"The childhood friend claims the woman is heir to an incredible fortune, all paperwork has been taken care of already, all there's left to do is sign them. Distrustful of both this situation and of this childhood friend, the woman somewhat gladly agrees to the proposal, but there's no time to waste, a decision had to be made quickly.",
- "release_date":"2012-09-25",
- "inventory":2
- },
- {
- "title":"Soldiers And Gangsters",
- "overview":"But what if this childhood friend is just a crazy person. Or what if the complete opposite is true. How could an ordinary woman be relied upon in something this big. No turning back now though.",
- "release_date":"1948-03-31",
- "inventory":9
- },
- {
- "title":"Body Of Utopia",
- "overview":"The peaceful life of a teenage girl is going the complete opposite way as a stranger enters her life.",
- "release_date":"1967-10-25",
- "inventory":2
- },
- {
- "title":"Faith Of The Ancestors",
- "overview":"The stranger claims the teenage girl is now part of a murder investigation and might be the number one suspect, no arrest will be made in front of possible friends and neighbors if there's no resistance. Concerned of the situation and a little distrustful of this stranger, the teenage girl tentatively agrees to the proposal, no matter what, something has to be done in this situation, hopefully this was the right choice.",
- "release_date":"1953-10-05",
- "inventory":7
- },
- {
- "title":"Traces In The Leaders",
- "overview":"But what if this stranger cannot be relied upon. Or what if somebody is orchestrating all of this. How could an ordinary teenage girl figure out the truth in all of this. Either way, the choice has been made.",
- "release_date":"1970-11-03",
- "inventory":6
- },
- {
- "title":"Bathing In The Void",
- "overview":"The stressful life of a girl changes for better or worse as a stranger enters her life.",
- "release_date":"2013-09-13",
- "inventory":10
- },
- {
- "title":"Mouse Of My House",
- "overview":"The stranger claims the girl is now cursed along with everybody else in this town. Why? By whom? What kind of curse exactly? Nobody seems to know, but the person supposedly responsible for this curse will explain everything at the town hall this afternoon, everybody should come. Unsure what to think of all this and of this stranger, the girl cautiously agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.",
- "release_date":"1993-12-27",
- "inventory":3
- },
- {
- "title":"Baby Of Tomorrow",
- "overview":"But what if this stranger is trying be misleading. Or what if the complete opposite is true. How could an ordinary girl find out what's happening without help. Only one way to find out.",
- "release_date":"1977-03-23",
- "inventory":4
- },
- {
- "title":"Cats Of Wonder",
- "overview":"The carefree life of a young girl will change forever as a neighbor enters her life.",
- "release_date":"1939-03-13",
- "inventory":9
- },
- {
- "title":"Kittens Of Excelsior",
- "overview":"The neighbor claims the young girl better leave the city now. The rivaling gangs have spiraled into an all out war, soon the entire city will be a battleground and the government apparently plans to surround the city and let the gangs fight it out, better to let them kill each other than risk soldier lives they say. Unsure what to think of all this and of this neighbor, the young girl oddly willingly agrees to the proposal, the situation is all too strange, it's best to get more information as soon as possible.",
- "release_date":"1965-06-10",
- "inventory":9
- },
- {
- "title":"Dinos And Boys",
- "overview":"But what if this neighbor can't be trusted. Or what if all this is an elaborate trap. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. No turning back now though.",
- "release_date":"1973-10-20",
- "inventory":0
- },
- {
- "title":"Tigers And Kids",
- "overview":"The secluded life of a elderly woman is going in a different direction as a friendly acquaintance enters her life.",
- "release_date":"2007-03-17",
- "inventory":6
- },
- {
- "title":"Wand Of My Country",
- "overview":"The friendly acquaintance claims the elderly woman is needed, all capable hands are needed. The dam is breaking and if we don't get every person working on repairing it the entire town might be destroyed by the following flood. Concerned of the situation and a little distrustful of this friendly acquaintance, the elderly woman oddly enthusiastically agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.",
- "release_date":"1960-06-26",
- "inventory":10
- },
- {
- "title":"Tales Of My Imagination",
- "overview":"But what if this friendly acquaintance is pulling a prank. Or what if the wrong person was picked for this. How could an ordinary elderly woman play a part in all this. No turning back now though.",
- "release_date":"1985-09-21",
- "inventory":3
- },
- {
- "title":"Learning With My Home",
- "overview":"The calm life of a elderly man is going the complete opposite way as a strange boy enters his life.",
- "release_date":"1939-09-01",
- "inventory":1
- },
- {
- "title":"Fearless With My Home",
- "overview":"The strange boy claims the elderly man is one of the rare few people in possession of a guardian animal spirit. It's widely known these exist and rituals are held on a near weekly basis to connect with these guardian spirits, now its time to be the center of that ritual. Unconvinced of the situation, but trusting of this strange boy, the elderly man hesitantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.",
- "release_date":"1965-03-28",
- "inventory":7
- },
- {
- "title":"Thief Without A Conscience",
- "overview":"But what if this strange boy can't be trusted. Or what if there's a change of mind. How could an ordinary elderly man be this important to the situation. Time to find out.",
- "release_date":"1982-11-14",
- "inventory":3
- },
- {
- "title":"Knight Of Last Rites",
- "overview":"The normal life of a girl will be changed completely as a strange man enters her life.",
- "release_date":"1973-12-16",
- "inventory":7
- },
- {
- "title":"Horses With Hoods",
- "overview":"The strange man claims the girl plays a vital role in the future, but that this version of the future cannot be allowed to be. The only way to prevent it is by traveling in time with this supposed time traveler. Sure of the truth in this situation, but somewhat distrustful of this strange man, the girl somewhat hesitantly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.",
- "release_date":"1965-09-16",
- "inventory":10
- },
- {
- "title":"Heirs With Gold",
- "overview":"But what if this strange man cannot be relied upon. Or what if all this is an elaborate trap. How could an ordinary girl be relied upon in something this big. Only one way to find out.",
- "release_date":"1949-10-03",
- "inventory":1
- },
- {
- "title":"Scientists And Rats",
- "overview":"The ordinary life of a young guy take a sharp turn as a childhood friend enters his life.",
- "release_date":"1973-11-07",
- "inventory":1
- },
- {
- "title":"Invaders And Guardians",
- "overview":"The childhood friend claims the young guy is in possession of a powerful artifact, an artifact which looks like any ordinary object, but an artifact which is of the utmost importance to this person, who will offer a reward for it. Sure of the truth in this situation, but somewhat distrustful of this childhood friend, the young guy oddly willingly agrees to the proposal, if all this turns out to be false, this choice will seem foolish, but it's still worth checking out.",
- "release_date":"1990-06-04",
- "inventory":0
- },
- {
- "title":"Accidents Of Hell",
- "overview":"But what if this childhood friend is a con artist. Or what if everything told is completely true. How could an ordinary young guy be relied upon in something this big. We're about to find out.",
- "release_date":"1944-03-24",
- "inventory":4
- },
- {
- "title":"Confinement Of War",
- "overview":"The fast-paced life of a teenage girl changes in an instant as a friendly acquaintance enters her life.",
- "release_date":"1959-04-06",
- "inventory":7
- },
- {
- "title":"Breath Of The Apocalypse",
- "overview":"The friendly acquaintance claims the teenage girl is actually already dead, a spirit trapped in a state of denial, not ready to move on yet. The person claims there's proof of this elsewhere. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the teenage girl oddly willingly agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.",
- "release_date":"1965-06-10",
- "inventory":5
- },
- {
- "title":"Force Of A Storm",
- "overview":"But what if this friendly acquaintance cannot be relied upon. Or what if there's a change of mind. How could an ordinary teenage girl find out what's happening without help. Time to find out.",
- "release_date":"1972-03-25",
- "inventory":3
- },
- {
- "title":"Officer Without Fear",
- "overview":"The ordinary life of a woman changes for better or worse as a strange woman enters her life.",
- "release_date":"1987-03-06",
- "inventory":2
- },
- {
- "title":"Spider Of The Gods",
- "overview":"The strange woman claims the woman was a witness of a horrific crime, a crime for which an innocent person is in jail for. Due to the horrific nature of the crime the memory was likely blocked, but there's a way to unblock it and save an innocent life. Unconvinced of the situation, but trusting of this strange woman, the woman somewhat keenly agrees to the proposal, the situation is all too strange, it's best to get more information as soon as possible.",
- "release_date":"2010-01-16",
- "inventory":2
- },
- {
- "title":"Women Of Insanity",
- "overview":"But what if this strange woman can't be trusted. Or what if the complete opposite is true. How could an ordinary woman end up in a situation like this. Only one way to find out.",
- "release_date":"1997-10-03",
- "inventory":10
- },
- {
- "title":"Doctors Of Water",
- "overview":"The stable life of a teenage girl changes for better or worse as a stranger enters her life.",
- "release_date":"1953-04-03",
- "inventory":11
- },
- {
- "title":"Snakes And Turtles",
- "overview":"The stranger claims the teenage girl better leave the city now. The rivaling gangs have spiraled into an all out war, soon the entire city will be a battleground and the government apparently plans to surround the city and let the gangs fight it out, better to let them kill each other than risk soldier lives they say. Suspicious of this situation, but somewhat trusting of this stranger, the teenage girl unusually eagerly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.",
- "release_date":"1992-12-14",
- "inventory":11
- },
- {
- "title":"Rogues And Boys",
- "overview":"But what if this stranger is pulling a prank. Or what if all this is an elaborate trap. How could an ordinary teenage girl find out what's happening without help. We're about to find out.",
- "release_date":"1979-12-30",
- "inventory":3
- },
- {
- "title":"Loss Of The Sea",
- "overview":"The relaxed life of a boy will change forever as a lost friend enters his life.",
- "release_date":"1976-07-16",
- "inventory":11
- },
- {
- "title":"Annihilation Of Autumn",
- "overview":"The lost friend claims the boy is in possession of a powerful artifact, one which looks like any other object, but one which could bring total destruction if fallen in the wrong hands. The person wishes to destroy it, with or without help. Unconvinced of the situation, but trusting of this lost friend, the boy oddly enthusiastically agrees to the proposal, it might be a mistake, but both options could've been the mistake, one had to be chosen.",
- "release_date":"2016-11-09",
- "inventory":6
- },
- {
- "title":"Searching At The Leaders",
- "overview":"But what if this lost friend is trying be misleading. Or what if the situation has changed or will change. How could an ordinary boy be this important to the situation. We're about to find out.",
- "release_date":"1995-12-21",
- "inventory":3
- },
- {
- "title":"Taste Of The Immortals",
- "overview":"The rough life of a young girl might turn out differently as a strange woman enters her life.",
- "release_date":"1948-02-12",
- "inventory":5
- },
- {
- "title":"Criminal Arrangement",
- "overview":"The strange woman claims the young girl is now cursed along with everybody else in this town. Why? By whom? What kind of curse exactly? Nobody seems to know, but the person supposedly responsible for this curse will explain everything at the town hall this afternoon, everybody should come. Unsure what to think of all this and of this strange woman, the young girl somewhat grudgingly agrees to the proposal, it's probably best to get to the bottom of this as soon as possible.",
- "release_date":"1939-04-23",
- "inventory":3
- },
- {
- "title":"Spider In The Window",
- "overview":"But what if this strange woman is a con artist. Or what if the complete opposite is true. How could an ordinary young girl find out what's happening without help. Either way, the choice has been made.",
- "release_date":"2007-06-29",
- "inventory":10
- },
- {
- "title":"Comedian Makeover",
- "overview":"The laid-back life of a young girl changes in an instant as a childhood friend enters her life.",
- "release_date":"1944-06-14",
- "inventory":4
- },
- {
- "title":"Baker On A Day Out",
- "overview":"The childhood friend claims the young girl is in for a fun day. A new casino opened up in town and is giving everybody a free roll on their slot machine, with a little luck who knows what could happen. Skeptical of this situation and of this childhood friend, the young girl cautiously agrees to the proposal, if anything this will at least speed things up, for better and for worse.",
- "release_date":"1948-07-26",
- "inventory":3
- },
- {
- "title":"Spider And Thief",
- "overview":"But what if this childhood friend is just a crazy person. Or what if everything told is completely true. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. No turning back now though.",
- "release_date":"1950-05-07",
- "inventory":10
- },
- {
- "title":"Rat And Chicken",
- "overview":"The carefree life of a elderly man will change forever as a strange woman enters his life.",
- "release_date":"1993-10-05",
- "inventory":8
- },
- {
- "title":"Laughing Stalks Me",
- "overview":"The strange woman claims the elderly man is now the citizen of a different country. The old country has just been taken over by an enemy force, everybody who wishes to leave this new nation has 3 days to do so. Distrustful of both this situation and of this strange woman, the elderly man tentatively agrees to the proposal, this whole situation is both exciting and terrifying at the same time, but surely the right choice was made.",
- "release_date":"1946-09-06",
- "inventory":2
- },
- {
- "title":"Fools Can Cook",
- "overview":"But what if this strange woman is a con artist. Or what if this proposal is wrong or missing important details. How could an ordinary elderly man be this important to the situation. Only one way to find out.",
- "release_date":"2013-11-20",
- "inventory":9
- },
- {
- "title":"Power Of The Project",
- "overview":"The unexciting life of a teenage boy is going in a different direction as a lost friend enters his life.",
- "release_date":"1982-02-19",
- "inventory":2
- },
- {
- "title":"Intelligence Of My Teacher",
- "overview":"The lost friend claims the teenage boy is in possession of a powerful artifact, one which looks like any other object, but one which could bring total destruction if fallen in the wrong hands. The person wishes to destroy it, with or without help. Unsure what to think of all this and of this lost friend, the teenage boy somewhat hesitantly agrees to the proposal, this whole situation is both exciting and terrifying at the same time, but surely the right choice was made.",
- "release_date":"2017-02-18",
- "inventory":10
- },
- {
- "title":"Priest Of Outer Space",
- "overview":"But what if this lost friend speaks only lies. Or what if the situation has changed or will change. How could an ordinary teenage boy come out of this situation in a better way. No turning back now though.",
- "release_date":"1975-12-06",
- "inventory":9
- },
- {
- "title":"Spy Of A Dog",
- "overview":"The secluded life of a teenage girl take a sharp turn as a stranger enters her life.",
- "release_date":"1972-11-18",
- "inventory":2
- },
- {
- "title":"Enemies Of The Mountain",
- "overview":"The stranger claims the teenage girl is in for a treat this afternoon. Supposedly this strange person has discovered a way to unlock the hidden potentials of the brain and will show the whole town this afternoon, it's not an event you want to miss. Concerned of the situation and a little distrusful of this stranger, the teenage girl tentatively agrees to the proposal, if anything this will at least speed things up, for better and for worse.",
- "release_date":"1956-10-16",
- "inventory":3
- },
- {
- "title":"Lions Of Tomorrow",
- "overview":"But what if this stranger is wrong about all this. Or what if this proposal is wrong or missing important details. How could an ordinary teenage girl be helpful at all in this situation. Either way, the choice has been made.",
- "release_date":"1983-07-03",
- "inventory":4
- },
- {
- "title":"Serpents And Kings",
- "overview":"The stable life of a elderly man might be changing forever as a friendly acquaintance enters his life.",
- "release_date":"2016-09-08",
- "inventory":7
- },
- {
- "title":"Agents And Robots",
- "overview":"The friendly acquaintance claims the elderly man plays a vital role in the future, but that this version of the future cannot be allowed to be. The only way to prevent it is by traveling in time with this supposed time traveler. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the elderly man oddly enthusiastically agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.",
- "release_date":"1964-06-19",
- "inventory":6
- },
- {
- "title":"Death Of The Mountain",
- "overview":"But what if this friendly acquaintance is trying be misleading. Or what if the complete opposite is true. How could an ordinary elderly man be needed for a situation like this. Time will tell.",
- "release_date":"1973-07-22",
- "inventory":2
- },
- {
- "title":"Picture Of The Lake",
- "overview":"The casual life of a woman will change forever as a friendly acquaintance enters her life.",
- "release_date":"2014-10-19",
- "inventory":8
- },
- {
- "title":"Muted By The River",
- "overview":"The friendly acquaintance claims the woman is actually already dead, a spirit trapped in a state of denial, not ready to move on yet. The person claims there's proof of this elsewhere. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the woman hastily agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.",
- "release_date":"1992-10-23",
- "inventory":3
- },
- {
- "title":"Young In The Chasm",
- "overview":"But what if this friendly acquaintance cannot be relied upon. Or what if the complete opposite is true. How could an ordinary woman be this important to the situation. Time to find out.",
- "release_date":"1948-05-21",
- "inventory":2
- },
- {
- "title":"Politicians Of The East",
- "overview":"The normal life of a girl might be changing forever as a new friend enters her life.",
- "release_date":"2010-11-30",
- "inventory":11
- },
- {
- "title":"Women Of Science",
- "overview":"The new friend claims the girl is the 'chosen one' according to an ancient prophecy. The prophecy states the chosen one will save the world, but only if properly trained. There is no time to waste. Distrustful of both this situation and of this new friend, the girl somewhat reluctantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.",
- "release_date":"1956-04-02",
- "inventory":8
- },
- {
- "title":"Preys Of The North",
- "overview":"But what if this new friend is trying to manipulate the situation. Or what if everything told is completely true. How could an ordinary girl come out of this situation in a better way. No turning back now though.",
- "release_date":"1957-07-12",
- "inventory":5
- },
- {
- "title":"Kings Of Medicine",
- "overview":"The nonchalant life of a woman might turn out differently as a strange woman enters her life.",
- "release_date":"1966-12-22",
- "inventory":1
- },
- {
- "title":"Stars And Sinners",
- "overview":"The strange woman claims the woman is actually the rightful heir to the throne, this information has obviously been kept secret by the current holders of the throne, but once this information gets out to the public the people will surely stand behind the true heir. Concerned of the situation and a little distrusful of this strange woman, the woman somewhat hesitantly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.",
- "release_date":"1985-08-30",
- "inventory":11
- },
- {
- "title":"Fungi And Amphibians",
- "overview":"But what if this strange woman is trying to manipulate the situation. Or what if the wrong person was picked for this. How could an ordinary woman be this lucky, or unlucky, depending on the turnout. Either way, the choice has been made.",
- "release_date":"1971-02-07",
- "inventory":8
- },
- {
- "title":"Wonders Of The Hunt",
- "overview":"The laid-back life of a young guy has a chance to change, for better or worse, as a strange girl enters his life.",
- "release_date":"1978-04-01",
- "inventory":11
- },
- {
- "title":"Crimes Of The Mountains",
- "overview":"The strange girl claims the young guy is now part of a murder investigation and might be the number one suspect, no arrest will be made in front of possible friends and neighbors if there's no resistance. Suspicious of this situation, but somewhat trusting of this strange girl, the young guy oddly willingly agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.",
- "release_date":"1959-01-29",
- "inventory":10
- },
- {
- "title":"Hidden The Swamps",
- "overview":"But what if this strange girl is wrong about all this. Or what if all this is an elaborate trap. How could an ordinary young guy be needed for a situation like this. We're about to find out.",
- "release_date":"1951-02-19",
- "inventory":7
- },
- {
- "title":"Love For Women",
- "overview":"The carefree life of a boy changes for better or worse as a friendly acquaintance enters his life.",
- "release_date":"1952-02-24",
- "inventory":5
- },
- {
- "title":"Boyfriend Of The Evening",
- "overview":"The friendly acquaintance claims the boy has a DNA strain which very likely offers the key to cure several crippling diseases. Tests will have to be done, but the key to save millions of lives is within the grasp of science through this DNA strain. Skeptical of this situation and of this friendly acquaintance, the boy oddly willingly agrees to the proposal, it was probably a good idea to make a quick decision anyway.",
- "release_date":"1973-02-27",
- "inventory":0
- },
- {
- "title":"Man Of Dawn",
- "overview":"But what if this friendly acquaintance is a con artist. Or what if somebody is orchestrating all of this. How could an ordinary boy play a part in all this. Either way, the choice has been made.",
- "release_date":"1960-07-16",
- "inventory":5
- },
- {
- "title":"Trueloves With Freckles",
- "overview":"The fast-paced life of a elderly man will be permanently altered as a strange girl enters his life.",
- "release_date":"1977-11-06",
- "inventory":3
- },
- {
- "title":"Girlfriends In The Forest",
- "overview":"The strange girl claims the elderly man will need to find a new home as this current house will be demolished by the government in order to make room for a highway. A large sum of money will be paid if the house is left within a week. Distrustful of both this situation and of this strange girl, the elderly man somewhat keenly agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.",
- "release_date":"2009-05-03",
- "inventory":0
- },
- {
- "title":"Queens And Trueloves",
- "overview":"But what if this strange girl is pulling a prank. Or what if everything told is completely true. How could an ordinary elderly man be helpful at all in this situation. Time to find out.",
- "release_date":"1962-06-22",
- "inventory":1
- },
- {
- "title":"Foreigners And Neighbors",
- "overview":"The calm life of a young girl might turn out differently as a strange boy enters her life.",
- "release_date":"2005-02-28",
- "inventory":10
- },
- {
- "title":"Name Of Fortune",
- "overview":"The strange boy claims the young girl was a witness of a horrific crime, a crime for which an innocent person is in jail for. Due to the horrific nature of the crime the memory was likely blocked, but there's a way to unblock it and save an innocent life. Suspicious of this situation, but somewhat trusting of this strange boy, the young girl somewhat reluctantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.",
- "release_date":"1953-04-19",
- "inventory":1
- },
- {
- "title":"Edge Of Tomorrow",
- "overview":"But what if this strange boy can't be trusted. Or what if the wrong person was picked for this. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. Time to find out.",
- "release_date":"2008-03-12",
- "inventory":7
- },
- {
- "title":"Punished By The Stars",
- "overview":"The secluded life of a elderly woman is going in a different direction as a childhood friend enters her life.",
- "release_date":"2004-09-13",
- "inventory":9
- },
- {
- "title":"Guarded By My Dreams",
- "overview":"The childhood friend claims the elderly woman is actually part of a 'sub-species' of humans with hidden powers and wants to show what these hidden powers can do. Unsure about everything, including this childhood friend, the elderly woman somewhat gladly agrees to the proposal, but something does feel very wrong about this whole situation, hopefully the right choice was made.",
- "release_date":"1986-04-26",
- "inventory":11
- },
- {
- "title":"Man Of Exploration",
- "overview":"But what if this childhood friend is a con artist. Or what if this proposal is wrong or missing important details. How could an ordinary elderly woman figure out the truth in all of this. Only one way to find out.",
- "release_date":"2011-04-28",
- "inventory":8
- },
- {
- "title":"Leader Of New Earth",
- "overview":"The normal life of a young girl changes for better or worse as a strange man enters her life.",
- "release_date":"1955-10-14",
- "inventory":8
- },
- {
- "title":"Guardians Of Eternity",
- "overview":"The strange man claims the young girl has been chosen to compete against others of other regions in a 'competition'. The winner will gain not only the honor and glory of winning, but will also never need for anything for the rest of their life. Certain of the truth in this situation and of this strange man, the young girl somewhat reluctantly agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.",
- "release_date":"1946-12-27",
- "inventory":7
- },
- {
- "title":"Soldiers Of The Outlands",
- "overview":"But what if this strange man is wrong about all this. Or what if all this is an elaborate trap. How could an ordinary young girl end up in a situation like this. Either way, the choice has been made.",
- "release_date":"1939-03-20",
- "inventory":6
- },
- {
- "title":"Leaders And Commanders",
- "overview":"The quiet life of a elderly man changes in an instant as a childhood friend enters his life.",
- "release_date":"1982-03-15",
- "inventory":3
- },
- {
- "title":"Medics And Strangers",
- "overview":"The childhood friend claims the elderly man is actually the rightful heir to the throne, this information has obviously been kept secret by the current holders of the throne, but once this information gets out to the public the people will surely stand behind the true heir. Skeptical of this situation and of this childhood friend, the elderly man hesitantly agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.",
- "release_date":"2007-03-13",
- "inventory":6
- },
- {
- "title":"Beginning Of The Vacuum",
- "overview":"But what if this childhood friend is just a crazy person. Or what if all this is an elaborate trap. How could an ordinary elderly man be needed for a situation like this. Time will tell.",
- "release_date":"1943-11-11",
- "inventory":3
- },
- {
- "title":"Fate Of Alien Life",
- "overview":"The normal life of a girl might be changing forever as a neighbor enters her life.",
- "release_date":"1938-12-01",
- "inventory":10
- },
- {
- "title":"Created By Androids",
- "overview":"The neighbor claims the girl plays a vital role in the survival of the universe and must come along to train for battle or else the universe might be lost forever. Unsure about everything, including this neighbor, the girl hesitantly agrees to the proposal, the choice was made fast, perhaps too fast, but this situation requires quick thinking.",
- "release_date":"1963-04-16",
- "inventory":7
- },
- {
- "title":"Elegance Of The Machines",
- "overview":"But what if this neighbor is wrong about all this. Or what if the situation is worse than it appears. How could an ordinary girl be this lucky, or unlucky, depending on the turnout. We're about to find out.",
- "release_date":"1991-05-19",
- "inventory":7
- }
-]
+[{"title":"Women Of Destruction","overview":"But what if this strange woman is a con artist. Or what if everything told is completely true. How could an ordinary boy be relied upon in something this big. Time will tell.","release_date":"2006-10-01","inventory":42},{"title":"Robots Of Eternity","overview":"The laid-back life of a woman is going in a different direction as a childhood friend enters her life.","release_date":"2007-10-10","inventory":42},{"title":"Rats And Strangers","overview":"The childhood friend claims the woman is heir to an incredible fortune, all paperwork has been taken care of already, all there's left to do is sign them. Distrustful of both this situation and of this childhood friend, the woman somewhat gladly agrees to the proposal, but there's no time to waste, a decision had to be made quickly.","release_date":"2012-09-25","inventory":42},{"title":"Soldiers And Gangsters","overview":"But what if this childhood friend is just a crazy person. Or what if the complete opposite is true. How could an ordinary woman be relied upon in something this big. No turning back now though.","release_date":"1948-03-31","inventory":42},{"title":"Body Of Utopia","overview":"The peaceful life of a teenage girl is going the complete opposite way as a stranger enters her life.","release_date":"1967-10-25","inventory":42},{"title":"Faith Of The Ancestors","overview":"The stranger claims the teenage girl is now part of a murder investigation and might be the number one suspect, no arrest will be made in front of possible friends and neighbors if there's no resistance. Concerned of the situation and a little distrustful of this stranger, the teenage girl tentatively agrees to the proposal, no matter what, something has to be done in this situation, hopefully this was the right choice.","release_date":"1953-10-05","inventory":42},{"title":"Traces In The Leaders","overview":"But what if this stranger cannot be relied upon. Or what if somebody is orchestrating all of this. How could an ordinary teenage girl figure out the truth in all of this. Either way, the choice has been made.","release_date":"1970-11-03","inventory":42},{"title":"Bathing In The Void","overview":"The stressful life of a girl changes for better or worse as a stranger enters her life.","release_date":"2013-09-13","inventory":42},{"title":"Mouse Of My House","overview":"The stranger claims the girl is now cursed along with everybody else in this town. Why? By whom? What kind of curse exactly? Nobody seems to know, but the person supposedly responsible for this curse will explain everything at the town hall this afternoon, everybody should come. Unsure what to think of all this and of this stranger, the girl cautiously agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.","release_date":"1993-12-27","inventory":42},{"title":"Baby Of Tomorrow","overview":"But what if this stranger is trying be misleading. Or what if the complete opposite is true. How could an ordinary girl find out what's happening without help. Only one way to find out.","release_date":"1977-03-23","inventory":42},{"title":"Cats Of Wonder","overview":"The carefree life of a young girl will change forever as a neighbor enters her life.","release_date":"1939-03-13","inventory":42},{"title":"Kittens Of Excelsior","overview":"The neighbor claims the young girl better leave the city now. The rivaling gangs have spiraled into an all out war, soon the entire city will be a battleground and the government apparently plans to surround the city and let the gangs fight it out, better to let them kill each other than risk soldier lives they say. Unsure what to think of all this and of this neighbor, the young girl oddly willingly agrees to the proposal, the situation is all too strange, it's best to get more information as soon as possible.","release_date":"1965-06-10","inventory":42},{"title":"Dinos And Boys","overview":"But what if this neighbor can't be trusted. Or what if all this is an elaborate trap. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. No turning back now though.","release_date":"1973-10-20","inventory":42},{"title":"Tigers And Kids","overview":"The secluded life of a elderly woman is going in a different direction as a friendly acquaintance enters her life.","release_date":"2007-03-17","inventory":42},{"title":"Wand Of My Country","overview":"The friendly acquaintance claims the elderly woman is needed, all capable hands are needed. The dam is breaking and if we don't get every person working on repairing it the entire town might be destroyed by the following flood. Concerned of the situation and a little distrustful of this friendly acquaintance, the elderly woman oddly enthusiastically agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.","release_date":"1960-06-26","inventory":42},{"title":"Tales Of My Imagination","overview":"But what if this friendly acquaintance is pulling a prank. Or what if the wrong person was picked for this. How could an ordinary elderly woman play a part in all this. No turning back now though.","release_date":"1985-09-21","inventory":42},{"title":"Learning With My Home","overview":"The calm life of a elderly man is going the complete opposite way as a strange boy enters his life.","release_date":"1939-09-01","inventory":42},{"title":"Fearless With My Home","overview":"The strange boy claims the elderly man is one of the rare few people in possession of a guardian animal spirit. It's widely known these exist and rituals are held on a near weekly basis to connect with these guardian spirits, now its time to be the center of that ritual. Unconvinced of the situation, but trusting of this strange boy, the elderly man hesitantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.","release_date":"1965-03-28","inventory":42},{"title":"Thief Without A Conscience","overview":"But what if this strange boy can't be trusted. Or what if there's a change of mind. How could an ordinary elderly man be this important to the situation. Time to find out.","release_date":"1982-11-14","inventory":42},{"title":"Knight Of Last Rites","overview":"The normal life of a girl will be changed completely as a strange man enters her life.","release_date":"1973-12-16","inventory":42},{"title":"Horses With Hoods","overview":"The strange man claims the girl plays a vital role in the future, but that this version of the future cannot be allowed to be. The only way to prevent it is by traveling in time with this supposed time traveler. Sure of the truth in this situation, but somewhat distrustful of this strange man, the girl somewhat hesitantly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.","release_date":"1965-09-16","inventory":42},{"title":"Heirs With Gold","overview":"But what if this strange man cannot be relied upon. Or what if all this is an elaborate trap. How could an ordinary girl be relied upon in something this big. Only one way to find out.","release_date":"1949-10-03","inventory":42},{"title":"Scientists And Rats","overview":"The ordinary life of a young guy take a sharp turn as a childhood friend enters his life.","release_date":"1973-11-07","inventory":42},{"title":"Accidents Of Hell","overview":"But what if this childhood friend is a con artist. Or what if everything told is completely true. How could an ordinary young guy be relied upon in something this big. We're about to find out.","release_date":"1944-03-24","inventory":42},{"title":"Confinement Of War","overview":"The fast-paced life of a teenage girl changes in an instant as a friendly acquaintance enters her life.","release_date":"1959-04-06","inventory":42},{"title":"Breath Of The Apocalypse","overview":"The friendly acquaintance claims the teenage girl is actually already dead, a spirit trapped in a state of denial, not ready to move on yet. The person claims there's proof of this elsewhere. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the teenage girl oddly willingly agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.","release_date":"1965-06-10","inventory":42},{"title":"Force Of A Storm","overview":"But what if this friendly acquaintance cannot be relied upon. Or what if there's a change of mind. How could an ordinary teenage girl find out what's happening without help. Time to find out.","release_date":"1972-03-25","inventory":42},{"title":"Officer Without Fear","overview":"The ordinary life of a woman changes for better or worse as a strange woman enters her life.","release_date":"1987-03-06","inventory":42},{"title":"Spider Of The Gods","overview":"The strange woman claims the woman was a witness of a horrific crime, a crime for which an innocent person is in jail for. Due to the horrific nature of the crime the memory was likely blocked, but there's a way to unblock it and save an innocent life. Unconvinced of the situation, but trusting of this strange woman, the woman somewhat keenly agrees to the proposal, the situation is all too strange, it's best to get more information as soon as possible.","release_date":"2010-01-16","inventory":42},{"title":"Women Of Insanity","overview":"But what if this strange woman can't be trusted. Or what if the complete opposite is true. How could an ordinary woman end up in a situation like this. Only one way to find out.","release_date":"1997-10-03","inventory":42},{"title":"Doctors Of Water","overview":"The stable life of a teenage girl changes for better or worse as a stranger enters her life.","release_date":"1953-04-03","inventory":42},{"title":"Snakes And Turtles","overview":"The stranger claims the teenage girl better leave the city now. The rivaling gangs have spiraled into an all out war, soon the entire city will be a battleground and the government apparently plans to surround the city and let the gangs fight it out, better to let them kill each other than risk soldier lives they say. Suspicious of this situation, but somewhat trusting of this stranger, the teenage girl unusually eagerly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.","release_date":"1992-12-14","inventory":42},{"title":"Rogues And Boys","overview":"But what if this stranger is pulling a prank. Or what if all this is an elaborate trap. How could an ordinary teenage girl find out what's happening without help. We're about to find out.","release_date":"1979-12-30","inventory":42},{"title":"Loss Of The Sea","overview":"The relaxed life of a boy will change forever as a lost friend enters his life.","release_date":"1976-07-16","inventory":42},{"title":"Annihilation Of Autumn","overview":"The lost friend claims the boy is in possession of a powerful artifact, one which looks like any other object, but one which could bring total destruction if fallen in the wrong hands. The person wishes to destroy it, with or without help. Unconvinced of the situation, but trusting of this lost friend, the boy oddly enthusiastically agrees to the proposal, it might be a mistake, but both options could've been the mistake, one had to be chosen.","release_date":"2016-11-09","inventory":42},{"title":"Searching At The Leaders","overview":"But what if this lost friend is trying be misleading. Or what if the situation has changed or will change. How could an ordinary boy be this important to the situation. We're about to find out.","release_date":"1995-12-21","inventory":42},{"title":"Taste Of The Immortals","overview":"The rough life of a young girl might turn out differently as a strange woman enters her life.","release_date":"1948-02-12","inventory":42},{"title":"Criminal Arrangement","overview":"The strange woman claims the young girl is now cursed along with everybody else in this town. Why? By whom? What kind of curse exactly? Nobody seems to know, but the person supposedly responsible for this curse will explain everything at the town hall this afternoon, everybody should come. Unsure what to think of all this and of this strange woman, the young girl somewhat grudgingly agrees to the proposal, it's probably best to get to the bottom of this as soon as possible.","release_date":"1939-04-23","inventory":42},{"title":"Spider In The Window","overview":"But what if this strange woman is a con artist. Or what if the complete opposite is true. How could an ordinary young girl find out what's happening without help. Either way, the choice has been made.","release_date":"2007-06-29","inventory":42},{"title":"Comedian Makeover","overview":"The laid-back life of a young girl changes in an instant as a childhood friend enters her life.","release_date":"1944-06-14","inventory":42},{"title":"Baker On A Day Out","overview":"The childhood friend claims the young girl is in for a fun day. A new casino opened up in town and is giving everybody a free roll on their slot machine, with a little luck who knows what could happen. Skeptical of this situation and of this childhood friend, the young girl cautiously agrees to the proposal, if anything this will at least speed things up, for better and for worse.","release_date":"1948-07-26","inventory":42},{"title":"Spider And Thief","overview":"But what if this childhood friend is just a crazy person. Or what if everything told is completely true. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. No turning back now though.","release_date":"1950-05-07","inventory":42},{"title":"Rat And Chicken","overview":"The carefree life of a elderly man will change forever as a strange woman enters his life.","release_date":"1993-10-05","inventory":42},{"title":"Laughing Stalks Me","overview":"The strange woman claims the elderly man is now the citizen of a different country. The old country has just been taken over by an enemy force, everybody who wishes to leave this new nation has 3 days to do so. Distrustful of both this situation and of this strange woman, the elderly man tentatively agrees to the proposal, this whole situation is both exciting and terrifying at the same time, but surely the right choice was made.","release_date":"1946-09-06","inventory":42},{"title":"Fools Can Cook","overview":"But what if this strange woman is a con artist. Or what if this proposal is wrong or missing important details. How could an ordinary elderly man be this important to the situation. Only one way to find out.","release_date":"2013-11-20","inventory":42},{"title":"Power Of The Project","overview":"The unexciting life of a teenage boy is going in a different direction as a lost friend enters his life.","release_date":"1982-02-19","inventory":42},{"title":"Priest Of Outer Space","overview":"But what if this lost friend speaks only lies. Or what if the situation has changed or will change. How could an ordinary teenage boy come out of this situation in a better way. No turning back now though.","release_date":"1975-12-06","inventory":42},{"title":"Spy Of A Dog","overview":"The secluded life of a teenage girl take a sharp turn as a stranger enters her life.","release_date":"1972-11-18","inventory":42},{"title":"Enemies Of The Mountain","overview":"The stranger claims the teenage girl is in for a treat this afternoon. Supposedly this strange person has discovered a way to unlock the hidden potentials of the brain and will show the whole town this afternoon, it's not an event you want to miss. Concerned of the situation and a little distrusful of this stranger, the teenage girl tentatively agrees to the proposal, if anything this will at least speed things up, for better and for worse.","release_date":"1956-10-16","inventory":42},{"title":"Lions Of Tomorrow","overview":"But what if this stranger is wrong about all this. Or what if this proposal is wrong or missing important details. How could an ordinary teenage girl be helpful at all in this situation. Either way, the choice has been made.","release_date":"1983-07-03","inventory":42},{"title":"Serpents And Kings","overview":"The stable life of a elderly man might be changing forever as a friendly acquaintance enters his life.","release_date":"2016-09-08","inventory":42},{"title":"Agents And Robots","overview":"The friendly acquaintance claims the elderly man plays a vital role in the future, but that this version of the future cannot be allowed to be. The only way to prevent it is by traveling in time with this supposed time traveler. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the elderly man oddly enthusiastically agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.","release_date":"1964-06-19","inventory":42},{"title":"Death Of The Mountain","overview":"But what if this friendly acquaintance is trying be misleading. Or what if the complete opposite is true. How could an ordinary elderly man be needed for a situation like this. Time will tell.","release_date":"1973-07-22","inventory":42},{"title":"Picture Of The Lake","overview":"The casual life of a woman will change forever as a friendly acquaintance enters her life.","release_date":"2014-10-19","inventory":42},{"title":"Muted By The River","overview":"The friendly acquaintance claims the woman is actually already dead, a spirit trapped in a state of denial, not ready to move on yet. The person claims there's proof of this elsewhere. Sure of the truth in this situation, but somewhat distrustful of this friendly acquaintance, the woman hastily agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.","release_date":"1992-10-23","inventory":42},{"title":"Young In The Chasm","overview":"But what if this friendly acquaintance cannot be relied upon. Or what if the complete opposite is true. How could an ordinary woman be this important to the situation. Time to find out.","release_date":"1948-05-21","inventory":42},{"title":"Politicians Of The East","overview":"The normal life of a girl might be changing forever as a new friend enters her life.","release_date":"2010-11-30","inventory":42},{"title":"Women Of Science","overview":"The new friend claims the girl is the 'chosen one' according to an ancient prophecy. The prophecy states the chosen one will save the world, but only if properly trained. There is no time to waste. Distrustful of both this situation and of this new friend, the girl somewhat reluctantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.","release_date":"1956-04-02","inventory":42},{"title":"Preys Of The North","overview":"But what if this new friend is trying to manipulate the situation. Or what if everything told is completely true. How could an ordinary girl come out of this situation in a better way. No turning back now though.","release_date":"1957-07-12","inventory":42},{"title":"Kings Of Medicine","overview":"The nonchalant life of a woman might turn out differently as a strange woman enters her life.","release_date":"1966-12-22","inventory":42},{"title":"Stars And Sinners","overview":"The strange woman claims the woman is actually the rightful heir to the throne, this information has obviously been kept secret by the current holders of the throne, but once this information gets out to the public the people will surely stand behind the true heir. Concerned of the situation and a little distrusful of this strange woman, the woman somewhat hesitantly agrees to the proposal, surely this was the right choice to make, all of this has to have some truth to it.","release_date":"1985-08-30","inventory":42},{"title":"Fungi And Amphibians","overview":"But what if this strange woman is trying to manipulate the situation. Or what if the wrong person was picked for this. How could an ordinary woman be this lucky, or unlucky, depending on the turnout. Either way, the choice has been made.","release_date":"1971-02-07","inventory":42},{"title":"Wonders Of The Hunt","overview":"The laid-back life of a young guy has a chance to change, for better or worse, as a strange girl enters his life.","release_date":"1978-04-01","inventory":42},{"title":"Crimes Of The Mountains","overview":"The strange girl claims the young guy is now part of a murder investigation and might be the number one suspect, no arrest will be made in front of possible friends and neighbors if there's no resistance. Suspicious of this situation, but somewhat trusting of this strange girl, the young guy oddly willingly agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.","release_date":"1959-01-29","inventory":42},{"title":"Hidden The Swamps","overview":"But what if this strange girl is wrong about all this. Or what if all this is an elaborate trap. How could an ordinary young guy be needed for a situation like this. We're about to find out.","release_date":"1951-02-19","inventory":42},{"title":"Love For Women","overview":"The carefree life of a boy changes for better or worse as a friendly acquaintance enters his life.","release_date":"1952-02-24","inventory":42},{"title":"Savior Of The Curse","overview":"The strange woman claims the boy has a DNA strain which very likely offers the key to cure several crippling diseases. Tests will have to be done, but the key to save millions of lives is within the grasp of science through this DNA strain. Unsure what to think of all this and of this strange woman, the boy hesitantly agrees to the proposal, there's something exciting about this whole situation, surely the right choice was made.","release_date":"2010-11-05","inventory":42},{"title":"Invaders And Guardians","overview":"The childhood friend claims the young guy is in possession of a powerful artifact, an artifact which looks like any ordinary object, but an artifact which is of the utmost importance to this person, who will offer a reward for it. Sure of the truth in this situation, but somewhat distrustful of this childhood friend, the young guy oddly willingly agrees to the proposal, if all this turns out to be false, this choice will seem foolish, but it's still worth checking out.","release_date":"1990-06-04","inventory":42},{"title":"Man Of Dawn","overview":"But what if this friendly acquaintance is a con artist. Or what if somebody is orchestrating all of this. How could an ordinary boy play a part in all this. Either way, the choice has been made.","release_date":"1960-07-16","inventory":42},{"title":"Trueloves With Freckles","overview":"The fast-paced life of a elderly man will be permanently altered as a strange girl enters his life.","release_date":"1977-11-06","inventory":42},{"title":"Queens And Trueloves","overview":"But what if this strange girl is pulling a prank. Or what if everything told is completely true. How could an ordinary elderly man be helpful at all in this situation. Time to find out.","release_date":"1962-06-22","inventory":42},{"title":"Foreigners And Neighbors","overview":"The calm life of a young girl might turn out differently as a strange boy enters her life.","release_date":"2005-02-28","inventory":42},{"title":"Name Of Fortune","overview":"The strange boy claims the young girl was a witness of a horrific crime, a crime for which an innocent person is in jail for. Due to the horrific nature of the crime the memory was likely blocked, but there's a way to unblock it and save an innocent life. Suspicious of this situation, but somewhat trusting of this strange boy, the young girl somewhat reluctantly agrees to the proposal, there's no way this is all a lie, right? If it is, a terrible choice might have been made.","release_date":"1953-04-19","inventory":42},{"title":"Edge Of Tomorrow","overview":"But what if this strange boy can't be trusted. Or what if the wrong person was picked for this. How could an ordinary young girl be this lucky, or unlucky, depending on the turnout. Time to find out.","release_date":"2008-03-12","inventory":42},{"title":"Punished By The Stars","overview":"The secluded life of a elderly woman is going in a different direction as a childhood friend enters her life.","release_date":"2004-09-13","inventory":42},{"title":"Guarded By My Dreams","overview":"The childhood friend claims the elderly woman is actually part of a 'sub-species' of humans with hidden powers and wants to show what these hidden powers can do. Unsure about everything, including this childhood friend, the elderly woman somewhat gladly agrees to the proposal, but something does feel very wrong about this whole situation, hopefully the right choice was made.","release_date":"1986-04-26","inventory":42},{"title":"Man Of Exploration","overview":"But what if this childhood friend is a con artist. Or what if this proposal is wrong or missing important details. How could an ordinary elderly woman figure out the truth in all of this. Only one way to find out.","release_date":"2011-04-28","inventory":42},{"title":"Leader Of New Earth","overview":"The normal life of a young girl changes for better or worse as a strange man enters her life.","release_date":"1955-10-14","inventory":42},{"title":"Guardians Of Eternity","overview":"The strange man claims the young girl has been chosen to compete against others of other regions in a 'competition'. The winner will gain not only the honor and glory of winning, but will also never need for anything for the rest of their life. Certain of the truth in this situation and of this strange man, the young girl somewhat reluctantly agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.","release_date":"1946-12-27","inventory":42},{"title":"Soldiers Of The Outlands","overview":"But what if this strange man is wrong about all this. Or what if all this is an elaborate trap. How could an ordinary young girl end up in a situation like this. Either way, the choice has been made.","release_date":"1939-03-20","inventory":42},{"title":"Leaders And Commanders","overview":"The quiet life of a elderly man changes in an instant as a childhood friend enters his life.","release_date":"1982-03-15","inventory":42},{"title":"Medics And Strangers","overview":"The childhood friend claims the elderly man is actually the rightful heir to the throne, this information has obviously been kept secret by the current holders of the throne, but once this information gets out to the public the people will surely stand behind the true heir. Skeptical of this situation and of this childhood friend, the elderly man hesitantly agrees to the proposal, it all seemed rather odd, but there was no time to waste and a choice had to be made.","release_date":"2007-03-13","inventory":42},{"title":"Beginning Of The Vacuum","overview":"But what if this childhood friend is just a crazy person. Or what if all this is an elaborate trap. How could an ordinary elderly man be needed for a situation like this. Time will tell.","release_date":"1943-11-11","inventory":42},{"title":"Fate Of Alien Life","overview":"The normal life of a girl might be changing forever as a neighbor enters her life.","release_date":"1938-12-01","inventory":42},{"title":"Created By Androids","overview":"The neighbor claims the girl plays a vital role in the survival of the universe and must come along to train for battle or else the universe might be lost forever. Unsure about everything, including this neighbor, the girl hesitantly agrees to the proposal, the choice was made fast, perhaps too fast, but this situation requires quick thinking.","release_date":"1963-04-16","inventory":42},{"title":"Elegance Of The Machines","overview":"But what if this neighbor is wrong about all this. Or what if the situation is worse than it appears. How could an ordinary girl be this lucky, or unlucky, depending on the turnout. We're about to find out.","release_date":"1991-05-19","inventory":42},{"title":"Blacksmith Of The Banished","overview":"The unexciting life of a boy will be permanently altered as a strange woman enters his life.","release_date":"1979-01-18","inventory":42},{"title":"Intelligence Of My Teacher","overview":"The lost friend claims the teenage boy is in possession of a powerful artifact, one which looks like any other object, but one which could bring total destruction if fallen in the wrong hands. The person wishes to destroy it, with or without help. Unsure what to think of all this and of this lost friend, the teenage boy somewhat hesitantly agrees to the proposal, this whole situation is both exciting and terrifying at the same time, but surely the right choice was made.","release_date":"2017-02-18","inventory":42},{"title":"Boyfriend Of The Evening","overview":"The friendly acquaintance claims the boy has a DNA strain which very likely offers the key to cure several crippling diseases. Tests will have to be done, but the key to save millions of lives is within the grasp of science through this DNA strain. Skeptical of this situation and of this friendly acquaintance, the boy oddly willingly agrees to the proposal, it was probably a good idea to make a quick decision anyway.","release_date":"1973-02-27","inventory":42},{"title":"Girlfriends In The Forest","overview":"The strange girl claims the elderly man will need to find a new home as this current house will be demolished by the government in order to make room for a highway. A large sum of money will be paid if the house is left within a week. Distrustful of both this situation and of this strange girl, the elderly man somewhat keenly agrees to the proposal, there must be truth to all this and if so, this was the right choice to make.","release_date":"2009-05-03","inventory":42}]
diff --git a/db/seeds/rentals.json b/db/seeds/rentals.json
new file mode 100644
index 000000000..46005ca43
--- /dev/null
+++ b/db/seeds/rentals.json
@@ -0,0 +1,34 @@
+[
+ {
+ "checkout_date":"Mon, 05 Nov 2018",
+ "checkin_date":"Mon, 05 Nov 2018",
+ "due_date":"Tue, 06 Nov 2018",
+ "customer_id":1,
+ "movie_id":1
+ },
+ {
+ "checkout_date":"2018-11-06",
+ "due_date":"2017-11-06",
+ "customer_id":1,
+ "movie_id":3
+ },
+ {
+ "checkout_date":"2018-11-04",
+ "due_date":"2016-11-06",
+ "customer_id":2,
+ "movie_id":4
+ },
+ {
+ "checkout_date":"2018-11-04",
+ "due_date":"2015-11-06",
+ "customer_id":3,
+ "movie_id":3
+ },
+ {
+ "checkout_date":"Mon, 05 Nov 2018",
+ "checkin_date":"Tue, 06 Nov 2018",
+ "due_date":"Tue, 06 Nov 2018",
+ "customer_id":2,
+ "movie_id":2
+ }
+]
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/pseudocode-routes.md b/pseudocode-routes.md
new file mode 100644
index 000000000..087e187d0
--- /dev/null
+++ b/pseudocode-routes.md
@@ -0,0 +1,24 @@
+# Pseudocode routes file (pre Wave1)
+
+## pseudo-routes
+
+ get /customers to customers#index
+
+ get /movies to movies#index
+ get /movies/:id to movies#show
+ post /movies to movies#create
+
+ post '/rentals/check_out' to rentals#check_out
+ post '/rentals/check_in' to rentals#check_in
+ get /zomg to rentals#zomg
+
+
+## real routes
+
+ resources :customers, only: [:index]
+ resources :movies, only: [:index, :show, :create]
+
+ post '/rentals/check_out', to: 'rentals#check_out', as: 'check_out'
+ post '/rentals/check_in', to: 'rentals#check_in', as: 'check_in'
+
+ get '/zomg', to: 'rentals#zomg', as :'zomg'
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/storage/.keep b/storage/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/Updated_Wave2_smoke_test.postman_collection.json b/test/Updated_Wave2_smoke_test.postman_collection.json
new file mode 100644
index 000000000..d368eb223
--- /dev/null
+++ b/test/Updated_Wave2_smoke_test.postman_collection.json
@@ -0,0 +1,328 @@
+{
+ "info": {
+ "_postman_id": "b1841628-deeb-4959-8931-1de7a30515c4",
+ "name": "VideoStoreAPI Wave 2",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "List Customers",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var jsonData = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(jsonData);",
+ "tests[\"Many customers were sent\"] = jsonData.length > 0;",
+ "",
+ "// Save info on the first customer",
+ "postman.setEnvironmentVariable(\"customer_id\", jsonData[0].id);",
+ "postman.setEnvironmentVariable(\"customer_mcoc\", jsonData[0].movies_checked_out_count);",
+ "",
+ "// Check required fields",
+ "var hasId = true;",
+ "var hasName = true;",
+ "var hasRegisteredAt = true;",
+ "var hasPostalCode = true;",
+ "var hasPhone = true;",
+ "var hasMoviesCheckedOutCount = true;",
+ "",
+ "jsonData.forEach(function(customer) {",
+ " hasId = hasId && \"id\" in customer;",
+ " hasName = hasName && \"name\" in customer;",
+ " hasRegisteredAt = hasRegisteredAt && \"registered_at\" in customer;",
+ " hasPostalCode = hasPostalCode && \"postal_code\" in customer;",
+ " hasPhone = hasPhone && \"phone\" in customer;",
+ " hasMoviesCheckedOutCount = hasMoviesCheckedOutCount && \"movies_checked_out_count\" in customer;",
+ "});",
+ "",
+ "tests[\"All customers have id\"] = hasId;",
+ "tests[\"All customers have name\"] = hasName;",
+ "tests[\"All customers have registered_at\"] = hasRegisteredAt;",
+ "tests[\"All customers have postal_code\"] = hasPostalCode;",
+ "tests[\"All customers have phone\"] = hasPhone;",
+ "tests[\"All customers have movies_checked_out_count\"] = hasMoviesCheckedOutCount;"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/customers",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "customers"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "List Movies",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var jsonData = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(jsonData);",
+ "tests[\"Many movies were sent\"] = jsonData.length > 0;",
+ "",
+ "// Save info on the first movie",
+ "postman.setEnvironmentVariable(\"movie_id\", jsonData[0].id);",
+ "",
+ "// Check required fields",
+ "let hasId = true;",
+ "let hasTitle = true;",
+ "let hasReleaseDate = true;",
+ "",
+ "jsonData.forEach((movie) => {",
+ " hasId = hasId && \"id\" in movie;",
+ " hasTitle = hasTitle && \"title\" in movie;",
+ " hasReleaseDate = hasReleaseDate && \"release_date\" in movie;",
+ "});",
+ "",
+ "tests[\"All movies have id\"] = hasId;",
+ "tests[\"All movies have title\"] = hasTitle;",
+ "tests[\"All movies have release_date\"] = hasReleaseDate;"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Show Movie from List",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "69e67d62-d1b7-4924-9760-e573029a1cb8",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var movie = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(movie);",
+ "",
+ "// Check required fields",
+ "tests[\"Movie has title\"] = \"title\" in movie;",
+ "tests[\"Movie has overview\"] = \"overview\" in movie;",
+ "tests[\"Movie has release_date\"] = \"release_date\" in movie;",
+ "tests[\"Movie has inventory\"] = \"inventory\" in movie;",
+ "tests[\"Movie has inventory_available\"] = \"inventory_available\" in movie;",
+ "",
+ "// Save available inventory for later",
+ "postman.setEnvironmentVariable(\"movie_ai\", movie.inventory_available);"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies/{{movie_id}}",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies",
+ "{{movie_id}}"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Create Movie",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var response = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(response);",
+ "",
+ "// Check required fields",
+ "tests[\"Response has id\"] = \"id\" in response;",
+ "",
+ "// Save movie ID for the next test",
+ "pm.environment.set(\"created_movie_id\", response[\"id\"]);"
+ ]
+ }
+ },
+ {
+ "listen": "prerequest",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Generate a unique title for this movie, so that multiple runs don't conflict",
+ "const uniqueId = Math.random().toString(36).substring(2) ",
+ " + (new Date()).getTime().toString(36);",
+ "",
+ "pm.environment.set(\"movie_title\", `test_movie_${uniqueId}`);"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/x-www-form-urlencoded"
+ }
+ ],
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "title",
+ "value": "{{movie_title}}",
+ "type": "text"
+ },
+ {
+ "key": "overview",
+ "value": "This movie was created by the Postman smoke tests.",
+ "type": "text"
+ },
+ {
+ "key": "release_date",
+ "value": "1990-01-01",
+ "type": "text"
+ },
+ {
+ "key": "inventory",
+ "value": "5",
+ "type": "text"
+ }
+ ]
+ },
+ "url": {
+ "raw": "{{url}}/movies",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Show Created Movie",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "32384c3b-78bd-41fe-a7e8-5d8492fe0e10",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var movie = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(movie);",
+ "",
+ "// Check required fields",
+ "tests[\"Movie has title\"] = \"title\" in movie;",
+ "tests[\"Movie title matches POST data\"] = movie[\"title\"] == pm.environment.get(\"movie_title\");",
+ "tests[\"Movie has overview\"] = \"overview\" in movie;",
+ "tests[\"Movie has release_date\"] = \"release_date\" in movie;",
+ "tests[\"Movie has inventory\"] = \"inventory\" in movie;",
+ "tests[\"Movie has inventory_available\"] = \"inventory_available\" in movie;"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies/{{created_movie_id}}",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies",
+ "{{created_movie_id}}"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/Updated_Wave3_smoke_test.postman_collection.json b/test/Updated_Wave3_smoke_test.postman_collection.json
new file mode 100644
index 000000000..9c9825ecf
--- /dev/null
+++ b/test/Updated_Wave3_smoke_test.postman_collection.json
@@ -0,0 +1,485 @@
+{
+ "info": {
+ "_postman_id": "a7b77970-2768-4f27-a4fc-12c0e2696820",
+ "name": "VideoStoreAPI Wave 3",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "List Customers",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var jsonData = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(jsonData);",
+ "tests[\"Many customers were sent\"] = jsonData.length > 0;",
+ "",
+ "// Save info on the first customer",
+ "postman.setEnvironmentVariable(\"customer_id\", jsonData[0].id);",
+ "postman.setEnvironmentVariable(\"customer_mcoc\", jsonData[0].movies_checked_out_count);",
+ "",
+ "// Check required fields",
+ "var hasId = true;",
+ "var hasName = true;",
+ "var hasRegisteredAt = true;",
+ "var hasPostalCode = true;",
+ "var hasPhone = true;",
+ "var hasMoviesCheckedOutCount = true;",
+ "",
+ "jsonData.forEach(function(customer) {",
+ " hasId = hasId && \"id\" in customer;",
+ " hasName = hasName && \"name\" in customer;",
+ " hasRegisteredAt = hasRegisteredAt && \"registered_at\" in customer;",
+ " hasPostalCode = hasPostalCode && \"postal_code\" in customer;",
+ " hasPhone = hasPhone && \"phone\" in customer;",
+ " hasMoviesCheckedOutCount = hasMoviesCheckedOutCount && \"movies_checked_out_count\" in customer;",
+ "});",
+ "",
+ "tests[\"All customers have id\"] = hasId;",
+ "tests[\"All customers have name\"] = hasName;",
+ "tests[\"All customers have registered_at\"] = hasRegisteredAt;",
+ "tests[\"All customers have postal_code\"] = hasPostalCode;",
+ "tests[\"All customers have phone\"] = hasPhone;",
+ "tests[\"All customers have movies_checked_out_count\"] = hasMoviesCheckedOutCount;"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/customers",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "customers"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "List Movies",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var jsonData = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(jsonData);",
+ "tests[\"Many movies were sent\"] = jsonData.length > 0;",
+ "",
+ "// Save info on the first movie",
+ "postman.setEnvironmentVariable(\"movie_id\", jsonData[0].id);",
+ "",
+ "// Check required fields",
+ "var hasTitle = true;",
+ "var hasReleaseDate = true;",
+ "",
+ "jsonData.forEach(function(customer) {",
+ " hasTitle = hasTitle && \"title\" in customer;",
+ " hasReleaseDate = hasReleaseDate && \"release_date\" in customer;",
+ "});",
+ "",
+ "tests[\"All movies have title\"] = hasTitle;",
+ "tests[\"All movies have release_date\"] = hasReleaseDate;"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Show Movie",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "67d129fd-ed85-4786-8b1b-650f18893dcb",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var movie = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(movie);",
+ "",
+ "// Check required fields",
+ "tests[\"Movie has title\"] = \"title\" in movie;",
+ "tests[\"Movie has overview\"] = \"overview\" in movie;",
+ "tests[\"Movie has release_date\"] = \"release_date\" in movie;",
+ "tests[\"Movie has inventory\"] = \"inventory\" in movie;",
+ "tests[\"Movie has available_inventory\"] = \"inventory_available\" in movie;",
+ "",
+ "// Save available inventory for later",
+ "postman.setEnvironmentVariable(\"movie_ai\", movie.inventory_available);"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies/{{movie_id}}",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies",
+ "{{movie_id}}"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Check Out Movie",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "f58b2427-e72e-4c76-a830-f714e65942be",
+ "type": "text/javascript",
+ "exec": [
+ "tests[\"Status code is 200\"] = responseCode.code === 200;"
+ ]
+ }
+ },
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "decbbae7-c4e7-40ad-852d-e682814daac8",
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"movie_id\": {{movie_id}},\n\t\"customer_id\": {{customer_id}}\n}"
+ },
+ "url": {
+ "raw": "{{url}}/rentals/check-out",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "rentals",
+ "check-out"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Customer Check Out Count Increased",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Extract the customer we're interested in",
+ "var customerList = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(customerList);",
+ "",
+ "var customerId = postman.getEnvironmentVariable(\"customer_id\");",
+ "customerList = customerList.filter(function(c) { return c.id == customerId });",
+ "",
+ "tests[\"Sent back expected customer\"] = customerList.length == 1;",
+ "",
+ "// Check that the mcoc has increased",
+ "var expected = Number(postman.getEnvironmentVariable(\"customer_mcoc\")) + 1;",
+ "tests[\"Customer's movie check out count increased\"] = customerList[0].movies_checked_out_count === expected;",
+ ""
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/customers",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "customers"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Movie Available Inventory Decreased",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "df7072ff-1b21-4baf-93fb-63047430d01d",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var movie = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(movie);",
+ "",
+ "var expected = Number(postman.getEnvironmentVariable(\"movie_ai\")) - 1;",
+ "tests[\"Movie inventory_available decreased\"] = movie.inventory_available === expected;"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies/{{movie_id}}",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies",
+ "{{movie_id}}"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Check In Movie",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "tests[\"Status code is 200\"] = responseCode.code === 200;"
+ ]
+ }
+ },
+ {
+ "listen": "prerequest",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "var today = new Date();",
+ "",
+ "// Get 1 week from today. Works at the end of the month too.",
+ "var nextWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 7);",
+ "",
+ "// toDateString produces \"Wed Jul 28 1993\", which fortunately Rails is able to parse",
+ "postman.setEnvironmentVariable(\"future_due_date\", nextWeek.toDateString());"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"customer_id\": {{customer_id}},\n\t\"movie_id\": {{movie_id}}\n}"
+ },
+ "url": {
+ "raw": "{{url}}/rentals/check-in",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "rentals",
+ "check-in"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Customer Check Out Count Decreased",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Extract the customer we're interested in",
+ "var customerList = JSON.parse(responseBody);",
+ "tests[\"Data is an array\"] = Array.isArray(customerList);",
+ "",
+ "var customerId = postman.getEnvironmentVariable(\"customer_id\");",
+ "customerList = customerList.filter(function(c) { return c.id == customerId });",
+ "",
+ "tests[\"Sent back expected customer\"] = customerList.length == 1;",
+ "",
+ "// Check that the mcoc has decreased",
+ "var expected = Number(postman.getEnvironmentVariable(\"customer_mcoc\"));",
+ "tests[\"Customer's movie check out count decreased\"] = customerList[0].movies_checked_out_count === expected;",
+ ""
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/customers",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "customers"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Movie Available Inventory Increased",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "26502d5c-bc4f-4358-bb1b-256e26830427",
+ "exec": [
+ "// Check headers",
+ "tests[\"Status code is 200\"] = responseCode.code === 200;",
+ "",
+ "var contentType = postman.getResponseHeader(\"Content-Type\");",
+ "tests[\"Content-Type is present\"] = contentType;",
+ "tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
+ "",
+ "// Check data format",
+ "var movie = JSON.parse(responseBody);",
+ "tests[\"Data is not an array\"] = !Array.isArray(movie);",
+ "",
+ "var expected = Number(postman.getEnvironmentVariable(\"movie_ai\"));",
+ "tests[\"Movie inventory_available increased\"] = movie.inventory_available === expected;"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{url}}/movies/{{movie_id}}",
+ "host": [
+ "{{url}}"
+ ],
+ "path": [
+ "movies",
+ "{{movie_id}}"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/VideoStoreAPI_Wave_3_smoke_tests.postman_collection.json b/test/VideoStoreAPI_Wave_3_smoke_tests.postman_collection.json
index 9f640d98c..12d9d506f 100644
--- a/test/VideoStoreAPI_Wave_3_smoke_tests.postman_collection.json
+++ b/test/VideoStoreAPI_Wave_3_smoke_tests.postman_collection.json
@@ -479,4 +479,4 @@
"response": []
}
]
-}
\ No newline at end of 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..325c84222
--- /dev/null
+++ b/test/controllers/customers_controller_test.rb
@@ -0,0 +1,226 @@
+require "test_helper"
+
+describe CustomersController do
+ describe 'index action' do
+ it "should get index" do
+ get customers_path, as: :json
+ must_respond_with :success
+ end
+
+ it 'returns expected fields' do
+ fields = %w(id movies_checked_out_count name phone postal_code registered_at)
+ get customers_path, as: :json
+ body = JSON.parse(response.body)
+ body.each do |customer|
+ customer.keys.sort.must_equal fields
+ end
+ end
+ end
+
+ describe 'get query params' do
+ let (:new_customer) { Customer.new(id: 1,
+ name: "customer_first",
+ registered_at: Time.zone.now,
+ postal_code: "postal_code",
+ phone: "phone")
+ }
+ let (:new_customer2) { Customer.new(id: 2,
+ name: "customer_first",
+ registered_at: Time.zone.now,
+ postal_code: "postal_code",
+ phone: "phone")
+ }
+
+ describe 'sorter' do
+ it 'given a single valid sorter, it sorts Customers in ascending order' do
+ # valid: name, registered_at, and postal_code
+ new_customer.save!
+ path = '/customers?sort=registered_at'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.last["name"]).must_equal "customer_first"
+
+ new_customer.name = "wabylala"
+ new_customer.save!
+
+ path = '/customers?sort=registered_at'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.last["name"]).must_equal "wabylala"
+ end
+
+ it 'defaults to id: :asc if the query is nil or an empty string' do
+ new_customer.save!
+ path = '/customers'
+ query_string = ["", "?sort=", "?", "sort="]
+ query_string.each do |query|
+ path << query
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.first["name"]).must_equal "customer_first"
+ end
+ end
+
+ it 'will throw out invalid sorters and default to id' do
+ new_customer.save!
+ path = '/customers?sort='
+ query_string = ["bubble tea", "bubbletea", "address", "phone", "id"]
+ query_string.each do |query|
+ path << query
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.first["name"]).must_equal "customer_first"
+ end
+ end
+
+ it 'given >1 valid sorters, it applies sorters left to right' do
+ path = '/customers?sort=postal_code&sort=name'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body[0]["postal_code"]).must_equal "00000"
+ expect(body[1]["name"]).must_equal "Zipper Zigzag"
+ end
+ end
+
+ describe 'items per page' do
+ it 'returns the appropriate # of items per page "n"' do
+ get '/customers?n=2', as: :json
+ body = JSON.parse(response.body)
+ expect(body.length).must_equal 2
+ end
+
+ end
+
+ describe 'page number' do
+ before do
+ # clear customer db then create new set of 6
+ Customer.destroy_all
+ 6.times do |i|
+ Customer.create(id: i,
+ name: "customer_#{i}",
+ registered_at: Time.zone.now,
+ postal_code: "postal_code",
+ phone: "phone")
+ end
+
+ end
+
+ it 'returns a start page if specified "p"' do
+ # get 3rd page of customers at 2 per page
+ # starting at id=0, the first item on page 3
+ # should be id 4
+ get '/customers?n=2&p=3', as: :json
+ body = JSON.parse(response.body)
+ # expect 2nd set of fixtures sorted by id asc order
+ # use let to create 2 new customers
+ expect(body.length).must_equal 2
+ expect(body[0]["id"]).must_equal 4
+ end
+ end
+
+ describe 'If the client requests both sorting and pagination, pagination should be relative to the sorted order' do
+ it 'customers#index orders before it paginates' do
+ last_page = Customer.count
+
+ # in the database:
+ first_customer = Customer.first # "Beckham Use Me ONLY For rentals#overdue"
+ last_customer = Customer.last # "Yabadabadoo Use Me ONLY For rentals#overdue"
+
+ first_customer_by_name = Customer.order(:name).first # "Ada Lovelace"
+ last_customer_by_name = Customer.order(:name).last # "Zipper Zigzag"
+
+ first_customer_by_pc = Customer.order(:postal_code).first # "Ada Lovelace2",
+ last_customer_by_pc = Customer.order(:postal_code).last # "Angelica Use Me ONLY For rentals#overdue"
+
+ first_customer_by_regat = Customer.order(:registered_at).first # "Zipper Zigzag"
+ last_customer_by_regat = Customer.order(:registered_at).last # "Ada Lovelace2"
+
+ database_customers = [[first_customer_by_name, first_customer_by_pc, first_customer_by_regat],
+ [last_customer_by_name, last_customer_by_pc, last_customer_by_regat]]
+
+ # in query params: get 1 item on page 1. Also sort by each field.
+ # then get 1 item on page(last). Also sort by each field.
+
+ path = '/customers?n=1&p='
+ page_number_query = ["1", "#{last_page}"] # first page, last page
+ sort_query = %w(name postal%20code registered%20at)
+
+
+ # path_with_sort = '/customers?n=1&p=7&sort=postal+code'
+ # get path_with_sort, as: :json
+ # body = JSON.parse(response.body)
+ # expect(body[0]["name"]).must_equal Customer.order(:postal_code).last.name
+
+ page_number_query.each_with_index do |page_number, i_pages|
+ path_with_p = path + page_number + "&sort="
+ sort_query.each_with_index do |query, i_sorters|
+ path_with_sort = path_with_p + query
+ get path_with_sort, as: :json
+ body = JSON.parse(response.body)
+ expect(body[0]["name"]).must_equal database_customers[i_pages][i_sorters].name
+ end
+ end
+
+ # edge: TODO: what if query params are wonky? (test some likely urls)
+ end
+ end
+ end
+
+ describe 'Optional (additional) endpoints' do
+ let(:rental) {
+ { customer_id: Customer.first.id,
+ movie_id: Movie.last.id
+ }
+ }
+ it 'can list all rentals that are currently checked out by customer' do
+ # the first customer has one movie checked out
+ id = Customer.first.id
+ get "/customers/#{id}/current", as: :json
+ value(response).must_be :successful?
+ fields = %w(checked_out due movie rental_id returned)
+ body = JSON.parse(response.body)
+ # returns JSON of expected fields, sort fields
+ body.each do |movie|
+ expect(movie.keys.sort).must_equal fields.sort
+ end
+
+ # count movies in array with nil checkin date
+ expect(body.count).must_equal 1
+ expect do
+ post check_out_path, params: rental, as: :json
+ end.must_change 'Rental.count', 1
+
+ get "/customers/#{id}/current", as: :json
+ body = JSON.parse(response.body)
+ expect(body.count).must_equal 2
+ end
+
+ it 'can list all rentals in customers rental history' do
+ # the first customer has one movie checked out
+ id = Customer.first.id
+ # checkout a movie for first customer
+ post check_out_path, params: rental, as: :json
+ # return movie to provide a history
+ post check_in_path, params: rental, as: :json
+ # count movies in array with checkin date
+ # expect do
+ # post check_in_path, params: rental, as: :json
+ # end.wont_change 'Rental.count'
+
+ get "/customers/#{id}/history", as: :json
+ value(response).must_be :successful?
+ fields = %w(checked_out due movie rental_id returned)
+ body = JSON.parse(response.body)
+ # returns JSON of expected fields, sort fields
+
+
+ body.each do |movie|
+ expect(movie.keys.sort).must_equal fields.sort
+ end
+ expect(body.count).must_equal 1
+ expect(body.last["movie"]["title"]).must_equal Movie.last.title
+ end
+
+ end
+
+end
diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb
new file mode 100644
index 000000000..2a142fedc
--- /dev/null
+++ b/test/controllers/movies_controller_test.rb
@@ -0,0 +1,198 @@
+require "test_helper"
+
+describe MoviesController do
+ describe 'get api - index' do
+ it "is working route that returns json" do
+ # Act
+ get movies_path, as: :json
+ # Assert
+ expect(response.header['Content-Type']).must_include 'json'
+ must_respond_with :success
+ end
+
+ it 'returns an array' do
+ get movies_path, as: :json
+ body = JSON.parse(response.body)
+
+ expect(body).must_be_kind_of Array
+ end
+
+ it 'returns expected fields' do
+ fields = %w(id release_date title)
+ get movies_path, as: :json
+ body = JSON.parse(response.body)
+ body.each do |movie|
+ movie.keys.sort.must_equal fields
+ end
+ end
+ end
+
+
+ describe 'show api' do
+ it 'returns an individual response with expected fields' do
+ get movie_path(Movie.first.id), as: :json
+ must_respond_with :success
+ body = JSON.parse(response.body)
+
+ fields = %w(id title overview release_date inventory inventory_available).sort
+ expect(body.keys.sort).must_equal fields
+ end
+
+ it 'return a 404 if movie DNE' do
+ id = -999
+ get movie_path(id), as: :json
+ must_respond_with :not_found
+
+ body = JSON.parse(response.body)
+ expect(body["ok"]).must_equal false
+ expect(body["cause"]).must_equal "not_found"
+ end
+ end
+
+ describe 'create api (post)' do
+ let (:movie_hash) {
+ {title: "test movie",
+ overview: "spoiler alert!",
+ release_date: Date.yesterday,
+ inventory: 99
+ }
+ }
+
+ it 'can create a new movie in db with valid data and return an id' do
+ expect{
+ post movies_path, params: movie_hash, as: :json
+ }.must_change 'Movie.count', 1
+
+ value(response).must_be :successful?
+ expect(response.header['Content-Type']).must_include 'json'
+ body = JSON.parse(response.body)
+ expect(body.keys).must_equal ["id"]
+ expect(body["id"]).must_equal Movie.last.id
+ end
+
+ it 'will not change db if a movie is created w/ garbage data' do
+ movie_hash[:title] = nil
+ expect{
+ post movies_path, params: movie_hash, as: :json
+ }.wont_change 'Movie.count'
+ body = JSON.parse(response.body)
+ must_respond_with :bad_request
+ expect(body["ok"]).must_equal false
+ expect(body["cause"]).must_equal "validation errors"
+ expect(body["errors"].keys).must_include "title"
+ end
+ end
+
+ describe 'get query params' do
+ let (:new_movie) { Movie.new(id: 1,
+ title: "movie_first",
+ overview: "watch me",
+ release_date: Date.current,
+ inventory: 5,
+ inventory_available: 0)
+ }
+ describe 'sorter' do
+ it 'given a single valid sorter, it sorts Movies in ascending order' do
+ # valid: title, release_date
+ path = '/movies?sort=title'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.last["title"]).must_equal "CATTACA"
+ end
+
+ it 'defaults to id: :asc if the query is nil or an empty string' do
+ new_movie.save!
+ path = '/movies'
+ query_string = ["", "?sort=", "?", "sort="]
+ query_string.each do |query|
+ path << query
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.first["title"]).must_equal "movie_first"
+ end
+ end
+
+ it 'will throw out invalid sorters and default to id' do
+ new_movie.save!
+ path = '/movies?sort='
+ query_string = ["bubble tea", "bubbletea", "overview", "inventory", "inventory_available"]
+ query_string.each do |query|
+ path << query
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body.first["title"]).must_equal "movie_first"
+ end
+ end
+
+ it 'given >1 valid sorters, it applies sorters left to right' do
+ path = '/movies?sort=release_date&sort=title'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body[0]["title"]).must_equal "Bend It Like It Like That"
+ expect(body[1]["title"]).must_equal "CATTACA"
+ end
+ end
+
+
+ describe 'endpoints' do
+ let(:rental) {
+ { customer_id: Customer.first.id,
+ movie_id: Movie.last.id
+ }
+ }
+ it 'can list all rentals that are currently checked out' do
+ # clear all rental data
+ Rental.destroy_all
+ # the movie gets checked out by the first customer
+ post check_out_path, params: rental, as: :json
+
+ id = Movie.last.id
+ get "/movies/#{id}/current", as: :json
+ value(response).must_be :successful?
+ fields = %w(rental_id checked_out due returned customer)
+ body = JSON.parse(response.body)
+ # returns JSON of expected fields, sort fields
+ body.each do |customer|
+ expect(customer.keys.sort).must_equal fields.sort
+ end
+
+ expect(body[0]["customer"].keys).must_include "name"
+ expect(body[0]["customer"]["postal_code"]).must_equal Customer.first.postal_code
+ # count movies in array with nil checkin date
+ expect(body.count).must_equal 1
+ post check_out_path, params: rental, as: :json
+
+
+ get "/movies/#{id}/current", as: :json
+ body = JSON.parse(response.body)
+ expect(body.count).must_equal 2
+ end
+
+ it 'can list all rental history for completed rentals' do
+ # clear all rental data
+ Rental.destroy_all
+ id = Movie.last.id
+ # the movie gets checked out by the first customer
+ post check_out_path, params: rental, as: :json
+ # return movie to provide a history
+ post check_in_path, params: rental, as: :json
+
+ get "/movies/#{id}/history", as: :json
+ value(response).must_be :successful?
+ fields = %w(rental_id checked_out due returned customer)
+ body = JSON.parse(response.body)
+ # returns JSON of expected fields, sort fields
+ body.each do |customer|
+ expect(customer.keys.sort).must_equal fields.sort
+ end
+ expect(body[0]["customer"].keys).must_include "name"
+ expect(body.count).must_equal 1
+
+ expect(body[0]["customer"]["name"]).must_equal Customer.first.name
+ expect(body[0]["customer"]["postal_code"]).must_equal Customer.first.postal_code
+ end
+ end
+ end
+end
+
+
diff --git a/test/controllers/rentals_controller_test.rb b/test/controllers/rentals_controller_test.rb
new file mode 100644
index 000000000..2bef44b62
--- /dev/null
+++ b/test/controllers/rentals_controller_test.rb
@@ -0,0 +1,309 @@
+require "test_helper"
+require 'date'
+
+describe RentalsController do
+ let(:rental) {
+ { customer_id: 859843310,
+ movie_id: 400453147
+ }
+ }
+
+ it 'zomg, a success message!' do
+ get zomg_path, as: :json
+ value(response).must_be :successful?
+ expect(JSON.parse(response.body)["message"]).must_equal "it works"
+ end
+
+ it 'can list all overdue rentals that are currently checked out' do
+ get overdue_path, as: :json
+ # success response
+ value(response).must_be :successful?
+ fields = %w(movie_id customer_id checkout_date due_date movie customer)
+ body = JSON.parse(response.body)
+ # returns JSON of expected fields, sort fields
+ body.each do |rental|
+ expect(rental.keys.sort).must_equal fields.sort
+ end
+ # count in array is ovedue rentals without checkin date
+ overdue_rentals = Rental.where(checkin_date: nil).where("rentals.due_date < ?", Date.current)
+ expect(overdue_rentals.count).must_equal 3
+ expect(body.count).must_equal 3
+
+ # SJL: maybe: also check nested hashes
+ end
+
+ it 'can list zero rentals if there are no overdue rentals currently checked out' do
+ Rental.destroy_all
+ get overdue_path, as: :json
+ value(response).must_be :successful?
+ body = JSON.parse(response.body)
+ body = []
+ end
+
+ it 'can checkout a movie' do
+ # POST /rentals/check_out
+ fields = %w(id movie_id customer_id due_date checkout_date checkin_date).sort
+ movie_inv_avail_start = Movie.find(400453147).inventory_available
+ # binding.pry
+ expect do
+ post check_out_path, params: rental, as: :json
+ end.must_change 'Rental.count', 1
+
+ movie_inv_avail_end = Movie.find(400453147).inventory_available
+ value(response).must_be :successful?
+
+ expect(response.header['Content-Type']).must_include 'json'
+ body = JSON.parse(response.body)
+
+ expect(body.keys.sort).must_equal fields
+ expect(body["checkout_date"]).must_equal Date.current.to_s
+ expect(body["checkin_date"]).must_be_nil
+ expect(body["due_date"]).must_equal (Date.current + 7).to_s
+ expect(movie_inv_avail_end).must_equal movie_inv_avail_start - 1
+ end
+
+ it 'can checkin a movie' do
+ # post '/rentals/check_in'
+ fields = %w(id movie_id customer_id due_date checkout_date checkin_date).sort
+ post check_out_path, params: rental
+ movie_inv_avail_start = Movie.find(400453147).inventory_available
+
+ expect do
+ post check_in_path, params: rental, as: :json
+ end.wont_change 'Rental.count'
+
+ movie_inv_avail_end = Movie.find(400453147).inventory_available
+ value(response).must_be :successful?
+
+ expect(response.header['Content-Type']).must_include 'json'
+ body = JSON.parse(response.body)
+
+ expect(body.keys.sort).must_equal fields
+ expect(body["checkin_date"]).must_equal Date.current.to_s
+ expect(movie_inv_avail_end).must_equal movie_inv_avail_start + 1
+ end
+
+ describe 'Checkin and Checkout' do
+ let (:customer) { customers(:customer_out)}
+ let (:movie) { movies(:movie_in)}
+ let(:new_rental_params) {
+ { customer_id: customer.id,
+ movie_id: movie.id
+ }
+ }
+ it 'checking OUT a movie increases customer mcoc count by one' do
+
+ # START
+ get customers_path, as: :json
+ body = JSON.parse(response.body) # array of all customers
+ body = body.select {|cust| cust["id"] == customer.id} # array of a single customer hash
+ mcoc_start = body[0]["movies_checked_out_count"]
+ expect(mcoc_start).must_equal 3 # just to be sure of our fixtures
+
+ # CHECKOUT
+ post check_out_path, params: new_rental_params, as: :json
+ value(response).must_be :successful?
+
+ # END
+ get customers_path, as: :json
+ body2 = JSON.parse(response.body) # array of all customers
+ body2 = body2.select {|cust| cust["id"] == customer.id} # array of a single customer hash
+ mcoc_end = body2[0]["movies_checked_out_count"]
+ expect(mcoc_end).must_equal 4 # FAIL: expect 4, actual 0
+ end
+
+ it 'checking IN a movie decreases customer mcoc count by one' do
+ ################################################
+ # SJL: This should be an exact copy of the check-in test from the check-out test below.
+ ################################################
+ # ZERO
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body = JSON.parse(response.body) # array of all customers
+ body = body.select {|cust| cust["id"] == customer.id} # array of a single customer hash
+ mcoc_zero = body[0]["movies_checked_out_count"]
+ expect(mcoc_zero).must_equal 3 # from fixtures
+ expect(Rental.count).must_equal 9
+
+ # CHECK OUT
+ post check_out_path, params: new_rental_params, as: :json
+ value(response).must_be :successful?
+ expect(Rental.count).must_equal 10
+
+ # BEFORE
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body2 = JSON.parse(response.body) # array of all customers
+ body2 = body2.select {|cust| cust["id"] == customer.id}
+ mcoc_before = body2[0]["movies_checked_out_count"]
+ expect(mcoc_before).must_equal 4 # mcoc_zero + 1
+
+ # CHECK IN
+ post check_in_path, params: new_rental_params, as: :json
+ value(response).must_be :successful?
+ expect(Rental.count).must_equal 10
+
+ # AFTER
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body3 = JSON.parse(response.body) # array of all customers
+ body3 = body3.select {|cust| cust["id"] == customer.id}
+ mcoc_end = body3[0]["movies_checked_out_count"]
+ expect(mcoc_end).must_equal 3 #mcoc_zero
+
+
+ ################################################
+ # SJL: REPEAT TEST A SECOND TIME to make sure the correct rental
+ # is retrieved from an array of rentals.
+ ################################################
+
+ # ZERO
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body = JSON.parse(response.body) # array of all customers
+ body = body.select {|cust| cust["id"] == customer.id} # array of a single customer hash
+ mcoc_zero = body[0]["movies_checked_out_count"]
+ expect(mcoc_zero).must_equal 3 # from fixtures
+ expect(Rental.count).must_equal 10
+
+ # CHECK OUT
+ post check_out_path, params: new_rental_params, as: :json
+ value(response).must_be :successful?
+ expect(Rental.count).must_equal 11
+
+ # BEFORE
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body2 = JSON.parse(response.body) # array of all customers
+ body2 = body2.select {|cust| cust["id"] == customer.id}
+ mcoc_before = body2[0]["movies_checked_out_count"]
+ expect(mcoc_before).must_equal 4 # mcoc_zero + 1
+
+ # CHECK IN
+ post check_in_path, params: new_rental_params, as: :json
+ value(response).must_be :successful?
+
+ # AFTER
+ get customers_path, as: :json
+ value(response).must_be :successful?
+ body3 = JSON.parse(response.body) # array of all customers
+ body3 = body3.select {|cust| cust["id"] == customer.id}
+ mcoc_end = body3[0]["movies_checked_out_count"]
+ expect(Rental.count).must_equal 11
+ expect(mcoc_end).must_equal 3 #mcoc_zero # FAIL: expect 3, actual 4
+ end
+ end
+
+ describe 'errors' do
+ let(:customer) { customers(:customer_out)}
+ let(:movie) { movies(:movie_out4)}
+ let(:rental) {
+ { customer_id: customer.id,
+ movie_id: movie.id
+ }
+ }
+ let(:rental_bad) {
+ { customer_id: customer.id,
+ movie_id: 1337
+ }
+ }
+ let(:customer_bad) {
+ { customer_id: 1337,
+ movie_id: movie.id
+ }
+ }
+
+ it 'sends an error msg when all movies have been checked out' do
+ # checkout a movie with inventory of 1 twice
+ 50.times do
+ post check_out_path, params: rental, as: :json
+ end
+ post check_out_path, params: rental, as: :json
+
+ must_respond_with :bad_request
+
+ body = JSON.parse(response.body)
+ expect(body["ok"]).must_equal false
+ expect(body["cause"]).must_equal "validation errors"
+ # TODO can't get messages to add to errors hash - have tried errors.add "msg" and errors << "msg"
+ end
+
+ it 'sends a validation error when movie checkout data is garbage' do
+ # check out with bad movie id
+ post check_out_path params: rental_bad, as: :json
+ must_respond_with :bad_request
+
+ body = JSON.parse(response.body)
+ expect(body["ok"]).must_equal false
+ expect(body["cause"]).must_equal "validation errors"
+ # TODO can't get messages to add to errors hash - have tried errors.add "msg" and errors << "msg"
+ # binding.pry
+ expect(body["errors"]["movie"]).must_include "must exist"
+ end
+
+ it 'sends a validation error when customer checkout data is garbage' do
+ # check out with bad movie id
+ post check_out_path params: rental_bad, as: :json
+ must_respond_with :bad_request
+
+ body = JSON.parse(response.body)
+ expect(body["ok"]).must_equal false
+ expect(body["cause"]).must_equal "validation errors"
+ # TODO can't get messages to add to errors hash - have tried errors.add "msg" and errors << "msg"
+ expect(body["errors"]["movie"]).must_include "must exist"
+ end
+ end
+
+ describe 'get query params' do
+ describe 'sorter' do
+ it 'given a single valid rental sorter, it sorts Overdue Rentals in ascending order' do
+ path = '/rentals/overdue?sort=due%20date'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(Date.parse(body[0]["due_date"])).must_equal rentals(:rental_odt_3).due_date
+ expect(Date.parse(body[1]["due_date"])).must_equal rentals(:rental_odt_2).due_date
+ expect(Date.parse(body[2]["due_date"])).must_equal rentals(:rental_odt_1).due_date
+ end
+
+ it 'sorts by associated records, e.g. movie title' do
+ path = '/rentals/overdue?sort=title'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body[0]["movie"]["title"]).must_equal "Actually Love"
+ expect(body[1]["movie"]["title"]).must_equal "Actually Love"
+ expect(body[2]["movie"]["title"]).must_equal "Bend It Like It Like That"
+ end
+
+ it 'defaults to id: :asc if the query is nil or an empty string' do
+ path = '/rentals/overdue'
+ query_string = ["", "?sort=", "?", "sort="]
+
+ overdue_rentals_fixtures_rental_ids_sorted =
+ [rentals(:rental_odt_1).id,
+ rentals(:rental_odt_2).id,
+ rentals(:rental_odt_3).id].sort
+ first_id = overdue_rentals_fixtures_rental_ids_sorted[0]
+ first_overdue_rental_fixture_by_id = Rental.find(first_id)
+
+ query_string.each do |query|
+ path << query
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(Date.parse(body.first["due_date"])).must_equal first_overdue_rental_fixture_by_id.due_date
+ end
+ end
+
+ it 'given >1 valid sorters, it applies sorters left to right' do
+ path = '/rentals/overdue?sort=title&sort=name'
+ get path, as: :json
+ body = JSON.parse(response.body)
+ expect(body[0]["movie"]["title"][0]).must_equal "A"
+ expect(body[1]["movie"]["title"][0]).must_equal "A"
+ expect(body[2]["movie"]["title"][0]).must_equal "B"
+ expect(body[0]["customer"]["name"][0]).must_equal "A"
+ expect(body[1]["customer"]["name"][0]).must_equal "Y"
+ expect(body[2]["customer"]["name"][0]).must_equal "B"
+ end
+ end
+ 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..87932b7ea
--- /dev/null
+++ b/test/fixtures/customers.yml
@@ -0,0 +1,57 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+customer_in:
+ name: Ada Lovelace
+ registered_at: 2018-11-05 12:32:19
+ address:
+ state: MyString
+ postal_code: "22222"
+ phone: aphonenumber
+
+customer_out:
+ name: Ada Lovelace
+ registered_at: 2018-11-05 12:32:19
+ address:
+ state: MyString
+ postal_code: "11111"
+ phone: MyString
+
+customer_tomorrow:
+ name: Ada Lovelace2
+ registered_at: 2018-11-06 12:32:19
+ address:
+ state: MyString
+ postal_code: "00000"
+ phone: MyString
+
+customer_z:
+ name: Zipper Zigzag
+ registered_at: 1991-11-06 12:32:19
+ address:
+ state: MyString
+ postal_code: "00000"
+ phone: MyString
+
+customer_odt_1:
+ name: Angelica Use Me ONLY For rentals#overdue
+ registered_at: 1991-11-06 12:32:19
+ address:
+ state: MyString
+ postal_code: 99999998
+ phone: MyString
+
+customer_odt_2:
+ name: Beckham Use Me ONLY For rentals#overdue
+ registered_at: 1991-11-06 12:32:19
+ address:
+ state: MyString
+ postal_code: 99999999
+ phone: MyString
+
+customer_odt_3:
+ name: Yabadabadoo Use Me ONLY For rentals#overdue
+ registered_at: 1991-11-06 12:32:19
+ address:
+ state: MyString
+ postal_code: 99999998
+ 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..498fa57fe
--- /dev/null
+++ b/test/fixtures/movies.yml
@@ -0,0 +1,50 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+movie_out:
+ title: Actually Love
+ overview: MyString
+ release_date: 2018-11-05
+ inventory: 20
+ inventory_available: 19
+
+movie_in:
+ title: Bend It Like It Like That
+ overview: MyString
+ release_date: 1991-11-05
+ inventory: 20
+ inventory_available: 20
+
+movie_out3:
+ title: CATTACA
+ overview: MyString
+ release_date: 1991-11-05
+ inventory: 50
+ inventory_available: 47
+
+movie_out4:
+ title: Actually Love
+ overview: MyString
+ release_date: 2018-11-05
+ inventory: 1
+ inventory_available: 1
+
+movie_odt_1:
+ title: Actually Love
+ overview: MyString
+ release_date: 2018-11-05
+ inventory: 20
+ inventory_available: 20
+
+movie_odt_2:
+ title: Bend It Like It Like That
+ overview: MyString
+ release_date: 2018-11-05
+ inventory: 20
+ inventory_available: 20
+
+movie_odt_3:
+ title: CATTACA
+ overview: MyString
+ release_date: 2018-11-05
+ inventory: 20
+ inventory_available: 20
diff --git a/test/fixtures/rentals.yml b/test/fixtures/rentals.yml
new file mode 100644
index 000000000..57551f52a
--- /dev/null
+++ b/test/fixtures/rentals.yml
@@ -0,0 +1,64 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+rental_out:
+ checkout_date: 2018-11-05
+ checkin_date:
+ due_date: Date.current + 30
+ movie: movie_out
+ customer: customer_out
+
+rental_in:
+ checkout_date: 2018-11-04
+ checkin_date: 2018-11-05
+ due_date: 2018-11-09
+ movie: movie_in
+ customer: customer_in
+
+rental_out2:
+ checkout_date: 2018-11-05
+ checkin_date:
+ due_date: Date.current + 30
+ movie: movie_out3
+ customer: customer_out
+
+rental_out3:
+ checkout_date: 2018-11-05
+ checkin_date:
+ due_date: Date.current + 30
+ movie: movie_out3
+ customer: customer_out
+
+rental_odt_1:
+ checkout_date: 2018-11-6
+ checkin_date:
+ due_date: 2017-11-6
+ movie: movie_odt_1
+ customer: customer_odt_1
+
+rental_odt_2:
+ checkout_date: 2018-11-4
+ checkin_date:
+ due_date: 2016-11-6
+ movie: movie_odt_2
+ customer: customer_odt_2
+
+rental_odt_3:
+ checkout_date: 2018-11-4
+ checkin_date:
+ due_date: 2015-11-6
+ movie: movie_odt_1
+ customer: customer_odt_3
+
+out_rental_not_due_yet:
+ checkout_date: 2018-11-05
+ checkin_date:
+ due_date: Date.current + 30
+ movie: movie_odt_3
+ customer: customer_odt_3
+
+overdue_rental_checked_in:
+ checkout_date: 2000-11-10
+ checkin_date: 2018-11-05
+ due_date: 2001-11-10
+ movie: movie_odt_1
+ customer: customer_odt_3
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..4f0b8949e
--- /dev/null
+++ b/test/models/customer_test.rb
@@ -0,0 +1,66 @@
+require "test_helper"
+
+describe Customer do
+
+ describe 'Validations' do
+ let (:new_customer) { Customer.new(name: "valid customer",
+ registered_at: Time.zone.now,
+ postal_code: "postal_code",
+ phone: "phone")
+ }
+
+ it "a customer can be created with all required fields present" do
+ new_customer.save
+ new_customer.valid?.must_equal true
+ end
+
+ it "a customer cannot be created if any required field is not present" do
+ fields = [:name, :registered_at, :postal_code, :phone]
+ setters = [:name=, :registered_at=, :postal_code=, :phone=]
+ setters.each_with_index do |setter, index|
+ new_customer.send(setter, nil)
+ new_customer.valid?.must_equal false
+ new_customer.errors.messages.must_include fields[index]
+ end
+ end
+ end
+
+
+ describe 'Relationships' do
+ let(:cust) { customers(:customer_out) }
+ it 'can have many rentals' do
+ rents = cust.rentals
+
+ expect(rents.length).must_be :>, 1
+ rents.each do |r|
+ expect(r).must_be_instance_of Rental
+ end
+ end
+
+ it 'can have many movies through rentals' do
+ movies = cust.movies
+ # binding.pry
+ expect(movies.length).must_be :>, 1
+ movies.each do |m|
+ expect(m).must_be_instance_of Movie
+ end
+ end
+
+
+ end
+end
+
+
+
+# describe 'Custom Methods' do
+# it 'movies_out_count is correct for customers with rental history' do
+# expect(customers(:customer_out).movies_out_count).must_equal 1
+# expect(customers(:customer_in).movies_out_count).must_equal 0
+# end
+#
+# it 'movies_out_count works on a customer with no rentals' do
+# Rental.destroy_all
+# expect(customers(:customer_out).rentals.count).must_equal 0
+# expect(customers(:customer_out).movies_out_count).must_equal 0
+# end
+# end
diff --git a/test/models/movie_test.rb b/test/models/movie_test.rb
new file mode 100644
index 000000000..8d831935a
--- /dev/null
+++ b/test/models/movie_test.rb
@@ -0,0 +1,47 @@
+require "test_helper"
+
+describe Movie do
+ describe 'Validations' do
+ let (:new_movie) { Movie.new(title: "valid movie",
+ overview: "overview",
+ release_date: Date.current,
+ inventory: 99)
+ }
+
+ it "a movie can be created with all required fields present" do
+ new_movie.save
+ new_movie.valid?.must_equal true
+ end
+
+ it "a movie cannot be created if any required field is not present" do
+ fields = [:title, :overview, :release_date, :inventory]
+ setters = [:title=, :overview=, :release_date=, :inventory=]
+ setters.each_with_index do |setter, index|
+ new_movie.send(setter, nil)
+ new_movie.valid?.must_equal false
+ new_movie.errors.messages.must_include fields[index]
+ end
+ end
+ end
+
+ describe 'relationships' do
+ let(:mov) { movies(:movie_out3) }
+
+ it 'has many rentals' do
+ rents = mov.rentals
+
+ expect(rents.length).must_be :>, 1
+ rents.each do |r|
+ expect(r).must_be_instance_of Rental
+ end
+ end
+
+ it 'has many customers through rental' do
+ custs = mov.customers
+ expect(custs.length).must_be :>, 1
+ custs.each do |c|
+ expect(c).must_be_instance_of Customer
+ end
+ end
+ end
+end
diff --git a/test/models/rental_test.rb b/test/models/rental_test.rb
new file mode 100644
index 000000000..64dd65633
--- /dev/null
+++ b/test/models/rental_test.rb
@@ -0,0 +1,65 @@
+require "test_helper"
+
+describe Rental do
+ let (:rental_in) { rentals(:rental_in)}
+ let (:rental_out) {rentals(:rental_out)}
+
+ describe 'Validations' do
+ let (:new_rental) { Rental.new(checkout_date: Date.current,
+ due_date: Date.tomorrow,
+ customer: customers(:customer_out),
+ movie: movies(:movie_in))
+ }
+
+ it "a rental can be created with all required fields present" do
+ new_rental.save
+ new_rental.valid?.must_equal true
+ end
+
+ it "a rental cannot be created if any required field is not present" do
+ fields = [:checkout_date, :due_date, :customer, :movie]
+ setters = [:checkout_date=, :due_date=, :customer=, :movie=]
+ setters.each_with_index do |setter, index|
+ new_rental.send(setter, nil)
+ new_rental.valid?.must_equal false
+ new_rental.errors.messages.must_include fields[index]
+ end
+ end
+ end
+
+ describe 'Custom Methods' do
+ it 'a rental is complete if it has a checkin date' do
+ expect(rental_in.complete?).must_equal true
+ end
+
+ it 'a rental is not complete if it does not have a checkin date' do
+ expect(rental_out.complete?).must_equal false
+ end
+ end
+
+
+ describe 'relationships' do
+
+ it 'belongs to a customer' do
+ # Arrange (done with let)
+
+ # Act
+ customer = rental_in.customer
+
+ # Assert
+ expect(customer).must_be_instance_of Customer
+ expect(customer.id).must_equal rental_in.customer_id
+ end
+
+ it 'belongs to a movie' do
+ # Arrange (done with let)
+
+ # Act
+ movie = rental_in.movie
+
+ # Assert
+ expect(movie).must_be_instance_of Movie
+ expect(movie.id).must_equal rental_in.movie_id
+ end
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 000000000..7fac2b396
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,30 @@
+require 'simplecov'
+SimpleCov.start
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
+require "minitest/rails"
+require "minitest/reporters" # for Colorized output
+
+# For colorful output!
+Minitest::Reporters.use!(
+ Minitest::Reporters::SpecReporter.new,
+ ENV,
+ Minitest.backtrace_filter
+)
+
+
+# To add Capybara feature tests add `gem "minitest-rails-capybara"`
+# to the test group in the Gemfile and uncomment the following:
+# require "minitest/rails/capybara"
+
+# Uncomment for awesome colorful output
+# require "minitest/pride"
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+ # 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