From 55ee705a97f26f60f6d7d118ae86fcc8725db840 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Fri, 17 Jul 2015 22:22:59 +1000 Subject: [PATCH 1/2] Fixed case where the login prompt was fired from within the run function --- app/src/app/guest/login/login.spec.ts | 10 ++++++++-- app/src/app/guest/login/login.ts | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/app/guest/login/login.spec.ts b/app/src/app/guest/login/login.spec.ts index 702bf56c..aae9d522 100644 --- a/app/src/app/guest/login/login.spec.ts +++ b/app/src/app/guest/login/login.spec.ts @@ -18,6 +18,7 @@ describe('Login', () => { let LoginController:ng.IControllerService, $scope:ng.IScope, $rootScope:ng.IRootScopeService, + $timeout:ng.ITimeoutService, $mdDialog:ng.material.IDialogService, authService:NgJwtAuth.NgJwtAuthService, deferredCredentials:ng.IDeferred, @@ -32,9 +33,10 @@ describe('Login', () => { beforeEach(()=> { - inject(($controller, _$rootScope_, _ngJwtAuthService_, _$mdDialog_, _$q_) => { + inject(($controller, _$rootScope_, _ngJwtAuthService_, _$mdDialog_, _$q_, _$timeout_) => { $rootScope = _$rootScope_; $scope = $rootScope.$new(); + $timeout = _$timeout_; $mdDialog = _$mdDialog_; authService = _ngJwtAuthService_; deferredCredentials = _$q_.defer(); @@ -86,17 +88,21 @@ describe('Login', () => { ($scope).cancelLoginDialog(); + $timeout.flush(); //flush timeout as the modal is delayed + expect($mdDialog.cancel).to.have.been.called; expect(deferredCredentials.promise).eventually.to.be.rejected; $scope.$apply(); + }); it('should show the login dialog when prompted', () => { - authService.promptLogin(); + $timeout.flush(); //flush timeout as the modal is delayed + expect($mdDialog.show).to.have.been.called; }); diff --git a/app/src/app/guest/login/login.ts b/app/src/app/guest/login/login.ts index 78e1428a..b54b0f06 100644 --- a/app/src/app/guest/login/login.ts +++ b/app/src/app/guest/login/login.ts @@ -26,10 +26,11 @@ module app.guest.login { class LoginInit { - static $inject = ['ngJwtAuthService', '$mdDialog']; + static $inject = ['ngJwtAuthService', '$mdDialog', '$timeout']; constructor( private ngJwtAuthService:NgJwtAuth.NgJwtAuthService, - private $mdDialog:ng.material.IDialogService + private $mdDialog:ng.material.IDialogService, + private $timeout:ng.ITimeoutService ) { ngJwtAuthService @@ -47,9 +48,8 @@ module app.guest.login { } }; - return $mdDialog.show(dialogConfig) - .catch(() => deferredCredentials.reject()) //if the dialog closes without resolving, reject the credentials request - ; + return $timeout(_.noop) //first do an empty timeout to allow the controllers to init if login prompt is fired from within a .run() phase + .then(() => $mdDialog.show(dialogConfig)); }) .init(); //initialise the auth service (kicks off the timers etc) From bcefa92d1b768ea9e2c272530214f79550ae9e15 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Sat, 18 Jul 2015 18:40:37 +1000 Subject: [PATCH 2/2] Updated todo file, dropped dependencies on the doc root by making it configurable with sed. Added env vars to the docker-compose file as example. --- TODO.md | 18 ------------------ docker-compose.yml | 7 ++++++- vhosts/nginx/spira-api.local.conf | 6 +++--- vhosts/nginx/spira-app.local.conf | 6 +++--- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/TODO.md b/TODO.md index 0b0b7a6c..fafbe1c1 100644 --- a/TODO.md +++ b/TODO.md @@ -1,25 +1,7 @@ #TODO -## Project -* Extend readme -* Add apiary documentation for API - -## Gulpfile -* Add file watchers to handle file changes \#13 -* Add test runner watching for karma \#13 -* Create docker container for running gulp commands, add rewrite to bashrc? and readme ie `docker-compose run gulp [gulp command]` \#14 -* Add host-only gulp tasks (work out how to differentiate in gulpfile) \#14 -** Add boot2docker tasks `gulp vm:[up|restart|down|init]` \#14 -** Add docker-compose tasks `gulp containers:[up|restart|down|status|pull]` \#14 -* Make php coverage reporting use docker container `docker-compose run --entrypoint /data/api/vendor/bin/phpunit php --coverage-clover=/data/reports/coverage/api/clover.xml --colors -c /data/api/phpunit.xml` - ## API -* Code coverage generation -* Add JWT authentication * Disable sessions (completely) ## Travis * Make travis use docker deployment ([not yet possible](http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/)) - -## Docker -* Configure gulp task to have php cli so it can run phpunit tests diff --git a/docker-compose.yml b/docker-compose.yml index 4c03af70..03fb100d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,8 @@ data: image: spira/docker-data volumes: - /data:/data + environment: + - DATA_ROOT=/data #default DATA_ROOT environment value for the other containers to inherit from privileged: true db: @@ -56,7 +58,9 @@ web: - "80:80" - "8080:8080" environment: - - NGINX_VHOSTS=vhosts/nginx/*.local.conf + - DATA_ROOT=/data + - API_PATH=/api + - NGINX_VHOSTS=vhosts/nginx/*.local.conf privileged: true devtools: @@ -84,5 +88,6 @@ lumen: - db:db - web:web environment: + - DATA_ROOT=/data - API_PATH=/api - API_DOTENV=.local.env diff --git a/vhosts/nginx/spira-api.local.conf b/vhosts/nginx/spira-api.local.conf index 91b3965d..11eec946 100644 --- a/vhosts/nginx/spira-api.local.conf +++ b/vhosts/nginx/spira-api.local.conf @@ -3,11 +3,11 @@ server { listen 8080; server_name local.api.spira.io; - root /data/api/public; + root %data-root%/api/public; index index.php index.html index.htm; - access_log /data/logs/access-api.log; - error_log /data/logs/error-api.log warn; + access_log %data-root%/logs/access-api.log; + error_log %data-root%/logs/error-api.log warn; location / { try_files $uri $uri/ /index.php?$query_string; diff --git a/vhosts/nginx/spira-app.local.conf b/vhosts/nginx/spira-app.local.conf index 838f62e8..0ac1e476 100644 --- a/vhosts/nginx/spira-app.local.conf +++ b/vhosts/nginx/spira-app.local.conf @@ -3,11 +3,11 @@ server { listen 80; server_name local.app.spira.io; - access_log /data/logs/access-app.log; - error_log /data/logs/error-app.log warn; + access_log %data-root%/logs/access-app.log; + error_log %data-root%/logs/error-app.log warn; location / { - root /data/app/build; + root %data-root%/app/build; index index.html; try_files $uri $uri/ /index.html =404; }