Merge branch 'master' of github.com:mozilla/FlightDeck

This commit is contained in:
Piotr Zalewa 2012-03-08 10:45:03 +01:00
Родитель cb78712b8e 3ec1e71154
Коммит 58a01b2e28
2 изменённых файлов: 39 добавлений и 6 удалений

Просмотреть файл

@ -203,6 +203,26 @@ class PackageRevisionTest(TestCase):
john_lib2.latest.dependency_add(jan_conflict.latest) john_lib2.latest.dependency_add(jan_conflict.latest)
self.assertRaises(DependencyException, addon.dependency_add, john_lib2.latest) self.assertRaises(DependencyException, addon.dependency_add, john_lib2.latest)
def test_adding_libs_with_common_dependency(self):
# if B and C both depend on D, at the same version, then it should
# be able to add both to A
addon = Package(author=self.author, type='a')
addon.save()
lib1 = Package(author=self.author, type='l')
lib1.save()
lib2 = Package(author=self.author, type='l')
lib2.save()
lib3 = Package(author=self.author, type='l')
lib3.save()
lib1.latest.dependency_add(lib3.latest)
lib2.latest.dependency_add(lib3.latest)
addon.latest.dependency_add(lib1.latest)
addon.latest.dependency_add(lib2.latest)
assert True
def test_adding_library_self(self): def test_adding_library_self(self):
" Check recurrent dependency (one level only) " " Check recurrent dependency (one level only) "
lib = self.library.latest lib = self.library.latest

Просмотреть файл

@ -3,19 +3,22 @@
var Request = require('shipyard/http/Request'), var Request = require('shipyard/http/Request'),
Cookie = require('shipyard/utils/Cookie'), Cookie = require('shipyard/utils/Cookie'),
log = require('shipyard/utils/log'), log = require('shipyard/utils/log'),
dom = require('shipyard/dom'), dom = require('shipyard/dom');
fd = dom.window.get('fd'); function fd() {
return dom.window.get('fd');
}
Request.prototype.options.headers['X-CSRFToken'] = Cookie.read('csrftoken'); Request.prototype.options.headers['X-CSRFToken'] = Cookie.read('csrftoken');
Request.prototype.options.onFailure = function(text) { var oldInit = Request.prototype.initialize;
var defaultFailure = function(text) {
if (this.status !== 0 && text) { if (this.status !== 0 && text) {
var response; var response;
try { try {
response = JSON.parse(text); response = JSON.parse(text);
} catch (notJSON) { } catch (notJSON) {
log.warn('Response error is not valid JSON', text); log.warn('Response error is not valid JSON');
if (text.indexOf('<html') !== -1) { if (text.indexOf('<html') !== -1) {
// We somehow got a full HTML page. Bad! // We somehow got a full HTML page. Bad!
log.error('Response is an HTML page!'); log.error('Response is an HTML page!');
@ -26,6 +29,16 @@ Request.prototype.options.onFailure = function(text) {
} }
} }
fd.error.alert(this.xhr.statusText, response); fd().error.alert(this.xhr.statusText, response);
} }
}; };
Request.implement('initialize', function FD_Request(options) {
if (!options) {
options = {};
}
if (!options.onFailure) {
options.onFailure = defaultFailure;
}
oldInit.call(this, options);
});