Skip to content

Commit 868185a

Browse files
committed
Feat: Add noteable title to record
1 parent 6a3988a commit 868185a

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ mergeRequestColumns:
558558
recordColumns:
559559
- user
560560
- iid
561+
- title
561562
- time
562563

563564
# Add columns for each project member to issue and

spec/models/time.title.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const moment = require('moment');
2+
const Config = require('../../src/include/config');
3+
const Time = require('./../../src/models/time');
4+
const issue = require('../../src/models/issue');
5+
const mergeRequest = require('../../src/models/mergeRequest');
6+
const expect = require('chai').expect;
7+
8+
describe('time class', () => {
9+
it('Returns title of parent Issue', () => {
10+
const config = new Config();
11+
const parent = new issue(config, {title: "Test title"})
12+
const time = new Time('1h', moment(), {}, parent, config);
13+
14+
expect(time.title).to.be.equal("Test title");
15+
});
16+
17+
it('Returns title of parent MergeRequest', () => {
18+
const config = new Config();
19+
const parent = new mergeRequest(config, {title: "Test title"})
20+
const time = new Time('1h', moment(), {}, parent, config);
21+
22+
expect(time.title).to.be.equal("Test title");
23+
});
24+
25+
it('Returns Null for missed title or parent', () => {
26+
const config = new Config();
27+
const parent = new mergeRequest(config, {});
28+
let time;
29+
time = new Time('1h', moment(), {}, parent, config);
30+
expect(time.title).to.be.equal(null);
31+
32+
time = new Time('1h', moment(), {}, null, config);
33+
expect(time.title).to.be.equal(null);
34+
});
35+
});
36+

src/models/time.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class time {
2828
* construct
2929
* @param timeString
3030
* @param note
31-
* @param parent
31+
* @param {hasTimes} parent
3232
* @param config
3333
*/
3434
constructor(timeString, date = null, note, parent, config) {
@@ -75,6 +75,15 @@ class time {
7575
return time.toHumanReadable(this.seconds, this._hoursPerDay, this._timeFormat);
7676
}
7777

78+
/**
79+
* Title of the linked Noteable object (Issue/MergeRequest)
80+
*
81+
* @returns {String|null}
82+
*/
83+
get title() {
84+
return this.parent && this.parent.title || null;
85+
}
86+
7887
get _timeFormat() {
7988
return this.config && this.config.get('timeFormat', 'records') ? this.config.get('timeFormat', 'records') : '';
8089
}

0 commit comments

Comments
 (0)