Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
fix(articles): Article controllers name conflicts (#1428)
Browse files Browse the repository at this point in the history
* fix(articles): Article controllers name conflicts

Fixes the naming conflicts for the Articles controllers.

Due to how Angular injects the controllers into the StateProvider,
naming conflicts were caused between the Articles public & admin module
controllers.

To resolve the issue the referenced controllers in the Articles admin
route configurations must be unique, and match up with the Admin
controllers.

* Client-side tests failing

Fixed the client-side tests that were failing due to the naming
conflicts.
  • Loading branch information
mleanos authored and lirantal committed Aug 26, 2016
1 parent 96aec09 commit c96f8c0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.state('admin.articles.list', {
url: '',
templateUrl: 'modules/articles/client/views/admin/list-articles.client.view.html',
controller: 'ArticlesListController',
controller: 'ArticlesAdminListController',
controllerAs: 'vm',
data: {
roles: ['admin']
Expand All @@ -26,7 +26,7 @@
.state('admin.articles.create', {
url: '/create',
templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html',
controller: 'ArticlesController',
controller: 'ArticlesAdminController',
controllerAs: 'vm',
data: {
roles: ['admin']
Expand All @@ -38,7 +38,7 @@
.state('admin.articles.edit', {
url: '/:articleId/edit',
templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html',
controller: 'ArticlesController',
controller: 'ArticlesAdminController',
controllerAs: 'vm',
data: {
roles: ['admin']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

angular
.module('articles.admin')
.controller('ArticlesController', ArticlesController);
.controller('ArticlesAdminController', ArticlesAdminController);

ArticlesController.$inject = ['$scope', '$state', '$window', 'articleResolve', 'Authentication'];
ArticlesAdminController.$inject = ['$scope', '$state', '$window', 'articleResolve', 'Authentication'];

function ArticlesController($scope, $state, $window, article, Authentication) {
function ArticlesAdminController($scope, $state, $window, article, Authentication) {
var vm = this;

vm.article = article;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
'use strict';

angular
.module('articles')
.controller('ArticlesListController', ArticlesListController);
.module('articles.admin')
.controller('ArticlesAdminListController', ArticlesAdminListController);

ArticlesListController.$inject = ['ArticlesService'];
ArticlesAdminListController.$inject = ['ArticlesService'];

function ArticlesListController(ArticlesService) {
function ArticlesAdminListController(ArticlesService) {
var vm = this;

vm.articles = ArticlesService.query();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function () {
'use strict';

describe('Articles Controller Tests', function () {
describe('Articles Admin Controller Tests', function () {
// Initialize global variables
var ArticlesController,
var ArticlesAdminController,
$scope,
$httpBackend,
$state,
Expand Down Expand Up @@ -59,7 +59,7 @@
};

// Initialize the Articles controller.
ArticlesController = $controller('ArticlesController as vm', {
ArticlesAdminController = $controller('ArticlesAdminController as vm', {
$scope: $scope,
articleResolve: {}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

describe('Create Route', function () {
var createstate,
ArticlesController,
ArticlesAdminController,
mockArticle;

beforeEach(inject(function ($controller, $state, $templateCache) {
Expand All @@ -70,7 +70,7 @@
mockArticle = new ArticlesService();

// Initialize Controller
ArticlesController = $controller('ArticlesController as vm', {
ArticlesAdminController = $controller('ArticlesAdminController as vm', {
$scope: $scope,
articleResolve: mockArticle
});
Expand Down Expand Up @@ -105,7 +105,7 @@

describe('Edit Route', function () {
var editstate,
ArticlesController,
ArticlesAdminController,
mockArticle;

beforeEach(inject(function ($controller, $state, $templateCache) {
Expand All @@ -120,7 +120,7 @@
});

// Initialize Controller
ArticlesController = $controller('ArticlesController as vm', {
ArticlesAdminController = $controller('ArticlesAdminController as vm', {
$scope: $scope,
articleResolve: mockArticle
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('Admin Articles List Controller Tests', function () {
// Initialize global variables
var ArticlesListController,
var ArticlesAdminListController,
$scope,
$httpBackend,
$state,
Expand Down Expand Up @@ -59,7 +59,7 @@
};

// Initialize the Articles List controller.
ArticlesListController = $controller('ArticlesListController as vm', {
ArticlesAdminListController = $controller('ArticlesAdminListController as vm', {
$scope: $scope
});

Expand Down

0 comments on commit c96f8c0

Please sign in to comment.