Unverified Commit af0b206b authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #676 from hypothesis/pass-authority-when-fetching-groups

Pass "authority" query param when fetching groups list
parents 218177ad c5436e3d
......@@ -15,9 +15,11 @@ var STORAGE_KEY = 'hypothesis.groups.focus';
var events = require('./events');
var { awaitStateChange } = require('./util/state-util');
var serviceConfig = require('./service-config');
// @ngInject
function groups(annotationUI, isSidebar, localStorage, serviceUrl, session, $rootScope, store) {
function groups(annotationUI, isSidebar, localStorage, serviceUrl, session,
settings, $rootScope, store) {
// The currently focused group. This is the group that's shown as selected in
// the groups dropdown, the annotations displayed are filtered to only ones
// that belong to this group, and any new annotations that the user creates
......@@ -26,6 +28,9 @@ function groups(annotationUI, isSidebar, localStorage, serviceUrl, session, $roo
var groups = [];
var documentUri;
var svc = serviceConfig(settings);
var authority = svc ? svc.authority : null;
function getDocumentUriForGroupSearch() {
function mainUri() {
var uris = annotationUI.searchUris();
......@@ -54,6 +59,9 @@ function groups(annotationUI, isSidebar, localStorage, serviceUrl, session, $roo
}
return uri.then(uri => {
var params = {};
if (authority) {
params.authority = authority;
}
if (uri) {
params.document_uri = uri;
}
......
......@@ -16,6 +16,7 @@ describe('groups', function() {
var fakeAnnotationUI;
var fakeIsSidebar;
var fakeSession;
var fakeSettings;
var fakeStore;
var fakeLocalStorage;
var fakeRootScope;
......@@ -68,6 +69,7 @@ describe('groups', function() {
},
};
fakeServiceUrl = sandbox.stub();
fakeSettings = {};
});
afterEach(function () {
......@@ -76,7 +78,7 @@ describe('groups', function() {
function service() {
return groups(fakeAnnotationUI, fakeIsSidebar, fakeLocalStorage, fakeServiceUrl, fakeSession,
fakeRootScope, fakeStore);
fakeSettings, fakeRootScope, fakeStore);
}
describe('#all()', function() {
......@@ -155,6 +157,14 @@ describe('groups', function() {
});
});
});
it('passes authority argument when using a third-party authority', () => {
fakeSettings.services = [{ authority: 'publisher.org' }];
var svc = service();
return svc.load().then(() => {
assert.calledWith(fakeStore.groups.list, sinon.match({ authority: 'publisher.org' }));
});
});
});
describe('#get() method', function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment