Skip to content

Instantly share code, notes, and snippets.

@timoxley
Created December 15, 2011 20:28
Show Gist options
  • Save timoxley/1482733 to your computer and use it in GitHub Desktop.
Save timoxley/1482733 to your computer and use it in GitHub Desktop.
'name must be unique': function(test) {
account.save(function(err) {
if (/duplicate/.test(err) || /unique/.test(err)) {
console.log(err.message)
test.done()
}
blueprints.generate('Account', function(err, anotherAccount) {
if (err) throw err
anotherAccount.name = account.name
anotherAccount.save(function(err) {
if (/duplicate/.test(err) || /unique/.test(err)) {
console.log(err.message)
test.done()
}
test.ok(err)
test.done()
})
})
})
},
'subdomain must be unique': function(test) {
account.save(function(err) {
if (/duplicate/.test(err) || /unique/.test(err)) {
console.log(err.message)
test.done()
}
blueprints.generate('Account', function(err, anotherAccount) {
if (err) throw err
anotherAccount.subdomain = account.subdomain
anotherAccount.save(function(err) {
if (/duplicate/.test(err) || /unique/.test(err)) {
console.log(err.message)
test.done()
}
test.ok(err)
test.done()
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment