Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2da3c05
rails setup including models/migrations
EricaJCasePhD May 9, 2017
afe7630
updated migrations to have :credit_account
EricaJCasePhD May 9, 2017
c2bc689
added controllers
EricaJCasePhD May 9, 2017
c9c8281
movie model test
EricaJCasePhD May 9, 2017
73909b8
customer model tests and rental model tests done
ricecakemonster May 9, 2017
44ef090
merged
ricecakemonster May 9, 2017
8f90de0
merging again
ricecakemonster May 10, 2017
63d57e2
Update README.md
ricecakemonster May 10, 2017
10d2be5
added routes
EricaJCasePhD May 10, 2017
2b56272
Merge branch 'master' of https://github.com/ricecakemonster/VideoStor…
EricaJCasePhD May 10, 2017
a5e0398
mid-progress commit to pull Hyunji's work
EricaJCasePhD May 10, 2017
7cb0e44
Merge branch 'master' of https://github.com/ricecakemonster/VideoStor…
EricaJCasePhD May 10, 2017
3a33a7c
synced with Hyunji to get serializer setup
EricaJCasePhD May 10, 2017
747dd27
added Serializer
ricecakemonster May 10, 2017
ee28760
movie controller tests done except error handling
EricaJCasePhD May 10, 2017
4c4ec99
customer contoller methods added. adding a column(returned) for renta…
ricecakemonster May 10, 2017
357e421
merged
ricecakemonster May 10, 2017
8ece387
Rental.checkout controller works well
ricecakemonster May 10, 2017
64b82be
securing version in remote
EricaJCasePhD May 10, 2017
ddf59f7
customer movies_checked_out_count
ricecakemonster May 10, 2017
4d1f3b5
error handling added for movies controller
EricaJCasePhD May 11, 2017
76714c5
merging
ricecakemonster May 11, 2017
28ebf25
merging
ricecakemonster May 11, 2017
7e0bb26
added checkout(that was lost somehow)
ricecakemonster May 11, 2017
3ee993e
added overdue date to Customers
ricecakemonster May 11, 2017
f4fc68f
fixed overdue and added error messages
ricecakemonster May 12, 2017
c19f070
added available inventory
EricaJCasePhD May 12, 2017
fe407e8
customer controller tests done. over_due method fixed
ricecakemonster May 12, 2017
0849cd7
merging
ricecakemonster May 12, 2017
11b7ba8
created rentals controller.
ricecakemonster May 13, 2017
e6805bb
Erica's final work
EricaJCasePhD May 14, 2017
8bfb651
fixed merge conflicts
EricaJCasePhD May 14, 2017
988f4f5
try to Dry the code
ricecakemonster May 14, 2017
e21e586
paginate working
ricecakemonster May 14, 2017
17d8add
paginate working for customers, rentals, and movies lists
ricecakemonster May 14, 2017
5e59ae5
merging
ricecakemonster May 14, 2017
c90a5d3
Merge branch 'master' of https://github.com/ricecakemonster/VideoStor…
ricecakemonster May 14, 2017
1efb061
added tests; checkout not working?
EricaJCasePhD May 14, 2017
e8bad1a
rental model tests added
ricecakemonster May 14, 2017
9be85a7
merged
ricecakemonster May 14, 2017
d2ae71c
rental tests done.
ricecakemonster May 15, 2017
23e7427
fixed checkin updating when one customer has checked out many copies …
ricecakemonster May 15, 2017
b957d36
added zomg
ricecakemonster May 15, 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
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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
.DS_Store
55 changes: 55 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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'

gem 'will_paginate', '~> 3.1.0'

gem 'active_model_serializers', '~> 0.10.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 'pry-rails'
end

group :test do
gem 'minitest-rails'
gem 'minitest-reporters'
end
169 changes: 169 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
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)
active_model_serializers (0.10.6)
actionpack (>= 4.1, < 6)
activemodel (>= 4.1, < 6)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.2)
activejob (5.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)
ansi (1.5.0)
arel (7.1.4)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
builder (3.2.3)
byebug (9.0.6)
case_transform (0.2)
activesupport
coderay (1.1.1)
concurrent-ruby (1.0.5)
erubis (2.7.0)
ffi (1.9.18)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.1)
jsonapi-renderer (0.1.2)
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)
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
nio4r (2.0.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
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)
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-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-progressbar (1.8.1)
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-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)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.1.5)

PLATFORMS
ruby

DEPENDENCIES
active_model_serializers (~> 0.10.0)
better_errors
byebug
listen (~> 3.0.5)
minitest-rails
minitest-reporters
pg (~> 0.18)
pry-rails
puma (~> 3.0)
rails (~> 5.0.2)
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
will_paginate (~> 3.1.0)

BUNDLED WITH
1.14.6
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ The smoke tests live in the file [`test/VideoStoreAPI_smoke_tests.postman_collec
1. Click `Import` in the top left
1. Drag-and-drop the file into the box
1. In the left sidebar, click on the `Collections` tab
1. There should now be an entry for the smoke tests. Hover over it and click the `>` icon for a detail view.
1. There should now be an entry for the smoke tests. Hover over it and click the `>` icon for a detail view. You will notice they are in the format `{{url}}/movies`. `{{url}}` is a key which you can give a value on your computer.
1. To do so go to the Gearbox in the top-right and select `Manage Environments`
![Manage Environments](images/manage-environment.png)
1. Then Select `Add`
![add button](images/add-btn.png)
1. Lastly add a key `url` and value `http://localhost:3000`
![Key & Value](images/key-value.png)
1. Click the blue `Run` button. This will launch the collection runner.
1. In the collection runner, scroll down in the center pane and click the blue `Start Test` button

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐️ for including a README! Documentation - especially good documentation - is so often overlooked and is super useful!

Expand Down Expand Up @@ -277,4 +283,4 @@ Fields to return:

# Reference
- [Postman on Environments](https://www.getpostman.com/docs/environments)


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.
53 changes: 53 additions & 0 deletions app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class CustomersController < ApplicationController
def index

sort_list = ["name", "postal_code", "registered_at"]
if sort_list.include?(params[:sort])
customers = Customer.paginate(page: params[:p], per_page: params[:n]).order(params[:sort])
else
customers = Customer.paginate(page: params[:p], per_page: params[:n])
end

if customers != []
render json: customers, status: :ok
else
render json: {errors: "There are No Customers"}, status: :not_found
end

end

end





# def overdue <=== If you want to return the customer with multiple overdue movies once.
# rentals = Rental.where(returned_date: nil)
# overdue_rentals = []
# rentals.each do |rental|
# overdue_rentals << rental if rental.due_date < Time.now
# end
#
# customers = []
# if overdue_rentals.nil?
# render json: {errors: "No Overdue Rentals"}, status: :not_found
# else
# overdue_rentals.each do |overdue|
# customer = Customer.find_by(id: overdue.customer_id)
# unless customers.include?(customer)
# customers << customer
# end
# end
# end
#
# if customers == []
# render json: {errors: "No Customers with Overdue Movies"}, status: :not_found
# else
# sort_list = ["overdue_title", "name", "checkout_date", "due_date"]
# if sort_list.include?(params[:sort])
# customers = customers.sort_by{|customer| customer[params[:sort]]}
# end
# render json: customers, status: :ok, each_serializer: OverdueSerializer
# end
# end
Loading