Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #53 from marmelab/refactor_errors
Browse files Browse the repository at this point in the history
[RFR] Refactor errors (follows #52)
  • Loading branch information
fzaninotto committed May 30, 2014
2 parents 6598ada + cfbd8a2 commit 7f4656a
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 438 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"angular": "1.2.14",
"angular-route": "1.2.6",
"angular-ui-router": "0.2.8-bowratic-tedium",
"angular-ui-router": "0.2.10",
"bootstrap": "3.0.2",
"html5shiv": "3.7.0",
"respond": "1.4.2",
Expand Down
5 changes: 5 additions & 0 deletions sass/phpcr-browser/toaster.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ $animation-duration: 200;
#toast-container > div {
@include border-radius(0);
@include box-shadow(none);

&:hover {
@include border-radius(0);
@include box-shadow(none);
}
}
17 changes: 3 additions & 14 deletions tests/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ define('mocks', [
getName: function() { return fixtures.workspaces[0].name; },
getRepository: function() {
return {
getName: function() { return fixtures.repositories[0].name; }
getName: function() { return fixtures.repositories[0].name; },
getWorkspaces: jasmine.createSpy('getWorkspaces').andReturn(mixins.buildPromise([])),
};
}
}),
Expand Down Expand Up @@ -223,17 +224,6 @@ define('mocks', [
};
};

getRouteParametersConverterMock = function() {
var repository = getRepositoryMock(),
workspace = getWorkspaceMock(),
node = getNodeMock();
return {
getCurrentRepository: jasmine.createSpy('getCurrentRepository').andReturn(mixins.buildPromise(repository)),
getCurrentWorkspace: jasmine.createSpy('getCurrentWorkspace').andReturn(mixins.buildPromise(workspace)),
getCurrentNode: jasmine.createSpy('getCurrentNode').andReturn(mixins.buildPromise(node)),
};
};

var buildFactoryMock = function() {
return function() {
return {
Expand Down Expand Up @@ -273,7 +263,6 @@ define('mocks', [
getRichTreeFactoryMock: buildFactoryWithPromiseMock(getRichTreeMock()),
getRichTreeMock: getRichTreeMock,
getNodeFactoryMock: buildFactoryMock(),
getJsonPatchMock: getJsonPatchMock,
getRouteParametersConverterMock: getRouteParametersConverterMock
getJsonPatchMock: getJsonPatchMock
};
});
6 changes: 5 additions & 1 deletion tests/unit/services/event-bridge-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/* jshint indent:2 */

define([
'mocks',
'angularMocks',
'app',
'services/event-bridge'
], function () {
], function (mocks) {
'use strict';

describe('Service: EventBridge', function () {
Expand All @@ -18,6 +19,9 @@ define([
beforeEach(inject(function ($injector) {
EventBridge = $injector.get('mbEventBridge');
$rootScope = $injector.get('$rootScope');

// For menu building
$rootScope.currentNode = mocks.getNodeMock();
}));

it('should broadcast events', function () {
Expand Down
72 changes: 0 additions & 72 deletions tests/unit/services/route-parameters-converter-spec.js

This file was deleted.

15 changes: 7 additions & 8 deletions tests/unit/services/tree-cache-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*global define,describe,it,beforeEach,module,inject,expect,jasmine*/
/*global define,describe,it,beforeEach,module,inject,expect*/
/* jshint indent:2 */

define([
Expand All @@ -12,18 +12,15 @@ define([
describe('Service: TreeCache', function () {
var TreeCache,
RichTreeFactory,
RouteParametersConverter,
$rootScope;

// load the service's module
beforeEach(module('browserApp'));
beforeEach(function() {
RichTreeFactory = mocks.getRichTreeFactoryMock();
RouteParametersConverter = mocks.getRouteParametersConverterMock();

module(function ($provide) {
$provide.value('mbRichTreeFactory', RichTreeFactory);
$provide.value('mbRouteParametersConverter', RouteParametersConverter);
});
});

Expand All @@ -32,10 +29,12 @@ define([
$rootScope = $injector.get('$rootScope');
}));

it('should return a RichTree after called getCurrentNode on RouteParametersConverter', function () {
TreeCache.getRichTree().then(function(richTree) {
expect(richTree).toEqual({ getRawTree: jasmine.any(Function) });
expect(RouteParametersConverter.getCurrentNode).toHaveBeenCalled();
it('should build a RichTree after called build on RichTreeFactory', function () {
var node = mocks.getNodeMock();
TreeCache.buildRichTree(node).then(function() {
expect(RichTreeFactory.build).toHaveBeenCalled();
}, function() {
expect(true).toBe(false); // to trigger an error if needed
});
$rootScope.$apply();
});
Expand Down
2 changes: 1 addition & 1 deletion views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

</head>

<body ng-controller="mbFrontCtrl">
<body>
<mb-overlay text="{{ 'LOADING' | translate }}" show-on="_browser.load" hide-on="_browser.loaded"></mb-overlay>
<div class="navbar navbar-default navbar-fixed-top" role="navigation" ng-controller="mbNavbarCtrl">
<div class="navbar-header">
Expand Down
2 changes: 1 addition & 1 deletion web/assets/css/screen.css

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions web/assets/js/browser/controllers/front.js

This file was deleted.

17 changes: 0 additions & 17 deletions web/assets/js/browser/controllers/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ define([
return rawProperties[type].insert(path, datum).then(function() {
reloadProperties();
$translate('NODE_ADD_PROPERTY_SUCCESS').then($log.log, $log.log);
}, function(err) {
if (err.data && err.data.message) { return $log.error(err, err.data.message); }
$log.error(err);
});
}

Expand All @@ -65,10 +62,6 @@ define([
reloadProperties();
$scope.newProperty = {};
$scope.displayCreateForm = false;
}, function(err) {
if (err.data && err.data.message) { return $log.error(err, err.data.message); }
$log.error(err);
return $q.reject(err);
});
};

Expand Down Expand Up @@ -148,10 +141,6 @@ define([
$location.hash('restore');
}
return $translate('NODE_DELETE_PROPERTY_SUCCESS').then($log.log, $log.log);
}, function(err) {
if (err.status === 423) { return $translate('NODE_PROPERTY_LOCKED').then($log.warn, $log.warn); }
else if (err.data && err.data.message) { return $log.error(err, err.data.message); }
$log.error(err);
});
}, $log.error);
};
Expand Down Expand Up @@ -198,19 +187,13 @@ define([
rawProperties[name].update(path, value).then(function() {
reloadProperties();
return $translate('NODE_UPDATE_PROPERTY_SUCCESS').then($log.log, $log.log);
}, function(err) {
if (err.data && err.data.message) { return $log.error(err, err.data.message); }
$log.error(err);
});
};

$scope.updatePropertyType = function(name, type) {
rawProperties[name].setType(type).then(function() {
reloadProperties();
return $translate('NODE_UPDATE_PROPERTY_SUCCESS').then($log.log, $log.log);
}, function(err) {
if (err.data && err.data.message) { return $log.error(err, err.data.message); }
$log.error(err);
});
};

Expand Down
16 changes: 2 additions & 14 deletions web/assets/js/browser/controllers/repositories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,14 @@ define([
], function(app) {
'use strict';

app.controller('mbRepositoriesCtrl', ['$scope', '$location', '$log', '$translate', 'mbObjectMapper',
function($scope, $location, $log, $translate, ObjectMapper) {
app.controller('mbRepositoriesCtrl', ['$scope', '$location',
function($scope, $location) {
$scope.$on('search.change', function(e, value) {
$scope.search = value;
});

$scope.openRepository = function(repository) {
$location.path('/' + repository.getName());
};

$scope.$emit('browser.load');
ObjectMapper.find().then(function(repositories) {
$scope.repositories = repositories;
$scope.$emit('browser.loaded');
}, function(err) {
$translate('ERROR_RETRY', function(translation) {
$log.error(err, translation);
}, function() {
$log.error(err);
});
});
}]);
});
Loading

0 comments on commit 7f4656a

Please sign in to comment.