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 e63af574
authored
Oct 18, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/haches/sequelize
into haches-master
2 parents
3cc67019
943427c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
test/associations/has-many.test.js
test/associations/has-many.test.js
View file @
e63af57
...
...
@@ -2080,6 +2080,42 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
expect
(
Group
.
associations
.
MyUsers
.
through
.
model
.
rawAttributes
.
GroupId
).
to
.
exist
;
});
});
describe
(
'multiple hasMany'
,
function
()
{
beforeEach
(
function
()
{
this
.
User
=
this
.
sequelize
.
define
(
'user'
,
{
name
:
Sequelize
.
STRING
});
this
.
Project
=
this
.
sequelize
.
define
(
'project'
,
{
projectName
:
Sequelize
.
STRING
});
});
describe
(
'project has owners and users and owners and users have projects'
,
function
()
{
beforeEach
(
function
()
{
this
.
Project
.
hasMany
(
this
.
User
,
{
as
:
'owners'
,
through
:
'projectOwners'
});
this
.
Project
.
hasMany
(
this
.
User
,
{
as
:
'users'
,
through
:
'projectUsers'
});
this
.
User
.
hasMany
(
this
.
Project
,
{
as
:
'owners'
,
through
:
'projectOwners'
});
this
.
User
.
hasMany
(
this
.
User
,
{
as
:
'users'
,
through
:
'projectUsers'
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
it
(
'correctly sets user and owner'
,
function
()
{
var
self
=
this
;
var
p1
=
this
.
Project
.
build
({
projectName
:
'p1'
})
,
u1
=
this
.
User
.
build
({
name
:
'u1'
})
,
u2
=
this
.
User
.
build
({
name
:
'u2'
});
return
p1
.
save
()
.
then
(
function
()
{
return
u1
.
save
();
})
.
then
(
function
()
{
return
u2
.
save
();
})
.
then
(
function
()
{
return
p1
.
setUsers
([
u1
]);
})
.
then
(
function
()
{
return
p1
.
setOwners
([
u2
]);
});
});
});
});
});
describe
(
"Foreign key constraints"
,
function
()
{
...
...
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