不要怂,就是干,撸起袖子干!

Commit 28f334e9 by Sascha Depold

store passed values of build in instance.selectedValues

1 parent 6fee856d
Showing with 10 additions and 5 deletions
...@@ -203,14 +203,13 @@ module.exports = (function() { ...@@ -203,14 +203,13 @@ module.exports = (function() {
}) })
Utils._.each(this.options.instanceMethods || {}, function(fct, name) { instance[name] = fct }) Utils._.each(this.options.instanceMethods || {}, function(fct, name) { instance[name] = fct })
Utils._.each(this.associations, function(association, associationName) { Utils._.each(this.associations, function(association) {
association.injectGetter(instance) association.injectGetter(instance)
association.injectSetter(instance) association.injectSetter(instance)
}) })
instance.isNewRecord = options.hasOwnProperty('isNewRecord') ? options.isNewRecord : true instance.isNewRecord = options.hasOwnProperty('isNewRecord') ? options.isNewRecord : true
instance.selectedValues = values
instance.returned_values = values
return instance return instance
} }
...@@ -222,8 +221,9 @@ module.exports = (function() { ...@@ -222,8 +221,9 @@ module.exports = (function() {
DAOFactory.prototype.__defineGetter__('primaryKeys', function() { DAOFactory.prototype.__defineGetter__('primaryKeys', function() {
var result = {} var result = {}
Utils._.each(this.attributes, function(dataTypeString, attributeName) { Utils._.each(this.attributes, function(dataTypeString, attributeName) {
if((attributeName != 'id') && (dataTypeString.indexOf('PRIMARY KEY') > -1)) if((attributeName != 'id') && (dataTypeString.indexOf('PRIMARY KEY') > -1)) {
result[attributeName] = dataTypeString result[attributeName] = dataTypeString
}
}) })
return result return result
......
...@@ -91,6 +91,11 @@ dialects.forEach(function(dialect) { ...@@ -91,6 +91,11 @@ dialects.forEach(function(dialect) {
expect(Task.build().foobar).toEqual('asd') expect(Task.build().foobar).toEqual('asd')
expect(Task.build().flag).toEqual(false) expect(Task.build().flag).toEqual(false)
}) })
it("stores the the passed values in a special variable", function() {
var user = this.User.build({ username: 'John Wayne' })
expect(user.selectedValues).toEqual({ username: 'John Wayne' })
})
}) })
describe('create', function() { describe('create', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!