Skip to content

Commit

Permalink
refactor(api): change id params to named params on campaign-route.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-Monney authored Nov 26, 2024
1 parent 35b3434 commit 1011198
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getGroups = async function (request) {

const getAnalysis = async function (request, h, dependencies = { campaignAnalysisSerializer }) {
const { userId } = request.auth.credentials;
const campaignId = request.params.id;
const { campaignId } = request.params;
const locale = extractLocaleFromRequest(request);
const campaignAnalysis = await usecases.computeCampaignAnalysis({ userId, campaignId, locale });
return dependencies.campaignAnalysisSerializer.serialize(campaignAnalysis);
Expand Down
4 changes: 2 additions & 2 deletions api/src/prescription/campaign/application/campaign-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const register = async function (server) {
},
{
method: 'GET',
path: '/api/campaigns/{id}/analyses',
path: '/api/campaigns/{campaignId}/analyses',
config: {
validate: {
params: Joi.object({
id: identifiersType.campaignId,
campaignId: identifiersType.campaignId,
}),
},
handler: campaignController.getAnalysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Acceptance | API | Campaign Controller', function () {
server = await createServer();
});

describe('PATCH /api/campaigns/{id}', function () {
describe('PATCH /api/campaigns/{campaignId}', function () {
it('should return 200 when user is admin but not owner of the campaign', async function () {
// given
const organization = databaseBuilder.factory.buildOrganization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Acceptance | API | Campaign Route', function () {
});
});

describe('GET /api/campaigns/{id}/analyses', function () {
describe('GET /api/campaigns/{campaignId}/analyses', function () {
let userId, organization, campaign;

describe('skill Ids provide by the campaign', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Unit | Application | Controller | Campaign', function () {

const request = {
auth: { credentials: { userId } },
params: { id: campaignId },
params: { campaignId },
headers: { 'accept-language': locale },
};

Expand All @@ -46,7 +46,7 @@ describe('Unit | Application | Controller | Campaign', function () {
// given
const error = new UserNotAuthorizedToAccessEntityError('User does not have access to this campaign');
const request = {
params: { id: campaignId },
params: { campaignId },
auth: {
credentials: { userId },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Unit | Application | Router | campaign-router ', function () {
});
});

describe('GET /api/campaigns/{id}/analyses', function () {
describe('GET /api/campaigns/{campaignId}/analyses', function () {
it('should return 200', async function () {
// given
sinon.stub(campaignController, 'getAnalysis').callsFake((request, h) => h.response('ok').code(200));
Expand Down

0 comments on commit 1011198

Please sign in to comment.