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

Breeann branch #3

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5011b32
actor tests working
brammerl Jun 25, 2020
81cf0e6
adding what I have so far for get id
breeannb Jun 25, 2020
3813497
merging lucias work into my branch
breeannb Jun 26, 2020
2fb9461
updates to studio tests
brammerl Jun 26, 2020
36d3676
fixed the studio get film route, its all good
breeannb Jun 26, 2020
e98305e
updated readme with our todos
breeannb Jun 26, 2020
0707818
saving what I have so far as I got my routes to finally generate some…
breeannb Jun 26, 2020
ccba332
readme
breeannb Jun 26, 2020
43ef6f5
removing the route that we completed for films
breeannb Jun 26, 2020
ec71923
film get all test and route
brammerl Jun 26, 2020
f082600
Merge branch 'lucia' of https://github.com/brammerl/ripe-banana into …
breeannb Jun 26, 2020
1d3bcad
reviewer tests and routes
brammerl Jun 26, 2020
42462f1
Merge branch 'lucia' of https://github.com/brammerl/ripe-banana into …
breeannb Jun 26, 2020
da2b593
saving what I have
breeannb Jun 26, 2020
d8d63ba
studio post route and test
brammerl Jun 26, 2020
ea9601a
saving what we worked through so far but having failing tests still
breeannb Jun 26, 2020
5ba9d82
adding reviewers tests not working
brammerl Jun 26, 2020
8fc7c51
saving so Lucia has all of this code
breeannb Jun 26, 2020
aee76e6
Merge branch 'lucia' of https://github.com/brammerl/ripe-banana into …
breeannb Jun 26, 2020
f9df4db
reviewers test and function
brammerl Jun 29, 2020
2b2841d
Merge branch 'lucia' of https://github.com/brammerl/ripe-banana into …
breeannb Jun 29, 2020
7fa4bfe
adding lucias passing test
breeannb Jun 29, 2020
5200016
reviewer post test and route
brammerl Jun 29, 2020
b8cdacf
pushing up what we have so far
breeannb Jun 29, 2020
a4086ff
Merge branch 'breeann-branch' of https://github.com/brammerl/ripe-ban…
brammerl Jun 29, 2020
49400b7
agh film
brammerl Jun 29, 2020
6bf4d7e
finished film by id test to pass
breeannb Jun 29, 2020
8ab1dae
fixing actor test and routes
brammerl Jun 29, 2020
1ac0fb7
reviews post route and test
brammerl Jun 29, 2020
f6e0811
reviewer patch route and test
brammerl Jun 29, 2020
81db25a
finished the post route for film
breeannb Jun 29, 2020
8671174
delete route for reviews and test
brammerl Jun 29, 2020
6234ddd
making sure I saved all work
breeannb Jun 29, 2020
4fcab27
Merge pull request #4 from brammerl/lucia
brammerl Jun 29, 2020
9b1ba9e
Merge branch 'lucia' of https://github.com/brammerl/ripe-banana into …
breeannb Jun 30, 2020
5594d8e
adding the delete test that i have
breeannb Jun 30, 2020
3d53c2f
adding reviewcheckanddelet function
brammerl Jun 30, 2020
2e4b3e8
Merge branch 'breeann-branch' of https://github.com/brammerl/ripe-ban…
breeannb Jun 30, 2020
10d7752
adding what I have
breeannb Jun 30, 2020
2d008f3
adding reviewer test/routes
brammerl Jun 30, 2020
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
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# ripe-banana
# ripe-banana

# To-dos:

## GET Routes

While the schemas should look like the data definitions above, these are descriptions of the data that should be returned from the various `GET` methods. You will need to use `lean`, `populate`, `select` and combining data to shape the appropriate response.

1. #### DELETE

1. Reviewers cannot be deleted if there are reviews
73 changes: 70 additions & 3 deletions __tests__/actor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const connect = require('../lib/utils/connect');
const request = require('supertest');
const app = require('../lib/app');
const Actor = require('../lib/models/Actor');
const Film = require('../lib/models/Film');
const Studio = require('../lib/models/Studio');


describe('actor routes', () => {
beforeAll(async() => {
Expand Down Expand Up @@ -35,17 +38,81 @@ describe('actor routes', () => {
_id: expect.anything(),
name: 'actor name',
dob: expect.anything(),
pob: 'Oakland, CA',
__v: 0
pob: 'Oakland, CA'
});
});
});

