diff --git a/src/actions/fragments.js b/src/actions/fragments.js index d3644df5751bca9a9f51f74305d6d8d1644592a5..0f9197be1c6a1590c50336c3fcd233effe358f11 100644 --- a/src/actions/fragments.js +++ b/src/actions/fragments.js @@ -2,19 +2,10 @@ import * as api from '../helpers/api' import * as T from './types' export const fragmentUrl = (collection, fragment) => { - let url = `/collections/${collection.id}/fragments` - - if (fragment.id) url += `/${fragment.id}` - - return url -} - -export const collectionUrl = (collection, suffix) => { - let url = '/collections' - - if (collection) url += `/${collection.id}` - - if (suffix) url += `/${suffix}` + let url = '' + if (collection) url += `/collections/${collection.id}` + url += '/fragments' + if (fragment && fragment.id) url += `/${fragment.id}` return url } @@ -46,7 +37,7 @@ export function getFragments(collection, options) { return dispatch => { dispatch(getFragmentsRequest(collection)) - let url = collectionUrl(collection, 'fragments') + let url = fragmentUrl(collection) if (options && options.fields) { url += '?fields=' + encodeURIComponent(options.fields.join(',')) diff --git a/test/actions/fragments.test.js b/test/actions/fragments.test.js index e083c2ae7f04a2fc7030304447bbe9a60e6622c8..97c50fb914c1e0c96643f5b141130ca7549da857 100644 --- a/test/actions/fragments.test.js +++ b/test/actions/fragments.test.js @@ -36,7 +36,8 @@ describe('fragments actions', () => { }) describeAction('createFragment', { - firstarg: mockcol, + // no collection routes to top level fragment endpoint + firstarg: null, secondarg: { title: 'mock fragment', type: 'some_fragment',