Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ashton & Addie's VideoStoreAPI #17

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ff54822
initial rails setup
add2point71dots May 9, 2017
d8cf182
created models and controllers for movie and customer
add2point71dots May 9, 2017
3ccc5bc
customer validations and tests
add2point71dots May 9, 2017
392bcb5
added simplecov
add2point71dots May 9, 2017
05aa5bd
movie model validations and testing
add2point71dots May 9, 2017
f47b977
customer's account_credit must be a number
add2point71dots May 9, 2017
292b1e2
index method and tests for customers
add2point71dots May 9, 2017
d5b5b2b
added movies_checked_out_count to customer model as a required field …
add2point71dots May 9, 2017
e7a35f8
gives movies_checked_out_count data in customers show
add2point71dots May 9, 2017
3006e38
cleaned up code slightly
add2point71dots May 9, 2017
7fa0fa1
fixed confusing variable name
add2point71dots May 9, 2017
07ebb0b
changed constant name so it wasn't the same across different tests
add2point71dots May 9, 2017
bb157a9
movies index method and tests
add2point71dots May 9, 2017
0494237
movies show method and tests
add2point71dots May 9, 2017
b3a790f
added available_inventory as a field and set it to the inventory numb…
add2point71dots May 9, 2017
a78854f
validations and tests on available_inventory
add2point71dots May 9, 2017
4657fd7
made available_inventory available in movies show
add2point71dots May 9, 2017
4a46faa
adding erd.pdf/test pushing
ashtn May 10, 2017
e5a020b
updated customer and movie model
ashtn May 10, 2017
babc29c
adjusted movie tests to account for removed schema column
ashtn May 10, 2017
14dd978
adjusted customer model test to account for removed schema column
ashtn May 10, 2017
6de94ed
adjusted movies and customers controller to account for removed schem…
ashtn May 10, 2017
e03bf9d
added 3 rental routes
ashtn May 10, 2017
72a11e8
added rental model
ashtn May 10, 2017
8a1a9d3
added a column i forgot whoooops!
ashtn May 10, 2017
bd94fe3
added model tests for rental
ashtn May 10, 2017
cdaea5c
added available_inventory to model + tests, and check_out method rent…
ashtn May 10, 2017
d9aa2b2
added movie_checked_out_count model method + test
ashtn May 10, 2017
e709142
added test for find rentals by customer_id
ashtn May 10, 2017
240d59f
added custom methods to json output in controller
ashtn May 10, 2017
a67b6dc
created check out action method plus tests
ashtn May 12, 2017
7329c24
wrote check_in method
add2point71dots May 12, 2017
d68879d
tests for check_in for rentals controller
add2point71dots May 12, 2017
9f453b5
added over model method plus tests
ashtn May 12, 2017
9a2718f
deleted a space
add2point71dots May 12, 2017
508be02
re-added tests that got lost on github somehow
add2point71dots May 12, 2017
19a5327
added overdue controller method in rentals controller
ashtn May 12, 2017
bacc496
changed name of movies_checked_out_method
add2point71dots May 12, 2017
f379347
removed pseudo code
ashtn May 12, 2017
4a82001
added overdue rental controller tests
ashtn May 12, 2017
733923e
minor tweak to overdue edge case
ashtn May 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore Byebug command history file.
.byebug_history

# Ignore coverage
/coverage/

# Ignore .env file
.env
67 changes: 67 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
source 'https://rubygems.org'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end

group :development do
gem 'listen', '~> 3.0.5'
# 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 do
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry-rails'
gem 'rails-erd'
end

group :test do
gem 'minitest-rails'
gem 'minitest-reporters'
gem 'simplecov'
end

group :development, :test do
gem 'minitest-vcr'
gem 'webmock'
gem 'dotenv-rails'
end

gem 'awesome_print'
gem 'omniauth'
gem 'omniauth-github'
gem 'omniauth-google-oauth2'
gem 'foundation-rails'
gem 'httparty'
253 changes: 253 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.2)
actionpack (= 5.0.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.2)
actionview (= 5.0.2)
activesupport (= 5.0.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.2)
activesupport (= 5.0.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.2)
activesupport (= 5.0.2)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
arel (~> 7.0)
activesupport (5.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
ansi (1.5.0)
arel (7.1.4)
awesome_print (1.7.0)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.3)
byebug (9.0.6)
choice (0.2.0)
coderay (1.1.1)
concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.3)
docile (1.1.5)
dotenv (2.2.1)
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
erubis (2.7.0)
execjs (2.7.0)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
foundation-rails (6.3.1.0)
railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5)
sprockets-es6 (>= 0.9.0)
globalid (0.4.0)
activesupport (>= 4.2.0)
hashdiff (0.3.4)
hashie (3.5.5)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.8.1)
json (2.0.2)
jwt (1.5.6)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.5)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minispec-metadata (2.0.0)
minitest
minitest (5.10.1)
minitest-rails (3.0.0)
minitest (~> 5.8)
railties (~> 5.0)
minitest-reporters (1.1.14)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
minitest-vcr (1.4.0)
minispec-metadata (~> 2.0)
minitest (>= 4.7.5)
vcr (>= 2.9)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.0.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-github (1.2.3)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
omniauth-google-oauth2 (0.4.1)
jwt (~> 1.5.2)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.3.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
pg (0.20.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (2.0.5)
puma (3.8.2)
rack (2.0.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.2)
actioncable (= 5.0.2)
actionmailer (= 5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
activemodel (= 5.0.2)
activerecord (= 5.0.2)
activesupport (= 5.0.2)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
rails-erd (1.5.0)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
ruby-graphviz (1.2.3)
ruby-progressbar (1.8.1)
safe_yaml (1.0.4)
sass (3.4.23)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
spring (2.0.1)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-es6 (0.9.2)
babel-source (>= 5.8.11)
babel-transpiler
sprockets (>= 3.0.0)
sprockets-rails (3.2.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.4)
thread_safe (0.3.6)
tzinfo (1.2.3)
thread_safe (~> 0.1)
vcr (3.0.3)
webmock (3.0.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)

PLATFORMS
ruby

DEPENDENCIES
awesome_print
better_errors
binding_of_caller
byebug
dotenv-rails
foundation-rails
httparty
listen (~> 3.0.5)
minitest-rails
minitest-reporters
minitest-vcr
omniauth
omniauth-github
omniauth-google-oauth2
pg (~> 0.18)
pry-rails
puma (~> 3.0)
rails (~> 5.0.2)
rails-erd
simplecov
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
webmock

BUNDLED WITH
1.14.6
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::API
end
Empty file added app/controllers/concerns/.keep
Empty file.
6 changes: 6 additions & 0 deletions app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CustomersController < ApplicationController
def index
customers = Customer.all
render json: customers.as_json(only: [:id, :name, :registered_at, :postal_code, :phone], methods: :movies_checked_out_count ), status: :ok
end
end
15 changes: 15 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MoviesController < ApplicationController
def index
movies = Movie.all
render json: movies.as_json(only: [:title, :release_date]), status: :ok
end

def show
movie = Movie.find_by(title: params[:title])
if movie
render json: movie.as_json(only: [:inventory, :overview, :release_date, :title], methods: :available_inventory), status: :ok
else
render json: { errors: { "title": ["Movie '#{params[:title]}' not found"] } }, status: :not_found
end
end
end
Loading