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

Detect baseline changes from null to something

Oliver Günther1432edd75ea7
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts
index 9a11af9c535..584a233aa24 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service.ts
@@ -150,7 +150,9 @@ export class WorkPackageViewBaselineService extends WorkPackageQueryStateService
public isChanged(workPackage:WorkPackageResource, attribute:string):boolean {
const timestamps = workPackage.attributesByTimestamp || [];
- return this.isActive() && timestamps.length >= 1 && !!timestamps[0][attribute as keyof IWorkPackageTimestamp];
+ return this.isActive()
+ && timestamps.length >= 1
+ && Object.prototype.hasOwnProperty.call(timestamps[0], attribute);
}
public valueFromQuery(query:QueryResource):string[] {
diff --git a/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb b/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
index 0183b29cf65..f8d82a89788 100644
--- a/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
+++ b/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
@@ -113,6 +113,23 @@ RSpec.describe 'baseline rendering',
end
end
+ shared_let(:wp_task_assigned) do
+ wp = Timecop.travel(5.days.ago) do
+ create(:work_package,
+ project:,
+ type: type_task,
+ assigned_to: nil)
+ end
+
+ Timecop.travel(1.day.ago) do
+ WorkPackages::UpdateService
+ .new(user:, model: wp)
+ .call(assigned_to: user)
+ .on_failure { |result| raise result.message }
+ .result
+ end
+ end
+
shared_let(:wp_task_was_bug) do
wp = Timecop.travel(5.days.ago) do
create(:work_package, project:, type: type_bug, subject: 'Bug changed to Task')
@@ -163,13 +180,14 @@ RSpec.describe 'baseline rendering',
describe 'with feature enabled', with_ee: %i[baseline_comparison], with_flag: { show_changes: true } do
it 'does show changes' do
wp_table.visit_query(query)
- wp_table.expect_work_package_listed wp_task, wp_task_changed, wp_task_was_bug, wp_bug_was_task
+ wp_table.expect_work_package_listed wp_task, wp_task_changed, wp_task_was_bug, wp_bug_was_task, wp_task_assigned
wp_table.ensure_work_package_not_listed! wp_bug
baseline.expect_active
baseline.expect_added wp_task_was_bug
baseline.expect_removed wp_bug_was_task
baseline.expect_changed wp_task_changed
+ baseline.expect_changed wp_task_assigned
baseline.expect_unchanged wp_task
baseline.expect_changed_attributes wp_task_was_bug,
@@ -187,6 +205,9 @@ RSpec.describe 'baseline rendering',
assignee: ['Assigned User', 'Itsa Me'],
responsible: ['Assigned User', 'Itsa Me']
+ baseline.expect_changed_attributes wp_task_assigned,
+ assignee: ['-', 'Itsa Me']
+
baseline.expect_unchanged_attributes wp_task_changed, :type
baseline.expect_unchanged_attributes wp_task,
:type, :subject, :start_date, :due_date,