Skip to content

Commit bd6464b

Browse files
committed
kriskbx#126: Feat: Add noteable title to record
1 parent ec5ca47 commit bd6464b

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
@@ -21,7 +21,7 @@ class time {
2121
* construct
2222
* @param timeString
2323
* @param note
24-
* @param parent
24+
* @param {hasTimes} parent
2525
* @param config
2626
*/
2727
constructor(timeString, date = null, note, parent, config) {
@@ -68,6 +68,15 @@ class time {
6868
return time.toHumanReadable(this.seconds, this._hoursPerDay, this._timeFormat);
6969
}
7070

71+
/**
72+
* Title of the linked Noteable object (Issue/MergeRequest)
73+
*
74+
* @returns {String|null}
75+
*/
76+
get title() {
77+
return this.parent && this.parent.title || null;
78+
}
79+
7180
get _timeFormat() {
7281
return this.config && this.config.get('timeFormat', 'records') ? this.config.get('timeFormat', 'records') : '';
7382
}

0 commit comments

Comments
 (0)