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

Tor & Wenjie - VideoStore - Octos #6

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e98095
ran rails new
torshimizu May 7, 2018
eeaef79
created models customer, movie, rental
torshimizu May 7, 2018
decf6bf
fixed table columns and ran db:seed
torshimizu May 7, 2018
64eaa54
wrote movie model validations
torshimizu May 7, 2018
58e6130
Added model validations
wf1101 May 7, 2018
a5e5d0d
Merge branch 'master' of https://github.com/torshimizu/VideoStoreAPI
torshimizu May 7, 2018
1c94d5e
created tests and controller for customers
torshimizu May 7, 2018
c5c92d8
Created yml for customers and movies
wf1101 May 7, 2018
1e48b75
Added movies controller actions
wf1101 May 7, 2018
48c4e6e
added a positive case for movie model
torshimizu May 7, 2018
16673a1
Added relations to models
wf1101 May 7, 2018
859da32
Implemented tests for model relations
wf1101 May 7, 2018
5e90218
Added yml for rentals
wf1101 May 7, 2018
1c0519d
wrote tests for rentals_controller, added conditional validations for…
torshimizu May 7, 2018
340a3a0
Added a checkout action in rental controller
wf1101 May 8, 2018
6df4de1
Added available inventory column to movies and movies checkout count …
wf1101 May 8, 2018
08f4df0
updated inventory to available inventory. removed required :movie fro…
torshimizu May 8, 2018
d8c34f9
Added business logic to rental model
wf1101 May 8, 2018
2c228ea
Added check out action for rentals controller
wf1101 May 8, 2018
2f1a355
Implemented tests for rentals check in
wf1101 May 8, 2018
562ef6a
Fixed validation bug and made all tests passed
torshimizu May 8, 2018
5cc36de
Added ERD for this project
wf1101 May 8, 2018
658a45e
moving updating rental movie and customer inventory to rental model
torshimizu May 9, 2018
d09a9ad
moved updating customer movies_checked_in_count and movie available i…
torshimizu May 9, 2018
08ecc76
Merge branch 'master' of https://github.com/torshimizu/VideoStoreAPI
torshimizu May 9, 2018
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
Prev Previous commit
Next Next commit
Added check out action for rentals controller
  • Loading branch information
wf1101 committed May 8, 2018
commit 2c228ead045049973f4554370fffbd0733eec83e
18 changes: 13 additions & 5 deletions app/controllers/rentals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ def check_out
movie.update(available_inventory: new_inventory)
render json: rental.as_json(except: [:updated_at], status: :ok)
else
render json: {
errors: rental.errors.messages
}, status: :bad_request
render json: { errors: rental.errors.messages}, status: :bad_request
end
end

def check_in

rental = Rental.find_checked_out_movie(params[:movie_id], params[:customer_id])
if rental
rental.update(check_in_date: Date.today)
render json: rental.as_json(except: [:updated_at], status: :ok)
else
render json: {
errors: {
rental: ["No rental found"]
}
}
end

end

Expand All @@ -25,6 +33,6 @@ def check_in
private

def rental_params
params.require(:rental).permit(:movie_id, :customer_id)
params.permit(:movie_id, :customer_id)
end
end