Skip to content

Commit 4576853

Browse files
authored
Merge pull request #8170 from michaelchadwick/frontend-4934-prog-year-report-fix
Reports->Terms->Program Year title fixed
2 parents bdaa1df + 710c8ab commit 4576853

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

packages/frontend/app/services/reporting.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,16 @@ export default class ReportingService extends Service {
102102
const objectKey = objectTranslations[prepositionalObject];
103103
const objectTranslation = this.intl.t(objectKey);
104104
let object;
105+
105106
if (model === 'user') {
106107
object = record.fullName;
107108
} else if (model === 'mesh-descriptor') {
108109
object = record.name;
110+
} else if (model === 'program-year') {
111+
const program = await record.program;
112+
const title = program.title;
113+
const classOfYear = await record.getClassOfYear();
114+
object = `${classOfYear} ${title}`;
109115
} else {
110116
object = record.title;
111117
}

packages/frontend/tests/unit/services/reporting-test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { module, test } from 'qunit';
22
import { setupTest } from 'ember-qunit';
33
import { setupIntl } from 'ember-intl/test-support';
44
import { setupMirage } from 'frontend/tests/test-support/mirage';
5+
import { DateTime } from 'luxon';
56

67
module('Unit | Service | reporting', function (hooks) {
78
setupTest(hooks);
@@ -226,6 +227,45 @@ module('Unit | Service | reporting', function (hooks) {
226227
);
227228
});
228229

230+
test('buildReportDescription() - all terms for program year X in school Y', async function (assert) {
231+
const school = this.server.create('school', { title: 'School of Schools' });
232+
const program = this.server.create('program', { school: school });
233+
const programYear = this.server.create('program-year', {
234+
program,
235+
startYear: DateTime.now().year,
236+
});
237+
const vocabulary = this.server.create('vocabulary', { school });
238+
this.server.create('term', {
239+
title: 'foo bar',
240+
programYears: [programYear],
241+
vocabulary,
242+
});
243+
const report = this.server.create('report', {
244+
subject: 'term',
245+
prepositionalObject: 'program year',
246+
prepositionalObjectTableRowId: programYear.id,
247+
school,
248+
});
249+
250+
const store = this.owner.lookup('service:store');
251+
const reportModel = await store.findRecord('report', report.id);
252+
const programYearModel = await store.findRecord('program year', programYear.id);
253+
const schoolModel = await store.findRecord('school', school.id);
254+
const title = await this.service.buildReportDescription(
255+
reportModel.subject,
256+
reportModel.prepositionalObject,
257+
reportModel.prepositionalObjectTableRowId,
258+
school,
259+
);
260+
const classOfYear = await programYearModel.getClassOfYear();
261+
const programYearTitle = `${classOfYear} ${program.title}`;
262+
263+
assert.strictEqual(
264+
title,
265+
`This report shows all Terms associated with Program Year "${programYearTitle}" in ${schoolModel.title}.`,
266+
);
267+
});
268+
229269
test('buildReportDescription() - broken report', async function (assert) {
230270
const school = this.server.create('school', { title: 'School of Schools' });
231271
const report = this.server.create('report', {

0 commit comments

Comments
 (0)