diff --git a/app/assets/javascripts/search/store/actions.js b/app/assets/javascripts/search/store/actions.js index ee5e778f63d6c47c1b2a383b49d4ff32b6c65f61..be64a9278e30c2705d7649ab8aba76a3c6d464ef 100644 --- a/app/assets/javascripts/search/store/actions.js +++ b/app/assets/javascripts/search/store/actions.js @@ -40,7 +40,7 @@ export const fetchProjects = ({ commit, state }, search) => { ); } else { // The .catch() is due to the API method not handling a rejection properly - Api.projects(search, { order_by: 'id' }, callback).catch(() => { + Api.projects(search, { order_by: 'similarity' }, callback).catch(() => { callback(); }); } diff --git a/spec/frontend/search/store/actions_spec.js b/spec/frontend/search/store/actions_spec.js index 9f8c83f28737e48c796a827ba6e7f274e3f27aa8..b50248bb2955a1ff64f7c35a1700a9864f8a875c 100644 --- a/spec/frontend/search/store/actions_spec.js +++ b/spec/frontend/search/store/actions_spec.js @@ -142,7 +142,13 @@ describe('Global Search Store Actions', () => { actions.fetchProjects({ commit: mockCommit, state }); expect(Api.groupProjects).not.toHaveBeenCalled(); - expect(Api.projects).toHaveBeenCalled(); + expect(Api.projects).toHaveBeenCalledWith( + state.query.search, + { + order_by: 'similarity', + }, + expect.any(Function), + ); }); }); });