Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e69aa63
created a rails app api
annaewolf May 9, 2017
43317ac
pseudocoded routes
annaewolf May 9, 2017
60c3768
added ZOMG route
annaewolf May 9, 2017
b6dc894
created models and migrations
J-C-L May 9, 2017
f27628f
added relationships to models
J-C-L May 9, 2017
2256df2
added validation to rental model
J-C-L May 9, 2017
9a6235b
created customers controller
J-C-L May 9, 2017
eef84ab
added controller index method and tests
annaewolf May 9, 2017
95a57de
wrote movies index action and associated tests
J-C-L May 9, 2017
5d21bec
resolved conflict
J-C-L May 9, 2017
cf9d43e
added fixtures
annaewolf May 9, 2017
b1671b2
gave fixtures titles
annaewolf May 9, 2017
7ae6318
fixed fixture
annaewolf May 9, 2017
1786d2b
created rental yml entries
J-C-L May 9, 2017
9b7b69c
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
J-C-L May 9, 2017
da83423
wrote tests for movie model relationships
J-C-L May 9, 2017
8d94482
wrote customer model tests
annaewolf May 9, 2017
70abd0e
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
annaewolf May 9, 2017
16e1fcf
created tests for rental model validations and relationships
J-C-L May 10, 2017
3d4832c
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
J-C-L May 10, 2017
9a47d9f
added serializer
annaewolf May 10, 2017
224eac7
wrote show method to find movie by title
J-C-L May 10, 2017
12b776f
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
J-C-L May 10, 2017
e022251
resolved comflict
J-C-L May 10, 2017
2678d78
updates movies yml file
J-C-L May 10, 2017
918b38a
updated show method now that serializer is in effect
J-C-L May 10, 2017
3044a62
added capitalize to params
annaewolf May 10, 2017
136b82e
added create method for rental
annaewolf May 10, 2017
4c0f9c5
wrote checkin method for checking in rentals
J-C-L May 10, 2017
c8a1583
added model method
annaewolf May 10, 2017
a42abfb
just pulled
J-C-L May 10, 2017
54b8ef8
added tests
annaewolf May 10, 2017
f6e3e9a
wrote overdue method in rentals model and controller
J-C-L May 10, 2017
754abee
wrote test for checked_out customer model method
J-C-L May 10, 2017
bc72951
added fields
annaewolf May 10, 2017
72ab758
wrote test for overdue method in rental model
J-C-L May 10, 2017
baccf0b
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
annaewolf May 11, 2017
cb1193a
added rental serializer
annaewolf May 11, 2017
73c898c
started tests for checkin method
J-C-L May 11, 2017
7ce5ae7
wrote tests
annaewolf May 11, 2017
c00e435
merged
annaewolf May 11, 2017
fddce8f
added simplecov
J-C-L May 12, 2017
b4d58a0
finished testing checkin method and corrected movies show method, so …
J-C-L May 12, 2017
e1092bf
wrote tests for overdue method in rentals controller
J-C-L May 12, 2017
eb8b10a
simplecov is 100%
J-C-L May 12, 2017
9a4fa30
fixed a name for a smoke test
annaewolf May 12, 2017
5d25740
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
annaewolf May 12, 2017
15f4a57
changed tests to match new method name, movies_checked_out_count
J-C-L May 12, 2017
99fd997
added sort params
annaewolf May 12, 2017
b29a41a
changed tests + route so that smoke tests pass
annaewolf May 12, 2017
0c1ace8
...
J-C-L May 12, 2017
3225eba
added 2 rentals in seeds
J-C-L May 12, 2017
e930b0f
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
J-C-L May 12, 2017
1b2bdc7
added sort method to movies controller
annaewolf May 12, 2017
b9d6606
Merge branch 'master' of https://github.com/J-C-L/VideoStoreAPI
annaewolf May 12, 2017
317b2be
changed rental seeds to not conflict with smoke tests
J-C-L May 12, 2017
a905872
wrote method to sort overdue rentals by diff characteristics
J-C-L May 12, 2017
1f94ac5
added rentals tests
annaewolf May 12, 2017
0a98009
merged
annaewolf May 12, 2017
7d14d60
finished tests
annaewolf May 12, 2017
ebd197a
added pagination to customers index
J-C-L May 12, 2017
5f34074
fixed sorted overdue methods and tests
J-C-L 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
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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
57 changes: 57 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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 'active_model_serializers', '~> 0.10.0'
gem 'will_paginate', '~> 3.1.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
gem 'simplecov'
# 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'
end

gem 'awesome_print'
gem 'foundation-rails'
group :test do
gem 'minitest-rails'
gem 'minitest-reporters'
end
198 changes: 198 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
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)
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)
case_transform (0.2)
activesupport
coderay (1.1.1)
concurrent-ruby (1.0.5)
debug_inspector (0.0.3)
docile (1.1.5)
erubis (2.7.0)
execjs (2.7.0)
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)
i18n (0.8.1)
json (2.0.2)
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.1)
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)
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)
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)
awesome_print
better_errors
binding_of_caller
byebug
foundation-rails
listen (~> 3.0.5)
minitest-rails
minitest-reporters
pg (~> 0.18)
pry-rails
puma (~> 3.0)
rails (~> 5.0.2)
simplecov
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
will_paginate (~> 3.1.0)

BUNDLED WITH
1.14.6
11 changes: 8 additions & 3 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

Expand Down Expand Up @@ -273,8 +279,7 @@ Fields to return:
- `title`
- `checkout_date`
- `due_date`


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

def index
customers = Customer.all
if customers.length > 0
if params[:sort] == "name" || params[:sort] == "registered_at" || params[:sort] == "postal_code"

customers = customers.order(params[:sort].to_sym)
end
if (params[:n] && params[:p])
#Assuming a pagination request comes with BOTH a value for p and n
customers = customers.paginate(:page => params[:p], :per_page => params[:n])
end
render :json => customers, status: :ok
else
render :json => {no_customers: "There are no customers in the database"}, status: :not_found
end
end

end
31 changes: 31 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class MoviesController < ApplicationController

# def zomg
# render :json => { just_for_dan: "it works!" }, status: :ok
# end

def index
movies = Movie.all
if movies.length > 0
if params[:sort] == "title" || params[:sort] == "release_date"
sorted_movies = Movie.order(params[:sort].to_sym)
render :json => sorted_movies, status: :ok
else
render json: movies, fields: [:title, :release_date], status: :ok
end
else
render json: {error: "We have no movies at this time"}, status: 404
end
end


def show
movie = Movie.find_by(title: params[:title])
if movie
render :json => movie, status: :ok
else
render status: :not_found, json: { error: "Could not find a movie with the title #{params[:title]}"}
end
end

end
Loading