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 0ce92678
authored
Mar 27, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests for reloading associations
1 parent
f178b9ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
spec/dao.spec.js
spec/dao.spec.js
View file @
0ce9267
...
@@ -216,7 +216,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
...
@@ -216,7 +216,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
});
});
});
});
describe
(
're
fresh
'
,
function
()
{
describe
(
're
load
'
,
function
()
{
it
(
"should return a reference to the same DAO instead of creating a new one"
,
function
(
done
)
{
it
(
"should return a reference to the same DAO instead of creating a new one"
,
function
(
done
)
{
this
.
User
.
create
({
username
:
'John Doe'
}).
done
(
function
(
err
,
originalUser
)
{
this
.
User
.
create
({
username
:
'John Doe'
}).
done
(
function
(
err
,
originalUser
)
{
...
@@ -245,7 +245,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
...
@@ -245,7 +245,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
done
();
done
();
})
})
})
})
})
})
})
})
})
})
...
@@ -271,6 +271,39 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
...
@@ -271,6 +271,39 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
},
1000
)
},
1000
)
})
})
})
})
it
(
"should update the associations as well"
,
function
(
done
)
{
var
Book
=
this
.
sequelize
.
define
(
'Book'
,
{
title
:
Helpers
.
Sequelize
.
STRING
})
,
Page
=
this
.
sequelize
.
define
(
'Page'
,
{
content
:
Helpers
.
Sequelize
.
TEXT
})
Book
.
hasMany
(
Page
)
Page
.
belongsTo
(
Book
)
this
.
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
Book
.
create
({
title
:
'A very old book'
}).
success
(
function
(
book
)
{
Page
.
create
({
content
:
'om nom nom'
}).
success
(
function
(
page
)
{
book
.
setPages
([
page
]).
success
(
function
()
{
Book
.
find
({
where
:
(
dialect
===
'postgres'
?
'"Books"."id"='
:
'`Books`.`id`='
)
+
book
.
id
,
include
:
[
Page
]
}).
success
(
function
(
leBook
)
{
page
.
updateAttributes
({
content
:
'something totally different'
}).
success
(
function
(
page
)
{
expect
(
leBook
.
pages
[
0
].
content
).
toEqual
(
'om nom nom'
)
expect
(
page
.
content
).
toEqual
(
'something totally different'
)
leBook
.
reload
().
success
(
function
(
leBook
)
{
expect
(
leBook
.
pages
[
0
].
content
).
toEqual
(
'something totally different'
)
expect
(
page
.
content
).
toEqual
(
'something totally different'
)
done
()
})
})
})
})
})
}.
bind
(
this
))
}.
bind
(
this
))
})
});
});
describe
(
'default values'
,
function
()
{
describe
(
'default values'
,
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