Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

linting

ulfertsdc535dc83a7d
diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rb
index aa061b049ce..5c2f94795d9 100644
--- a/app/services/journals/create_service.rb
+++ b/app/services/journals/create_service.rb
@@ -108,9 +108,10 @@ module Journals
# (i.e. when determining the latest state of the journable and when getting the current version number).
#
# The second CTE (`changes`) determines whether a change as occurred so that a new journal needs to be created. The next CTE,
- # that will insert new data, will only do so if the changes CTE returns an entry. The only two exceptions to this check is that
- # if a note is provided or a predecessor is replaced, a journal will be created regardless of whether any changes are detected.
- # To determine whether a change is worthy of being journalized, the current and the latest journalized state are compared in three aspects:
+ # that will insert new data, will only do so if the changes CTE returns an entry. The only two exceptions to this check is
+ # that if a note is provided or a predecessor is replaced, a journal will be created regardless of whether any changes are
+ # detected. To determine whether a change is worthy of being journalized, the current and the latest journalized state are
+ # compared in three aspects:
# * the journable's table columns are compared to the columns in the journable's journal data table
# (e.g. work_package_journals for WorkPackages). Only columns that exist in the journable's journal data table are considered
# (and some columns like the primary key `id` is ignored). Therefore, to add an attribute to be journalized, it needs to
@@ -121,11 +122,12 @@ module Journals
# When comparing text based values, newlines are normalized as otherwise users having a different OS might change a text value
# without intending to.
#
- # Only if a change has been identified (or if a note/predecessor is present) is a journal inserted by the third CTE (`insert_journal`).
- # Its creation timestamp will be the updated_at value of the journable as this is the logical creation time. If a note is present,
- # however, the current time is taken as it signifies an action in itself and there might not be a change at all. In such a
- # case, the journable will later on receive the creation date of the journal as its updated_at value. The update timestamp of
- # a journable and the creation date of its most recent journal should always be in sync.
+ # Only if a change has been identified (or if a note/predecessor is present) is a journal inserted by the
+ # third CTE (`insert_journal`). Its creation timestamp will be the updated_at value of the journable as this is the
+ # logical creation time. If a note is present, however, the current time is taken as it signifies an action in itself and
+ # there might not be a change at all. In such a case, the journable will later on receive the creation date of the
+ # journal as its updated_at value. The update timestamp of a journable and the creation date of its most recent
+ # journal should always be in sync.
#
# Both cases (having a note or a change) can at this point be identified by a journal having been created. Therefore, the
# return value of that insert statement is further on used to identify whether the next statements (`insert_data`,
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
index f39df688d64..82b62949a39 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
@@ -27,6 +27,7 @@
//++
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
+import { HalResource } from 'core-app/features/hal/resources/hal-resource';
export class ActivityEntryInfo {
public date = this.activityDate(this.activity);
@@ -38,28 +39,28 @@ export class ActivityEntryInfo {
constructor(public timezoneService:TimezoneService,
public isReversed:boolean,
public activities:any[],
- public activity:any,
+ public activity:HalResource,
public index:number) {
}
- public number(forceReverse = false) {
+ public number(forceReverse = false):number {
return this.orderedIndex(this.index, forceReverse);
}
- public get href() {
- return this.activity.href;
+ public get href():string {
+ return this.activity.href as string;
}
- public get identifier() {
+ public get identifier():string {
return `${this.href}-${this.version}-${this.updatedAt}`;
}
- public get version() {
- return this.activity.version;
+ public get version():number {
+ return this.activity.version as number;
}
- public get updatedAt() {
- return this.activity.updatedAt;
+ public get updatedAt():string {
+ return this.activity.updatedAt as string;
}
public isInitial(forceReverse = false) {
diff --git a/modules/backlogs/spec/models/burndown_spec.rb b/modules/backlogs/spec/models/burndown_spec.rb
index 603a2424aac..ffb8461a159 100644
--- a/modules/backlogs/spec/models/burndown_spec.rb
+++ b/modules/backlogs/spec/models/burndown_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Burndown, type: :model do
def set_attribute_journalized(story, attribute, value, day)
@@ -36,33 +36,31 @@ describe Burndown, type: :model do
story.last_journal.update(created_at: day, updated_at: day)
end
- let(:user) { @user ||= create(:user) }
- let(:role) { @role ||= create(:role) }
- let(:type_feature) { @type_feature ||= create(:type_feature) }
- let(:type_task) { @type_task ||= create(:type_task) }
- let(:issue_priority) { @issue_priority ||= create(:priority, is_default: true) }
- let(:version) { @version ||= create(:version, project:) }
- let(:sprint) { @sprint ||= Sprint.find(version.id) }
+ let(:user) { create(:user) }
+ let(:role) { create(:role) }
+ let(:type_feature) { create(:type_feature) }
+ let(:type_task) { create(:type_task) }
+ let(:issue_priority) { create(:priority, is_default: true) }
+ let(:version) { create(:version, project:) }
+ let(:sprint) { Sprint.find(version.id) }
let(:project) do
- unless @project
- @project = build(:project)
- @project.members = [build(:member, principal: user,
- project: @project,
- roles: [role])]
- @project.versions << version
- end
- @project
+ project = build(:project)
+ project.members = [build(:member,
+ principal: user,
+ project:,
+ roles: [role])]
+ project
end
- let(:issue_open) { @status1 ||= create(:status, name: 'status 1', is_default: true) }
- let(:issue_closed) { @status2 ||= create(:status, name: 'status 2', is_closed: true) }
- let(:issue_resolved) { @status3 ||= create(:status, name: 'status 3', is_closed: false) }
+ let(:issue_open) { create(:status, name: 'status 1', is_default: true) }
+ let(:issue_closed) { create(:status, name: 'status 2', is_closed: true) }
+ let(:issue_resolved) { create(:status, name: 'status 3', is_closed: false) }
before do
Rails.cache.clear
- allow(User).to receive(:current).and_return(user)
+ login_as(user)
allow(Setting).to receive(:plugin_openproject_backlogs).and_return({ 'points_burn_direction' => 'down',
'wiki_template' => '',
@@ -90,8 +88,8 @@ describe Burndown, type: :model do
describe 'WITH having a version in the future' do
before do
- version.start_date = Date.today + 1.day
- version.effective_date = Date.today + 6.days
+ version.start_date = Time.zone.today + 1.day
+ version.effective_date = Time.zone.today + 6.days
version.save!
end
@@ -102,8 +100,8 @@ describe Burndown, type: :model do
describe 'WITH having a 10 (working days) sprint and being 5 (working) days into it' do
before do
- version.start_date = Date.today - 7.days
- version.effective_date = Date.today + 6.days
+ version.start_date = Time.zone.today - 7.days
+ version.effective_date = Time.zone.today + 6.days
version.save!
end
@@ -115,8 +113,8 @@ describe Burndown, type: :model do
type: type_feature,
status: issue_open,
priority: issue_priority,
- created_at: Date.today - 20.days,
- updated_at: Date.today - 20.days)
+ created_at: Time.zone.today - 20.days,
+ updated_at: Time.zone.today - 20.days)
end
describe 'WITH the story having story_point defined on creation' do
@@ -126,13 +124,12 @@ describe Burndown, type: :model do
story.last_journal.update_columns(created_at: story.created_at, updated_at: story.created_at)
end
- subject(:burndown) { Burndown.new(sprint, project) }
+ subject(:burndown) { described_class.new(sprint, project) }
describe 'WITH the story being closed and opened again within the sprint duration' do
-
before do
- set_attribute_journalized story, :status_id=, issue_closed.id, Time.now - 6.days
- set_attribute_journalized story, :status_id=, issue_open.id, Time.now - 3.days
+ set_attribute_journalized story, :status_id=, issue_closed.id, 6.days.ago
+ set_attribute_journalized story, :status_id=, issue_open.id, 3.days.ago
end
it { expect(burndown.story_points).to eql [9.0, 0.0, 0.0, 0.0, 9.0, 9.0] }
@@ -145,8 +142,8 @@ describe Burndown, type: :model do
describe "WITH the story marked as resolved and consequently 'done'" do
before do
- set_attribute_journalized story, :status_id=, issue_resolved.id, Time.now - 6.days
- set_attribute_journalized story, :status_id=, issue_open.id, Time.now - 3.days
+ set_attribute_journalized story, :status_id=, issue_resolved.id, 6.days.ago
+ set_attribute_journalized story, :status_id=, issue_open.id, 3.days.ago
project.done_statuses << issue_resolved
end
@@ -167,8 +164,8 @@ describe Burndown, type: :model do
type: type_feature,
status: issue_open,
priority: issue_priority,
- created_at: Date.today - (20 - i).days,
- updated_at: Date.today - (20 - i).days)
+ created_at: Time.zone.today - (20 - i).days,
+ updated_at: Time.zone.today - (20 - i).days)
stories[i].last_journal.update_columns(created_at: stories[i].created_at, updated_at: stories[i].created_at)
end
@@ -190,7 +187,7 @@ describe Burndown, type: :model do
end
describe 'THEN' do
- subject(:burndown) { Burndown.new(sprint, project) }
+ subject(:burndown) { described_class.new(sprint, project) }
it { expect(burndown.story_points).to eql [90.0, 80.0, 70.0, 60.0, 50.0, 50.0] }
it { expect(burndown.story_points.unit).to be :points }