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

Aruna && Monalisa #7

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
90eb69d
Intial set up
MonalisaC May 7, 2018
8ca9539
created movie model
aruna79 May 7, 2018
60708c8
created models
aruna79 May 7, 2018
855dace
Add controllers
MonalisaC May 7, 2018
604e3df
Add routes
MonalisaC May 7, 2018
f8ac74d
adding tests for models
aruna79 May 7, 2018
3bc954b
add validations
MonalisaC May 7, 2018
6fa399b
merge
MonalisaC May 7, 2018
083604d
added customer model tests
aruna79 May 7, 2018
44d02e9
some test
MonalisaC May 7, 2018
23f9b2f
Merge branch 'master' of https://github.com/aruna79/VideoStoreAPI
MonalisaC May 7, 2018
f8c4eec
schema error
MonalisaC May 7, 2018
388bf3d
Add test for movie model
MonalisaC May 7, 2018
f27dd84
customer model tests passing
aruna79 May 7, 2018
d4ebaa0
Merge branch 'master' of https://github.com/aruna79/VideoStoreAPI
aruna79 May 7, 2018
8ee1a00
Add rental model test
MonalisaC May 7, 2018
7877cff
Merge branch 'master' of https://github.com/aruna79/VideoStoreAPI
aruna79 May 7, 2018
ea1454d
added customer index method for controller
aruna79 May 8, 2018
b101950
added methods to model controller
aruna79 May 8, 2018
a35bf24
added customer controller test
aruna79 May 8, 2018
440d350
added movie controller tests
aruna79 May 8, 2018
225ed4f
tests passing for movie controller
aruna79 May 8, 2018
a8b3835
fixed error in movie controller
aruna79 May 8, 2018
737df1c
fixed typo
MonalisaC May 8, 2018
20e80e5
added rental controller
aruna79 May 8, 2018
21c72ff
Merge branch 'master' of https://github.com/aruna79/VideoStoreAPI
aruna79 May 8, 2018
9836438
fixed error in movie test
aruna79 May 8, 2018
0a361f1
add routes
MonalisaC May 9, 2018
b9eb68a
change method logic
MonalisaC May 9, 2018
a475d48
Changed fixtures
MonalisaC May 9, 2018
dc73a4f
Add tests
MonalisaC May 9, 2018
16226a4
wrote methods
MonalisaC May 9, 2018
f00ba73
fix failure
MonalisaC May 9, 2018
0c336cd
add erd
MonalisaC 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
2 changes: 2 additions & 0 deletions app/models/rental.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Rental < ApplicationRecord
belongs_to :customer
belongs_to :movie
validates :checkout_date, presence: true
validates :due_date, presence: true
end
52 changes: 50 additions & 2 deletions test/models/rental_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,56 @@

describe Rental do
let(:rental) { Rental.new }
let(:rental1) { rentals(:one) }

it "must be valid" do
value(rental).must_be :valid?
describe "relations" do
it "has a customer" do
rental1.must_respond_to :customer
rental1.customer.must_be_kind_of Customer
rental1.customer.must_equal customers(:mary)
end
it "has a movie" do
rental1.must_respond_to :movie
rental1.movie.must_be_kind_of Movie
rental1.movie.must_equal movies(:one)
end

it "changes in customer_id and movie_id reflects in customer and movie" do
rental1.customer_id = customers(:sally).id
rental1.customer.must_equal customers(:sally)

rental1.movie_id = movies(:two).id
rental1.movie.must_equal movies(:two)
end
end

describe "validations" do
it "has validation for empty parameters" do
rental.valid?.must_equal false
end

it "has validation for due_date presence" do
rental1.due_date = nil
rental1.valid?.must_equal false
rental1.errors.messages.must_include :due_date

rental1.due_date = ""
rental1.valid?.must_equal false
rental1.errors.messages.must_include :due_date
end

it "has validation for checkout_date presence" do
rental1.checkout_date = nil
rental1.valid?.must_equal false
rental1.errors.messages.must_include :checkout_date

rental1.checkout_date = ""
rental1.valid?.must_equal false
rental1.errors.messages.must_include :checkout_date
end

it "must be valid" do
rental1.valid?.must_equal true
end
end
end