-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
not hijacking then method anymore , it causes issues while creating r…
…ecords
- Loading branch information
1 parent
49538bc
commit 9fd225c
Showing
10 changed files
with
166 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
const chai = require('chai') | ||
const expect = chai.expect | ||
const Database = require('../../src/Database') | ||
const Model = require('../../src/Orm/Proxy/Model') | ||
|
||
let Env = { | ||
get: function(){ | ||
return 'sqlite' | ||
} | ||
} | ||
|
||
let Config = { | ||
get: function(name){ | ||
return { | ||
client: 'sqlite3', | ||
connection: { | ||
filename: path.join(__dirname,'./storage/blog.sqlite3') | ||
}, | ||
debug: false | ||
} | ||
} | ||
} | ||
|
||
const db = new Database(Env,Config) | ||
|
||
class User extends Model{ | ||
|
||
getUsername(value){ | ||
return value.toUpperCase() | ||
} | ||
|
||
} | ||
|
||
User.database = db | ||
User = User.extend() | ||
|
||
|
||
class Posts extends Model{ | ||
} | ||
|
||
describe('Database Implementation', function () { | ||
|
||
context('Users', function () { | ||
|
||
it('should be able to create a new user using static create method', function (done) { | ||
|
||
const userData = { | ||
username: 'virk', | ||
email: 'virk@adonisjs.com', | ||
password: 'foobar' | ||
} | ||
|
||
let user_id = null | ||
|
||
User | ||
.create(userData) | ||
.then (function (user) { | ||
user_id = user[0] | ||
return User.where('id',user_id).fetch() | ||
}) | ||
.then (function (user){ | ||
expect(user.first().username).to.equal('VIRK') | ||
done() | ||
}) | ||
.catch(done) | ||
|
||
}) | ||
|
||
}) | ||
|
||
}) |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters