Commit 4b131cec4c59abefe42fa419f70a38d645e5443d
1 parent
af7485cb
Exists in
master
and in
1 other branch
Refactor profile controller name
Showing
9 changed files
with
80 additions
and
84 deletions
Show diff stats
src/app/index.route.js
| @@ -8,9 +8,9 @@ | @@ -8,9 +8,9 @@ | ||
| 8 | function routeConfig($routeProvider) { | 8 | function routeConfig($routeProvider) { |
| 9 | $routeProvider | 9 | $routeProvider |
| 10 | .when('/:profile', { | 10 | .when('/:profile', { |
| 11 | - templateUrl: 'app/main/main.html', | ||
| 12 | - controller: 'MainController', | ||
| 13 | - controllerAs: 'main' | 11 | + templateUrl: 'app/profile/profile.html', |
| 12 | + controller: 'ProfileController', | ||
| 13 | + controllerAs: 'vm' | ||
| 14 | }) | 14 | }) |
| 15 | .when('/profile/:profile', { | 15 | .when('/profile/:profile', { |
| 16 | redirectTo: '/:profile' | 16 | redirectTo: '/:profile' |
src/app/main/main.controller.js
| @@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
| 1 | -(function() { | ||
| 2 | - 'use strict'; | ||
| 3 | - | ||
| 4 | - angular | ||
| 5 | - .module('angular') | ||
| 6 | - .controller('MainController', MainController); | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - /** @ngInject */ | ||
| 10 | - function MainController($timeout, noosfero, $log, $routeParams) { | ||
| 11 | - var vm = this; | ||
| 12 | - vm.boxes = []; | ||
| 13 | - activate(); | ||
| 14 | - | ||
| 15 | - function activate() { | ||
| 16 | - noosfero.communities().get({identifier: $routeParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { | ||
| 17 | - $log.log(profile); | ||
| 18 | - vm.owner = profile.communities[0]; | ||
| 19 | - }); | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - vm.boxesOrder = function(box) { | ||
| 23 | - if(box.position==2) return 0; | ||
| 24 | - return box.position; | ||
| 25 | - } | ||
| 26 | - } | ||
| 27 | -})(); |
src/app/main/main.controller.spec.js
| @@ -1,38 +0,0 @@ | @@ -1,38 +0,0 @@ | ||
| 1 | -(function() { | ||
| 2 | - 'use strict'; | ||
| 3 | - | ||
| 4 | - describe('controllers', function(){ | ||
| 5 | - var vm; | ||
| 6 | - var $timeout; | ||
| 7 | - var toastr; | ||
| 8 | - | ||
| 9 | - beforeEach(module('angular')); | ||
| 10 | - beforeEach(inject(function(_$controller_, _$timeout_, _toastr_) { | ||
| 11 | - spyOn(_toastr_, 'info').and.callThrough(); | ||
| 12 | - | ||
| 13 | - vm = _$controller_('MainController'); | ||
| 14 | - $timeout = _$timeout_; | ||
| 15 | - toastr = _toastr_; | ||
| 16 | - })); | ||
| 17 | - | ||
| 18 | - it('should have a timestamp creation date', function() { | ||
| 19 | - expect(vm.creationDate).toEqual(jasmine.any(Number)); | ||
| 20 | - }); | ||
| 21 | - | ||
| 22 | - it('should define animate class after delaying timeout ', function() { | ||
| 23 | - $timeout.flush(); | ||
| 24 | - expect(vm.classAnimation).toEqual('rubberBand'); | ||
| 25 | - }); | ||
| 26 | - | ||
| 27 | - it('should show a Toastr info and stop animation when invoke showToastr()', function() { | ||
| 28 | - vm.showToastr(); | ||
| 29 | - expect(toastr.info).toHaveBeenCalled(); | ||
| 30 | - expect(vm.classAnimation).toEqual(''); | ||
| 31 | - }); | ||
| 32 | - | ||
| 33 | - it('should define more than 5 awesome things', function() { | ||
| 34 | - expect(angular.isArray(vm.awesomeThings)).toBeTruthy(); | ||
| 35 | - expect(vm.awesomeThings.length === 5).toBeTruthy(); | ||
| 36 | - }); | ||
| 37 | - }); | ||
| 38 | -})(); |
src/app/main/main.html
src/app/pages/profile/box.html
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +(function() { | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + angular | ||
| 5 | + .module('angular') | ||
| 6 | + .controller('ProfileController', ProfileController); | ||
| 7 | + | ||
| 8 | + | ||
| 9 | + /** @ngInject */ | ||
| 10 | + function ProfileController($timeout, noosfero, $log, $routeParams) { | ||
| 11 | + var vm = this; | ||
| 12 | + vm.boxes = []; | ||
| 13 | + activate(); | ||
| 14 | + | ||
| 15 | + function activate() { | ||
| 16 | + noosfero.communities().get({identifier: $routeParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { | ||
| 17 | + $log.log(profile); | ||
| 18 | + vm.owner = profile.communities[0]; | ||
| 19 | + }); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + vm.boxesOrder = function(box) { | ||
| 23 | + if(box.position==2) return 0; | ||
| 24 | + return box.position; | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | +})(); |
| @@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
| 1 | +(function() { | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + describe('controllers', function(){ | ||
| 5 | + var vm; | ||
| 6 | + var $timeout; | ||
| 7 | + var toastr; | ||
| 8 | + | ||
| 9 | + beforeEach(module('angular')); | ||
| 10 | + beforeEach(inject(function(_$controller_, _$timeout_, _toastr_) { | ||
| 11 | + spyOn(_toastr_, 'info').and.callThrough(); | ||
| 12 | + | ||
| 13 | + vm = _$controller_('MainController'); | ||
| 14 | + $timeout = _$timeout_; | ||
| 15 | + toastr = _toastr_; | ||
| 16 | + })); | ||
| 17 | + | ||
| 18 | + it('should have a timestamp creation date', function() { | ||
| 19 | + expect(vm.creationDate).toEqual(jasmine.any(Number)); | ||
| 20 | + }); | ||
| 21 | + | ||
| 22 | + it('should define animate class after delaying timeout ', function() { | ||
| 23 | + $timeout.flush(); | ||
| 24 | + expect(vm.classAnimation).toEqual('rubberBand'); | ||
| 25 | + }); | ||
| 26 | + | ||
| 27 | + it('should show a Toastr info and stop animation when invoke showToastr()', function() { | ||
| 28 | + vm.showToastr(); | ||
| 29 | + expect(toastr.info).toHaveBeenCalled(); | ||
| 30 | + expect(vm.classAnimation).toEqual(''); | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + it('should define more than 5 awesome things', function() { | ||
| 34 | + expect(angular.isArray(vm.awesomeThings)).toBeTruthy(); | ||
| 35 | + expect(vm.awesomeThings.length === 5).toBeTruthy(); | ||
| 36 | + }); | ||
| 37 | + }); | ||
| 38 | +})(); |
src/app/views/profile/block.html
| @@ -3,6 +3,6 @@ | @@ -3,6 +3,6 @@ | ||
| 3 | <h3 class="panel-title">{{block.title}}</h3> | 3 | <h3 class="panel-title">{{block.title}}</h3> |
| 4 | </div> | 4 | </div> |
| 5 | <div class="panel-body"> | 5 | <div class="panel-body"> |
| 6 | - <noosfero-block block="block" owner="main.owner"></noosfero-block> | 6 | + <noosfero-block block="block" owner="vm.owner"></noosfero-block> |
| 7 | </div> | 7 | </div> |
| 8 | </div> | 8 | </div> |