Upgrade tests to 1.1.0

This commit is contained in:
Tobe O 2017-12-22 08:35:46 -05:00
parent 310474438e
commit bd2c6ddb93
2 changed files with 11 additions and 9 deletions

View file

@ -12,7 +12,7 @@ main() {
setUp(() async {
app = new Angel()
..lazyParseBodies = true
..before.add((RequestContext req, res) async {
..use((RequestContext req, res) async {
var xUser = req.headers.value('X-User');
if (xUser != null)
req.inject('user',
@ -25,7 +25,7 @@ main() {
..use('/artists', new ArtistService())
..use('/roled', new RoledService());
app.service('user_data')
(app.service('user_data') as HookedService)
..beforeIndexed.listen(hooks.queryWithCurrentUser())
..beforeCreated.listen(hooks.hashPassword());
@ -34,14 +34,16 @@ main() {
..beforeRead.listen(hooks.restrictToOwner())
..beforeCreated.listen(hooks.associateCurrentUser());
app.service('roled')
(app.service('roled') as HookedService)
..beforeIndexed.listen(new Permission('foo:*').toHook())
..beforeRead.listen(new Permission('foo:*').toHook(owner: true));
app.fatalErrorStream.listen((e) {
print('Fatal: ${e.error}');
print(e.stack);
});
var errorHandler = app.errorHandler;
app.errorHandler = (e, req, res) {
print(e.toJson());
print(e.stackTrace);
return errorHandler(e, req, res);
};
client = await connectTo(app);
});
@ -272,7 +274,7 @@ const Artist _MICHAEL_JACKSON =
class RoledService extends Service {
@override
index([params]) {
index([params]) async {
return ['foo'];
}

View file

@ -16,7 +16,7 @@ main() {
setUp(() async {
app = new Angel();
app.before.add((RequestContext req, res) async {
app.use((RequestContext req, res) async {
// In real life, you'd use auth to check user roles,
// but in this case, let's just set the user manually
var xRoles = req.headers.value('X-Roles');