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 62dfc1a5
authored
Mar 30, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some tests
1 parent
17fd3447
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
lib/sequelize/model-definition.js
test/Model/mixin.js
test/Model/sync.js
lib/sequelize/model-definition.js
View file @
62dfc1a
...
@@ -74,4 +74,6 @@ ModelDefinition.prototype.build = function(values) {
...
@@ -74,4 +74,6 @@ ModelDefinition.prototype.build = function(values) {
ModelDefinition
.
prototype
.
create
=
function
(
values
)
{
ModelDefinition
.
prototype
.
create
=
function
(
values
)
{
return
this
.
build
(
values
).
save
return
this
.
build
(
values
).
save
}
}
\ No newline at end of file
Utils
.
_
.
map
(
require
(
"./association-mixin"
).
classMethods
,
function
(
fct
,
name
)
{
ModelDefinition
.
prototype
[
name
]
=
fct
})
\ No newline at end of file
test/Model/mixin.js
View file @
62dfc1a
var
assert
=
require
(
"assert"
)
var
assert
=
require
(
"assert"
)
,
Model
=
require
(
"./../../lib/sequelize/model
"
)
,
Model
Definition
=
require
(
"./../../lib/sequelize/model-definition
"
)
module
.
exports
=
{
module
.
exports
=
{
'mixin should be correctly added to the model'
:
function
()
{
'mixin should be correctly added to the model'
:
function
()
{
assert
.
isDefined
(
Model
.
hasOne
)
assert
.
isDefined
(
ModelDefinition
.
prototype
.
hasOne
)
assert
.
isDefined
(
Model
.
hasMany
)
assert
.
isDefined
(
ModelDefinition
.
prototype
.
hasMany
)
assert
.
isDefined
(
Model
.
belongsTo
)
assert
.
isDefined
(
ModelDefinition
.
prototype
.
belongsTo
)
},
'model methods should be correctly added to the model'
:
function
()
{
assert
.
isDefined
(
Model
.
drop
)
assert
.
isDefined
(
Model
.
sync
)
assert
.
isDefined
(
Model
.
prototype
.
save
)
assert
.
isDefined
(
Model
.
prototype
.
destroy
)
}
}
}
}
\ No newline at end of file
test/Model/sync.js
0 → 100644
View file @
62dfc1a
var
assert
=
require
(
"assert"
)
,
config
=
require
(
"./../config"
)
,
Sequelize
=
require
(
"./../../index"
)
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
)
module
.
exports
=
{
'sync should work'
:
function
(
beforeExit
)
{
var
User
=
sequelize
.
define
(
'User'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
User
.
sync
().
on
(
'success'
,
beforeExit
)
}
}
\ No newline at end of file
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