Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ mergeRequestColumns:
recordColumns:
- user
- iid
- title
- time

# Add columns for each project member to issue and
Expand Down
36 changes: 36 additions & 0 deletions spec/models/time.title.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const moment = require('moment');
const Config = require('../../src/include/config');
const Time = require('./../../src/models/time');
const issue = require('../../src/models/issue');
const mergeRequest = require('../../src/models/mergeRequest');
const expect = require('chai').expect;

describe('time class', () => {
it('Returns title of parent Issue', () => {
const config = new Config();
const parent = new issue(config, {title: "Test title"})
const time = new Time('1h', moment(), {}, parent, config);

expect(time.title).to.be.equal("Test title");
});

it('Returns title of parent MergeRequest', () => {
const config = new Config();
const parent = new mergeRequest(config, {title: "Test title"})
const time = new Time('1h', moment(), {}, parent, config);

expect(time.title).to.be.equal("Test title");
});

it('Returns Null for missed title or parent', () => {
const config = new Config();
const parent = new mergeRequest(config, {});
let time;
time = new Time('1h', moment(), {}, parent, config);
expect(time.title).to.be.equal(null);

time = new Time('1h', moment(), {}, null, config);
expect(time.title).to.be.equal(null);
});
});

11 changes: 10 additions & 1 deletion src/models/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class time {
* construct
* @param timeString
* @param note
* @param parent
* @param {hasTimes} parent
* @param config
*/
constructor(timeString, date = null, note, parent, config) {
Expand Down Expand Up @@ -68,6 +68,15 @@ class time {
return time.toHumanReadable(this.seconds, this._hoursPerDay, this._timeFormat);
}

/**
* Title of the linked Noteable object (Issue/MergeRequest)
*
* @returns {String|null}
*/
get title() {
return this.parent && this.parent.title || null;
}

get _timeFormat() {
return this.config && this.config.get('timeFormat', 'records') ? this.config.get('timeFormat', 'records') : '';
}
Expand Down