summaryrefslogtreecommitdiff
path: root/spec/frontend_integration/test_helpers/mock_server/routes/projects.js
blob: de37aa98eeebffdd99cd5050de39ecb0a029bec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { withKeys } from 'test_helpers/utils/obj';

export default (server) => {
  server.get('/api/v4/projects/:id', (schema, request) => {
    const { id } = request.params;

    const proj =
      schema.projects.findBy({ id }) ?? schema.projects.findBy({ path_with_namespace: id });

    return proj.attrs;
  });

  server.get('/api/v4/projects/:id/merge_requests', (schema, request) => {
    const result = schema.mergeRequests.where(
      withKeys(request.queryParams, {
        source_project_id: 'project_id',
        source_branch: 'source_branch',
      }),
    );

    return result.models;
  });
};