Skip to content

Commit

Permalink
Fix(typo) in dailyRentalRate
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhannedNoman committed Oct 7, 2020
1 parent 774e42b commit a71750b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions models/movie.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const Movie = mongoose.model(
},
genre: { type: genreSchema, required: true },
numberInStock: { type: Number, required: true, min: 0, max: 255 },
dailyRenalRate: { type: Number, min: 0, max: 255, required: true },
dailyRentalRate: { type: Number, min: 0, max: 255, required: true },
})
);

function validateMovie(movie) {
const schema = {
title: Joi.string().min(3).required(),
numberInStock: Joi.number().required().min(0),
dailyRenalRate: Joi.number().min(0).required(),
dailyRentalRate: Joi.number().min(0).required(),
genreId: Joi.objectId().required(),
};
return Joi.validate(movie, schema);
Expand Down
4 changes: 2 additions & 2 deletions models/rental.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const rentalSchema = new mongoose.Schema({
minlength: 5,
maxlength: 255,
},
dailyRenalRate: {
dailyRentalRate: {
type: Number,
required: true,
min: 0,
Expand Down Expand Up @@ -67,7 +67,7 @@ rentalSchema.methods.return = function () {
this.dateReturned = new Date();

const rentalDays = moment().diff(this.dateOut, 'days');
this.rentalFee = rentalDays * this.movie.dailyRenalRate;
this.rentalFee = rentalDays * this.movie.dailyRentalRate;
};

const Rental = mongoose.model('Rental', rentalSchema);
Expand Down
4 changes: 2 additions & 2 deletions routes/movies.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ router.post('/', auth, async (req, res) => {
name: genre.name,
},
numberInStock: req.body.numberInStock,
dailyRenalRate: req.body.dailyRenalRate,
dailyRentalRate: req.body.dailyRentalRate,
});

await movie.save();
Expand Down Expand Up @@ -72,7 +72,7 @@ router.put('/:id', auth, async (req, res) => {
name: genre.name,
},
numberInStock: req.body.numberInStock,
dailyRenalRate: req.body.dailyRenalRate,
dailyRentalRate: req.body.dailyRentalRate,
},
{
new: true,
Expand Down
4 changes: 2 additions & 2 deletions routes/rentals.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ router.post('/', auth, async (req, res) => {
movie: {
_id: movie._id,
title: movie.title,
dailyRenalRate: movie.dailyRenalRate,
dailyRentalRate: movie.dailyRentalRate,
},
});

Expand Down Expand Up @@ -107,7 +107,7 @@ router.put('/:id', auth, async (req, res) => {
movie: {
_id: movie._id,
title: movie.title,
dailyRenalRate: movie.dailyRenalRate,
dailyRentalRate: movie.dailyRentalRate,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/returns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('/api/returns', () => {
movie = new Movie({
_id: movieId,
title: '12345',
dailyRenalRate: 2,
dailyRentalRate: 2,
genre: { name: '12345' },
numberInStock: 10,
});
Expand All @@ -39,7 +39,7 @@ describe('/api/returns', () => {
movie: {
_id: movieId,
title: '12345',
dailyRenalRate: 2,
dailyRentalRate: 2,
},
});
await rental.save();
Expand Down

0 comments on commit a71750b

Please sign in to comment.