diff --git a/modules/articles/client/config/articles-admin.client.routes.js b/modules/articles/client/config/articles-admin.client.routes.js index b15d918c..b493d0e0 100644 --- a/modules/articles/client/config/articles-admin.client.routes.js +++ b/modules/articles/client/config/articles-admin.client.routes.js @@ -16,7 +16,7 @@ }) .state('admin.articles.list', { url: '', - templateUrl: 'modules/articles/client/views/admin/list-articles.client.view.html', + templateUrl: '/modules/articles/client/views/admin/list-articles.client.view.html', controller: 'ArticlesAdminListController', controllerAs: 'vm', data: { @@ -25,7 +25,7 @@ }) .state('admin.articles.create', { url: '/create', - templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html', + templateUrl: '/modules/articles/client/views/admin/form-article.client.view.html', controller: 'ArticlesAdminController', controllerAs: 'vm', data: { @@ -37,7 +37,7 @@ }) .state('admin.articles.edit', { url: '/:articleId/edit', - templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html', + templateUrl: '/modules/articles/client/views/admin/form-article.client.view.html', controller: 'ArticlesAdminController', controllerAs: 'vm', data: { diff --git a/modules/articles/client/config/articles.client.routes.js b/modules/articles/client/config/articles.client.routes.js index a16926e5..4a94fa2e 100644 --- a/modules/articles/client/config/articles.client.routes.js +++ b/modules/articles/client/config/articles.client.routes.js @@ -16,7 +16,7 @@ }) .state('articles.list', { url: '', - templateUrl: 'modules/articles/client/views/list-articles.client.view.html', + templateUrl: '/modules/articles/client/views/list-articles.client.view.html', controller: 'ArticlesListController', controllerAs: 'vm', data: { @@ -25,7 +25,7 @@ }) .state('articles.view', { url: '/:articleId', - templateUrl: 'modules/articles/client/views/view-article.client.view.html', + templateUrl: '/modules/articles/client/views/view-article.client.view.html', controller: 'ArticlesController', controllerAs: 'vm', resolve: { diff --git a/modules/articles/client/services/articles.client.service.js b/modules/articles/client/services/articles.client.service.js index 19b8015d..5e653ca4 100644 --- a/modules/articles/client/services/articles.client.service.js +++ b/modules/articles/client/services/articles.client.service.js @@ -8,7 +8,7 @@ ArticlesService.$inject = ['$resource', '$log']; function ArticlesService($resource, $log) { - var Article = $resource('api/articles/:articleId', { + var Article = $resource('/api/articles/:articleId', { articleId: '@_id' }, { update: { diff --git a/modules/articles/tests/client/admin.articles.client.controller.tests.js b/modules/articles/tests/client/admin.articles.client.controller.tests.js index 52b206e4..32964a8f 100644 --- a/modules/articles/tests/client/admin.articles.client.controller.tests.js +++ b/modules/articles/tests/client/admin.articles.client.controller.tests.js @@ -48,6 +48,9 @@ ArticlesService = _ArticlesService_; Notification = _Notification_; + // Ignore parent template get on state transitions + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200, ''); + // create mock article mockArticle = new ArticlesService({ _id: '525a8422f6d0f87f0e407a33', @@ -87,7 +90,7 @@ it('should send a POST request with the form input values and then locate to new object URL', inject(function (ArticlesService) { // Set POST response - $httpBackend.expectPOST('api/articles', sampleArticlePostData).respond(mockArticle); + $httpBackend.expectPOST('/api/articles', sampleArticlePostData).respond(mockArticle); // Run controller functionality $scope.vm.save(true); @@ -101,7 +104,7 @@ it('should call Notification.error if error', function () { var errorMessage = 'this is an error message'; - $httpBackend.expectPOST('api/articles', sampleArticlePostData).respond(400, { + $httpBackend.expectPOST('/api/articles', sampleArticlePostData).respond(400, { message: errorMessage }); diff --git a/modules/articles/tests/client/admin.articles.client.routes.tests.js b/modules/articles/tests/client/admin.articles.client.routes.tests.js index e699ae45..0a7873e4 100644 --- a/modules/articles/tests/client/admin.articles.client.routes.tests.js +++ b/modules/articles/tests/client/admin.articles.client.routes.tests.js @@ -53,7 +53,7 @@ }); it('Should have templateUrl', function () { - expect(liststate.templateUrl).toBe('modules/articles/client/views/admin/list-articles.client.view.html'); + expect(liststate.templateUrl).toBe('/modules/articles/client/views/admin/list-articles.client.view.html'); }); }); @@ -64,7 +64,7 @@ beforeEach(inject(function ($controller, $state, $templateCache) { createstate = $state.get('admin.articles.create'); - $templateCache.put('modules/articles/client/views/admin/form-article.client.view.html', ''); + $templateCache.put('/modules/articles/client/views/admin/form-article.client.view.html', ''); // Create mock article mockArticle = new ArticlesService(); @@ -99,7 +99,7 @@ }); it('Should have templateUrl', function () { - expect(createstate.templateUrl).toBe('modules/articles/client/views/admin/form-article.client.view.html'); + expect(createstate.templateUrl).toBe('/modules/articles/client/views/admin/form-article.client.view.html'); }); }); @@ -110,7 +110,7 @@ beforeEach(inject(function ($controller, $state, $templateCache) { editstate = $state.get('admin.articles.edit'); - $templateCache.put('modules/articles/client/views/admin/form-article.client.view.html', ''); + $templateCache.put('/modules/articles/client/views/admin/form-article.client.view.html', ''); // Create mock article mockArticle = new ArticlesService({ @@ -150,7 +150,7 @@ }); it('Should have templateUrl', function () { - expect(editstate.templateUrl).toBe('modules/articles/client/views/admin/form-article.client.view.html'); + expect(editstate.templateUrl).toBe('/modules/articles/client/views/admin/form-article.client.view.html'); }); xit('Should go to unauthorized route', function () { diff --git a/modules/articles/tests/client/admin.list.articles.client.controller.tests.js b/modules/articles/tests/client/admin.list.articles.client.controller.tests.js index e4e99dbb..90bd19f1 100644 --- a/modules/articles/tests/client/admin.list.articles.client.controller.tests.js +++ b/modules/articles/tests/client/admin.list.articles.client.controller.tests.js @@ -46,6 +46,10 @@ Authentication = _Authentication_; ArticlesService = _ArticlesService_; + // Ignore parent template get on state transitions + $httpBackend.whenGET('/modules/articles/client/views/list-articles.client.view.html').respond(200, ''); + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200, ''); + // create mock article mockArticle = new ArticlesService({ _id: '525a8422f6d0f87f0e407a33', @@ -76,7 +80,7 @@ it('should send a GET request and return all articles', inject(function (ArticlesService) { // Set POST response - $httpBackend.expectGET('api/articles').respond(mockArticleList); + $httpBackend.expectGET('/api/articles').respond(mockArticleList); $httpBackend.flush(); diff --git a/modules/articles/tests/client/articles.client.routes.tests.js b/modules/articles/tests/client/articles.client.routes.tests.js index 650223d8..7b724a5c 100644 --- a/modules/articles/tests/client/articles.client.routes.tests.js +++ b/modules/articles/tests/client/articles.client.routes.tests.js @@ -53,7 +53,7 @@ }); it('Should have templateUrl', function () { - expect(liststate.templateUrl).toBe('modules/articles/client/views/list-articles.client.view.html'); + expect(liststate.templateUrl).toBe('/modules/articles/client/views/list-articles.client.view.html'); }); }); @@ -64,7 +64,7 @@ beforeEach(inject(function ($controller, $state, $templateCache) { viewstate = $state.get('articles.view'); - $templateCache.put('modules/articles/client/views/view-article.client.view.html', ''); + $templateCache.put('/modules/articles/client/views/view-article.client.view.html', ''); // create mock article mockArticle = new ArticlesService({ @@ -104,12 +104,14 @@ }); it('Should have templateUrl', function () { - expect(viewstate.templateUrl).toBe('modules/articles/client/views/view-article.client.view.html'); + expect(viewstate.templateUrl).toBe('/modules/articles/client/views/view-article.client.view.html'); }); }); describe('Handle Trailing Slash', function () { - beforeEach(inject(function ($state, $rootScope) { + beforeEach(inject(function ($state, $rootScope, $templateCache) { + $templateCache.put('/modules/articles/client/views/list-articles.client.view.html', ''); + $state.go('articles.list'); $rootScope.$digest(); })); @@ -119,7 +121,7 @@ $rootScope.$digest(); expect($location.path()).toBe('/articles'); - expect($state.current.templateUrl).toBe('modules/articles/client/views/list-articles.client.view.html'); + expect($state.current.templateUrl).toBe('/modules/articles/client/views/list-articles.client.view.html'); })); }); }); diff --git a/modules/articles/tests/client/list-articles.client.controller.tests.js b/modules/articles/tests/client/list-articles.client.controller.tests.js index ee654f47..b5e37c9f 100644 --- a/modules/articles/tests/client/list-articles.client.controller.tests.js +++ b/modules/articles/tests/client/list-articles.client.controller.tests.js @@ -76,8 +76,10 @@ it('should send a GET request and return all articles', inject(function (ArticlesService) { // Set POST response - $httpBackend.expectGET('api/articles').respond(mockArticleList); + $httpBackend.expectGET('/api/articles').respond(mockArticleList); + // Ignore parent template get on state transition + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200, ''); $httpBackend.flush(); diff --git a/modules/chat/client/config/chat.client.routes.js b/modules/chat/client/config/chat.client.routes.js index 4ec07d8b..f69aff61 100644 --- a/modules/chat/client/config/chat.client.routes.js +++ b/modules/chat/client/config/chat.client.routes.js @@ -11,7 +11,7 @@ $stateProvider .state('chat', { url: '/chat', - templateUrl: 'modules/chat/client/views/chat.client.view.html', + templateUrl: '/modules/chat/client/views/chat.client.view.html', controller: 'ChatController', controllerAs: 'vm', data: { diff --git a/modules/chat/client/views/chat.client.view.html b/modules/chat/client/views/chat.client.view.html index 3b9174c6..ad45efa5 100644 --- a/modules/chat/client/views/chat.client.view.html +++ b/modules/chat/client/views/chat.client.view.html @@ -18,7 +18,7 @@
  • - {{message.username}} + {{message.username}}

    diff --git a/modules/chat/tests/client/chat.client.controller.tests.js b/modules/chat/tests/client/chat.client.controller.tests.js index 50139f68..693ceb3b 100644 --- a/modules/chat/tests/client/chat.client.controller.tests.js +++ b/modules/chat/tests/client/chat.client.controller.tests.js @@ -11,7 +11,8 @@ ChatController, $timeout, $state, - Authentication; + Authentication, + $httpBackend; // Load the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); @@ -39,12 +40,17 @@ }); describe('when user logged in', function () { - beforeEach(inject(function ($controller, $rootScope, _Socket_, _Authentication_, _$timeout_, _$state_) { + beforeEach(inject(function ($controller, $rootScope, _$httpBackend_, _Socket_, _Authentication_, _$timeout_, _$state_) { Authentication.user = { name: 'user', roles: ['user'] }; + $httpBackend = _$httpBackend_; + + // Ignore parent template get on state transitions + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200, ''); + ChatController = $controller('ChatController as vm', { $scope: $scope }); diff --git a/modules/chat/tests/client/chat.client.routes.tests.js b/modules/chat/tests/client/chat.client.routes.tests.js index bbd447ee..2f16e8db 100644 --- a/modules/chat/tests/client/chat.client.routes.tests.js +++ b/modules/chat/tests/client/chat.client.routes.tests.js @@ -4,7 +4,8 @@ describe('Chat Route Tests', function () { // Initialize global variables var $scope, - Authentication; + Authentication, + $httpBackend; // We can start by loading the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); @@ -34,27 +35,35 @@ }); it('Should have templateUrl', function () { - expect(mainstate.templateUrl).toBe('modules/chat/client/views/chat.client.view.html'); + expect(mainstate.templateUrl).toBe('/modules/chat/client/views/chat.client.view.html'); }); }); describe('Handle Trailing Slash', function () { - beforeEach(inject(function ($state, $rootScope, _Authentication_) { + beforeEach(inject(function ($state, $rootScope, _$httpBackend_, _Authentication_) { Authentication.user = { name: 'user', roles: ['user'] }; + $httpBackend = _$httpBackend_; + + // Ignore parent template get on state transition + $httpBackend.whenGET('/modules/chat/client/views/chat.client.view.html').respond(200); + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200, ''); + $state.go('chat'); $rootScope.$digest(); })); - it('Should remove trailing slash', inject(function ($state, $location, $rootScope) { + it('Should remove trailing slash', inject(function ($state, $location, $rootScope, $templateCache) { + $templateCache.put('/modules/chat/client/views/chat.client.view.html', ''); + $location.path('chat/'); $rootScope.$digest(); expect($location.path()).toBe('/chat'); - expect($state.current.templateUrl).toBe('modules/chat/client/views/chat.client.view.html'); + expect($state.current.templateUrl).toBe('/modules/chat/client/views/chat.client.view.html'); })); }); diff --git a/modules/core/client/app/init.js b/modules/core/client/app/init.js index 4b99c46d..8ffaef33 100644 --- a/modules/core/client/app/init.js +++ b/modules/core/client/app/init.js @@ -13,7 +13,10 @@ bootstrapConfig.$inject = ['$compileProvider', '$locationProvider', '$httpProvider', '$logProvider']; function bootstrapConfig($compileProvider, $locationProvider, $httpProvider, $logProvider) { - $locationProvider.html5Mode(true).hashPrefix('!'); + $locationProvider.html5Mode({ + enabled: true, + requireBase: false + }).hashPrefix('!'); $httpProvider.interceptors.push('authInterceptor'); diff --git a/modules/core/client/config/core.client.routes.js b/modules/core/client/config/core.client.routes.js index 9a89d6c3..c00f8807 100644 --- a/modules/core/client/config/core.client.routes.js +++ b/modules/core/client/config/core.client.routes.js @@ -29,13 +29,13 @@ $stateProvider .state('home', { url: '/', - templateUrl: 'modules/core/client/views/home.client.view.html', + templateUrl: '/modules/core/client/views/home.client.view.html', controller: 'HomeController', controllerAs: 'vm' }) .state('not-found', { url: '/not-found', - templateUrl: 'modules/core/client/views/404.client.view.html', + templateUrl: '/modules/core/client/views/404.client.view.html', controller: 'ErrorController', controllerAs: 'vm', params: { @@ -50,7 +50,7 @@ }) .state('bad-request', { url: '/bad-request', - templateUrl: 'modules/core/client/views/400.client.view.html', + templateUrl: '/modules/core/client/views/400.client.view.html', controller: 'ErrorController', controllerAs: 'vm', params: { @@ -65,7 +65,7 @@ }) .state('forbidden', { url: '/forbidden', - templateUrl: 'modules/core/client/views/403.client.view.html', + templateUrl: '/modules/core/client/views/403.client.view.html', data: { ignoreState: true, pageTitle: 'Forbidden' diff --git a/modules/core/client/views/header.client.view.html b/modules/core/client/views/header.client.view.html index c09e9770..d35f961d 100644 --- a/modules/core/client/views/header.client.view.html +++ b/modules/core/client/views/header.client.view.html @@ -32,7 +32,7 @@