Skip to content

Commit dea0e61

Browse files
committed
Adds a couple of missing fields
1 parent 308b152 commit dea0e61

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/models/types/patterns/token_property_mapper.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,22 @@ class TokenPropertyMapper
3737
context.public_send(key.to_sym)
3838
end.curry
3939

40+
# Parent ID <- Is tagged as Parent
41+
4042
TOKEN_PROPERTY_MAP = IceNine.deep_freeze(
4143
{
44+
id: { fn: ->(wp) { wp.id }, label: -> { WorkPackage.human_attribute_name(:id) } },
4245
accountable: { fn: ->(wp) { wp.responsible&.name }, label: -> { WorkPackage.human_attribute_name(:responsible) } },
4346
assignee: { fn: ->(wp) { wp.assigned_to&.name }, label: -> { WorkPackage.human_attribute_name(:assigned_to) } },
4447
author: { fn: ->(wp) { wp.author&.name }, label: -> { WorkPackage.human_attribute_name(:author) } },
4548
category: { fn: ->(wp) { wp.category&.name }, label: -> { WorkPackage.human_attribute_name(:category) } },
4649
creation_date: { fn: ->(wp) { wp.created_at }, label: -> { WorkPackage.human_attribute_name(:created_at) } },
4750
estimated_time: { fn: ->(wp) { wp.estimated_hours }, label: -> { WorkPackage.human_attribute_name(:estimated_hours) } },
4851
finish_date: { fn: ->(wp) { wp.due_date }, label: -> { WorkPackage.human_attribute_name(:due_date) } },
49-
parent: { fn: ->(wp) { wp.parent&.id }, label: -> { WorkPackage.human_attribute_name(:parent) } },
52+
parent_id: { fn: ->(wp) { wp.parent&.id }, label: -> { WorkPackage.human_attribute_name(:parent_id) } },
53+
parent_assignee: { fn: ->(wp) { wp.parent&.assigned_to&.name }, label: -> {
54+
WorkPackage.human_attribute_name(:assigned_to)
55+
} },
5056
parent_author: { fn: ->(wp) { wp.parent&.author&.name }, label: -> { WorkPackage.human_attribute_name(:author) } },
5157
parent_category: { fn: ->(wp) { wp.parent&.category&.name },
5258
label: -> { WorkPackage.human_attribute_name(:category) } },
@@ -57,6 +63,7 @@ class TokenPropertyMapper
5763
parent_finish_date: { fn: ->(wp) { wp.parent&.due_date },
5864
label: -> { WorkPackage.human_attribute_name(:due_date) } },
5965
parent_priority: { fn: ->(wp) { wp.parent&.priority }, label: -> { WorkPackage.human_attribute_name(:priority) } },
66+
parent_subject: { fn: ->(wp) { wp.parent&.subject }, label: -> { WorkPackage.human_attribute_name(:subject) } },
6067
priority: { fn: ->(wp) { wp.priority }, label: -> { WorkPackage.human_attribute_name(:priority) } },
6168
project: { fn: ->(wp) { wp.project_id }, label: -> { WorkPackage.human_attribute_name(:project) } },
6269
project_active: { fn: ->(wp) { wp.project&.active? }, label: -> { Project.human_attribute_name(:active) } },

spec/models/types/patterns/token_property_mapper_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333
RSpec.describe Types::Patterns::TokenPropertyMapper do
3434
shared_let(:responsible) { create(:user, firstname: "Responsible") }
3535
shared_let(:assignee) { create(:user, firstname: "Assignee") }
36+
shared_let(:parent_assignee) { create(:user, firstname: "Parent", lastname: "Assignee") }
3637

3738
shared_let(:category) { create(:category) }
3839

3940
shared_let(:project) { create(:project, parent: create(:project), status_code: 1, status_explanation: "A Mess") }
4041

4142
shared_let(:work_package_parent) do
42-
create(:work_package, project:, category:, start_date: Date.yesterday, estimated_hours: 120, due_date: 3.months.from_now)
43+
create(:work_package, project:, category:, start_date: Date.yesterday, estimated_hours: 120,
44+
due_date: 3.months.from_now, assigned_to: parent_assignee)
4345
end
4446

4547
shared_let(:work_package) do

0 commit comments

Comments
 (0)