Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use params instead of headers #266

Merged
merged 12 commits into from
May 7, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ describe('CreateF3XStep1Component', () => {
it('#save should save a new f3x record', () => {
component.form.patchValue({ ...f3x });
component.save();
const req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/`);
const req = httpTestingController.expectOne(
`${environment.apiUrl}/f3x-summaries/?fields_to_validate=filing_frequency,report_type_category,report_code,coverage_from_date,coverage_through_date,date_of_election,state_of_election,form_type`
);
expect(req.request.method).toEqual('POST');
httpTestingController.verify();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ describe('CreateF3xStep2Component', () => {
component.form.patchValue({ change_of_address: 'X' });

component.save('back');
let req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/${component.report.id}/`);
let req = httpTestingController.expectOne(
`${environment.apiUrl}/f3x-summaries/${component.report.id}/?fields_to_validate=change_of_address,street_1,street_2,city,state,zip,memo_checkbox,memo`
);
expect(req.request.method).toEqual('PUT');
req.flush(component.report);
expect(navigateSpy).toHaveBeenCalledWith('/reports');

navigateSpy.calls.reset();
component.save('continue');
req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/${component.report.id}/`);
req = httpTestingController.expectOne(
`${environment.apiUrl}/f3x-summaries/${component.report.id}/?fields_to_validate=change_of_address,street_1,street_2,city,state,zip,memo_checkbox,memo`
);
expect(req.request.method).toEqual('PUT');
req.flush(component.report);
expect(navigateSpy).toHaveBeenCalledWith('/reports');
Expand Down
6 changes: 4 additions & 2 deletions front-end/src/app/shared/services/f3x-summary.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('F3xSummaryService', () => {
expect(response).toEqual(f3xSummary);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/?fields_to_validate=`);
expect(req.request.method).toEqual('POST');
req.flush(f3xSummary);
httpTestingController.verify();
Expand All @@ -70,7 +70,9 @@ describe('F3xSummaryService', () => {
expect(response).toEqual(f3xSummary);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/f3x-summaries/${f3xSummary.id}/`);
const req = httpTestingController.expectOne(
`${environment.apiUrl}/f3x-summaries/${f3xSummary.id}/?fields_to_validate=`
);
expect(req.request.method).toEqual('PUT');
req.flush(f3xSummary);
httpTestingController.verify();
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/services/f3x-summary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export class F3xSummaryService {
public create(f3xSummary: F3xSummary, fieldsToValidate: string[] = []): Observable<F3xSummary> {
const payload = f3xSummary.toJson();
return this.apiService
.post<F3xSummary>(`/f3x-summaries/`, payload, { fields_to_validate: fieldsToValidate })
.post<F3xSummary>(`/f3x-summaries/?fields_to_validate=${fieldsToValidate}`, payload)
.pipe(map((response) => F3xSummary.fromJSON(response)));
}
toddlees marked this conversation as resolved.
Show resolved Hide resolved

public update(f3xSummary: F3xSummary, fieldsToValidate: string[] = []): Observable<F3xSummary> {
const payload = f3xSummary.toJson();
return this.apiService
.put<F3xSummary>(`/f3x-summaries/${f3xSummary.id}/`, payload, { fields_to_validate: fieldsToValidate })
.put<F3xSummary>(`/f3x-summaries/${f3xSummary.id}/?fields_to_validate=${fieldsToValidate}`, payload)
.pipe(map((response) => F3xSummary.fromJSON(response)));
}

Expand Down