Skip to content

Commit

Permalink
Add private deployment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmule committed Jan 14, 2016
1 parent c105bdd commit b0dd47e
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/unit/common/controllers/navigation-controller-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var ROOT_PATH = '../../../../';

describe('navigation controller', function () {

var $rootScope,
$scope,
$controller,
ConfigEndpoint,
mockAuthenticationService,
BootstrapConfig;

beforeEach(function () {
var testApp = angular.module('testApp', [
'pascalprecht.translate',
'ngResource',
'angular-cache'
])
.controller('navigationController', require(ROOT_PATH + 'app/common/controllers/navigation.js'))
.service('ConfigEndpoint', require(ROOT_PATH + 'app/common/services/endpoints/config.js'))
.factory('BootstrapConfig', function () {
return {
private: true
};
});

require(ROOT_PATH + 'test/unit/simple-test-app-config')(testApp);

angular.mock.module('testApp');
});

beforeEach(inject(function (_$rootScope_,
_$controller_,
_ConfigEndpoint_,
_BootstrapConfig_) {
$rootScope = _$rootScope_;
$controller = _$controller_;
ConfigEndpoint = _ConfigEndpoint_;
BootstrapConfig = _BootstrapConfig_;
$scope = _$rootScope_.$new();
}));

beforeEach(function () {
$controller('navigationController', {
$rootScope: $rootScope,
$scope: $scope,
Authentication: {}
});
});

describe('private deployment', function() {
it('should not allow a user to register on a private deployment', function () {
expect($scope.site.private).toBe(true);
expect($scope.canRegister()).toBe(false);
});

it('should not allow a non-logged in user to create a post on a private deployment', function () {
$scope.loggedin = false;

expect($scope.site.private).toBe(true);
expect($scope.canCreatePost()).toBe(false);
});
});
});

0 comments on commit b0dd47e

Please sign in to comment.