it('gets all actors via GET', async() => {
await Actor.create({
await Actor.create([{
name: 'actor name',
dob: Date(),
pob: 'Oakland, CA'
}, {
name: 'actor name 2',
dob: Date(),
pob: 'Portland, OR '
}]);

return request(app)
.get('/api/v1/actors/')
.then(res => {
expect(res.body).toEqual([
{
_id: expect.anything(),
name: 'actor name',
dob: expect.anything(),
pob: 'Oakland, CA',
}, {
_id: expect.anything(),
name: 'actor name 2',
dob: expect.anything(),
pob: 'Portland, OR ',
}
]);
});
});

it('gets actors by id via GET', async() => {
const actor = await Actor.create({
name: 'actor name',
dob: Date(),
pob: 'Oakland, CA'
});

const studio = await Studio.create({
name: 'Portland Studio',
address: {
city: 'Portland',
state: 'Oregon',
country: 'US'
}
});

const film = await Film.create({
title: 'Film Title',
studio: studio._id,
released: 2020,
cast: [{
role: 'Lead',
actor: actor._id
}]
});

return request(app)
.get(`/api/v1/actors/${actor._id}`)
.then(res => {
expect(res.body).toEqual({
__v: 0,
_id: expect.anything(),
name: 'actor name',
dob: expect.anything(),
pob: 'Oakland, CA',
films: [{
title: film.title,
released: film.released
}]
});
});
});
});
207 changes: 207 additions & 0 deletions __tests__/film.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
const { MongoMemoryServer } = require('mongodb-memory-server');
const mongod = new MongoMemoryServer();
const mongoose = require('mongoose');
const connect = require('../lib/utils/connect');

const request = require('supertest');
const app = require('../lib/app');
const Studio = require('../lib/models/Studio');
const Film = require('../lib/models/Film');
const Actor = require('../lib/models/Actor');
const Review = require('../lib/models/Review');
const Reviewer = require('../lib/models/Reviewer');


describe('film routes', () => {

beforeAll(async() => {
const uri = await mongod.getUri();
return connect(uri);
});

beforeEach(() => {
return mongoose.connection.dropDatabase();
});

afterAll(async() => {
await mongoose.connection.close();
return mongod.stop();
});

it('gets all studios via GET', async() => {
const actor = await Actor.create({
name: 'actor name',
dob: Date(),
pob: 'Oakland, CA'
});

const studio = await Studio.create({
name: 'Portland Studio',
address: {
city: 'Portland',
state: 'Oregon',
country: 'US'
}
});

await Film.create({
title: 'My Own Private Idaho',
studio: {
_id: studio.id,
name: studio.name,
},
released: 1991,
cast: [{
role: 'Scott Favor',
actor: actor._id
}]
});

return request(app)
.get('/api/v1/films')
.then(res => {
expect(res.body).toEqual([{
_id: expect.anything(),
title: 'My Own Private Idaho',
released: 1991,
cast: [{
_id: expect.anything(),
role: 'Scott Favor',
actor: actor.id
}],
studio: {
_id: studio.id,
name: studio.name,
}
}
]);
});
});

it('gets films by id via GET', async() => {
const actor = await Actor.create({
name: 'actor name',
dob: Date(),
pob: 'Oakland, CA'
});

const studio = await Studio.create({
name: 'Portland Studio',
address: {
city: 'Portland',
state: 'Oregon',
country: 'US'
}
});

const film = await Film.create({
title: 'My Own Private Idaho',
studio: {
_id: studio.id,
name: studio.name,
},
released: 1991,
cast: [{
role: 'Scott Favor',
actor: actor._id
}]
});

const reviewer = await Reviewer.create({
name: 'Breeann B',
company: 'Alchemy'
});

const review = await Review.create({
rating: 1,
reviewer: reviewer._id,
review: 'The worst movie everrrr',
film: film._id
});

return request(app)
.get(`/api/v1/films/${film._id}`)
.then(res => {
expect(res.body).toEqual({
_id: expect.anything(),
title: 'My Own Private Idaho',
studio: {
_id: expect.anything(),
name: 'Portland Studio',
},
released: 1991,
cast: [{
_id: expect.anything(),
role: 'Scott Favor',
actor: {
_id: expect.anything(),
name: 'actor name'
}
}],
reviews: [{
_id: expect.anything(),
rating: review.rating,
reviewer: {
_id: expect.anything(),
name: 'Breeann B'
},
review: 'The worst movie everrrr'
}],
__v: 0
});
});
});

it('creates an film via POST', async() => {

const studio = await Studio.create({
name: 'Portland Studio',
address: {
city: 'Portland',
state: 'Oregon',
country: 'US'
}
});

const actor = await Actor.create({
name: 'actor name',
dob: Date(),
pob: 'Oakland, CA'
});

const film = await Film.create({
title: 'My Own Private Idaho',
studio: {
_id: studio.id,
name: studio.name,
},
released: 1991,
cast: [{
role: 'Scott Favor',
actor: actor._id
}]
});

return request(app)
.post('/api/v1/films')
.send({
title: 'My Own Private Idaho',
studio: studio._id,
released: 1992,
cast: film.cast
})
.then(res => {
expect(res.body).toEqual({
_id: expect.anything(),
title: 'My Own Private Idaho',
studio: expect.anything(),
released: 1992,
cast: [{
_id: expect.anything(),
role: 'Scott Favor',
actor: actor._id.toString()
}]
});
});
});
});
Loading