Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 71e94bff
authored
Dec 03, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(hasMany/include): add test by vpontis
1 parent
f121f76e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
28 deletions
test/associations/has-many.test.js
test/associations/has-many.test.js
View file @
71e94bf
...
@@ -1583,46 +1583,36 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -1583,46 +1583,36 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
});
});
it
(
'should correctly get associations even after a child instance is deleted'
,
function
()
{
it
(
'should correctly get associations even after a child instance is deleted'
,
function
()
{
var
self
=
this
,
var
self
=
this
user
,
projects
;
,
user
return
this
.
sequelize
.
sync
({
logging
:
console
.
log
}).
then
(
function
()
{
,
projects
;
return
Promise
.
all
([
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
join
(
self
.
User
.
create
({
name
:
'Matt'
}),
self
.
User
.
create
({
name
:
'Matt'
}),
self
.
Project
.
create
({
name
:
'Good Will Hunting'
}),
self
.
Project
.
create
({
name
:
'Good Will Hunting'
}),
self
.
Project
.
create
({
name
:
'The Departed'
})
self
.
Project
.
create
({
name
:
'The Departed'
})
]);
);
})
}).
spread
(
function
(
user
,
project1
,
project2
)
{
.
spread
(
function
(
user
,
project1
,
project2
)
{
return
user
.
addProjects
([
project1
,
project2
]).
return
(
user
);
return
user
.
addProjects
([
project1
,
project2
]).
return
(
user
);
})
}).
then
(
function
(
user
)
{
.
then
(
function
(
user
)
{
return
Promise
.
join
(
return
Promise
.
all
([
user
,
user
,
user
.
getProjects
()
user
.
getProjects
()
]);
);
})
}).
spread
(
function
(
user
,
projects
)
{
.
then
(
function
(
savedUser
,
savedProjects
)
{
var
user
=
savedUser
,
projects
=
savedProjects
;
return
Promise
.
all
([
self
.
sequelize
.
query
(
'alter table user_projects drop constraint user_projects_project_id_fkey;'
),
self
.
sequelize
.
query
(
'alter table user_projects drop constraint user_projects_user_id_fkey;'
)
])
})
.
spread
(
function
()
{
var
project
=
projects
[
0
];
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
defined
;
return
project
.
destroy
().
return
(
user
);
return
project
.
destroy
().
return
(
user
);
})
}).
then
(
function
(
user
)
{
.
then
(
function
(
user
)
{
return
self
.
User
.
find
({
return
self
.
User
.
find
({
where
:
{
id
:
user
.
id
},
where
:
{
id
:
user
.
id
},
include
:
self
.
Project
include
:
[{
model
:
self
.
Project
,
as
:
'Projects'
}]
});
});
})
}).
then
(
function
(
user
)
{
.
then
(
function
(
user
)
{
var
projects
=
user
.
Projects
var
projects
=
user
.
Projects
;
,
project
=
projects
[
0
]
;
var
project
=
projects
[
0
];
expect
(
project
).
to
.
be
.
defined
;
expect
(
project
).
to
.
be
.
defined
;
});
});
});
});
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment