Turn off global ajaxError handler in afterEach in teams tab factory specs.
This commit is contained in:
committed by
Clinton Blackburn
parent
d851b2c951
commit
a6635bb884
@@ -1,6 +1,6 @@
|
||||
define(['jquery', 'backbone', 'teams/js/teams_tab_factory',
|
||||
define(['jquery', 'backbone', 'teams/js/teams_tab_factory', 'teams/js/views/teams_tab',
|
||||
'common/js/spec_helpers/page_helpers', 'teams/js/spec_helpers/team_spec_helpers'],
|
||||
function($, Backbone, TeamsTabFactory, PageHelpers, TeamSpecHelpers) {
|
||||
function($, Backbone, TeamsTabFactory, TeamsTabView, PageHelpers, TeamSpecHelpers) {
|
||||
'use strict';
|
||||
|
||||
describe("Teams Tab Factory", function() {
|
||||
@@ -15,6 +15,7 @@ define(['jquery', 'backbone', 'teams/js/teams_tab_factory',
|
||||
|
||||
afterEach(function() {
|
||||
Backbone.history.stop();
|
||||
$(document).off('ajaxError', TeamsTabView.prototype.errorHandler);
|
||||
});
|
||||
|
||||
it('can render the "Teams" tab', function() {
|
||||
|
||||
@@ -56,7 +56,11 @@ define([
|
||||
spyOn(Logger, 'log');
|
||||
});
|
||||
|
||||
afterEach(Backbone.history.stop);
|
||||
afterEach(function() {
|
||||
Backbone.history.stop();
|
||||
$(document).off('ajaxError', TeamsTabView.prototype.errorHandler);
|
||||
}
|
||||
);
|
||||
|
||||
describe('Navigation', function () {
|
||||
it('does not render breadcrumbs for the top level tabs', function() {
|
||||
|
||||
@@ -159,14 +159,7 @@
|
||||
start: function() {
|
||||
Backbone.history.start();
|
||||
|
||||
$(document).ajaxError(function (event, xhr) {
|
||||
if (xhr.status === 401) {
|
||||
TeamUtils.showMessage(gettext("Your request could not be completed. Reload the page and try again."));
|
||||
}
|
||||
else if (xhr.status === 500) {
|
||||
TeamUtils.showMessage(gettext("Your request could not be completed due to a server problem. Reload the page and try again. If the issue persists, click the Help tab to report the problem."));
|
||||
}
|
||||
});
|
||||
$(document).ajaxError(this.errorHandler);
|
||||
|
||||
// Navigate to the default page if there is no history:
|
||||
// 1. If the user belongs to at least one team, jump to the "My Teams" page
|
||||
@@ -180,6 +173,20 @@
|
||||
}
|
||||
},
|
||||
|
||||
errorHandler: function(event, xhr) {
|
||||
if (xhr.status === 401) {
|
||||
TeamUtils.showMessage(gettext(
|
||||
"Your request could not be completed. Reload the page and try again."
|
||||
));
|
||||
}
|
||||
else if (xhr.status === 500) {
|
||||
TeamUtils.showMessage(gettext(
|
||||
"Your request could not be completed due to a server problem. Reload the page" +
|
||||
" and try again. If the issue persists, click the Help tab to report the problem."
|
||||
));
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.mainView.setElement(this.$el).render();
|
||||
TeamUtils.hideMessage();
|
||||
|
||||
Reference in New Issue
Block a user