Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def attribute(key, label_fn, value_fn, formatter = STRING_OR_NIL)
attribute(:parent_subject, -> { WorkPackage.human_attribute_name(:subject) }, ->(parent) { parent.subject }),
attribute(:parent_status, -> { WorkPackage.human_attribute_name(:status) }, ->(parent) { parent.status }),
attribute(:parent_type, -> { WorkPackage.human_attribute_name(:type) }, ->(parent) { parent.type }),
attribute(:parent_version, -> { WorkPackage.human_attribute_name(:version) }, ->(parent) { parent.version }),
attribute(:parent_version, -> { Setting::WorkPackageMultipleVersions.active? ? WorkPackage.human_attribute_name(:target_versions) : WorkPackage.human_attribute_name(:version) }, ->(parent) { parent.target_versions }, ARRAY),
attribute(:priority, -> { WorkPackage.human_attribute_name(:priority) }, ->(wp) { wp.priority }),
attribute(:project_id, -> { Project.human_attribute_name(:id) }, ->(project) { project.id }),
attribute(:project_active, -> { Project.human_attribute_name(:active) }, ->(project) { project.active? }),
Expand All @@ -75,7 +75,7 @@ def attribute(key, label_fn, value_fn, formatter = STRING_OR_NIL)
attribute(:start_date, -> { WorkPackage.human_attribute_name(:start_date) }, ->(wp) { wp.start_date }, DATE),
attribute(:status, -> { WorkPackage.human_attribute_name(:status) }, ->(wp) { wp.status }),
attribute(:type, -> { WorkPackage.human_attribute_name(:type) }, ->(wp) { wp.type }),
attribute(:version, -> { WorkPackage.human_attribute_name(:version) }, ->(wp) { wp.version })
attribute(:version, -> { Setting::WorkPackageMultipleVersions.active? ? WorkPackage.human_attribute_name(:target_versions) : WorkPackage.human_attribute_name(:version) }, ->(wp) { wp.target_versions }, ARRAY)
].freeze
# rubocop:enable Layout/LineLength

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,38 @@
expect(token.call(sub_work_package)).to eq("Task")
end
end

context "for versions" do
shared_let(:second_version) { create(:version, project:) }

before do
create(:work_package_version, work_package:, version: second_version, kind: :target)
end

context "when work package multiple versions is active",
with_flag: { work_package_multiple_versions: true },
with_settings: { work_package_multiple_versions: true } do
it "renders an array of values" do
enabled, = subject
token = detect(enabled, :version)

expect(token.call(work_package)).to eq("#{version.name}, #{second_version.name}")
end

it "label is target versions" do
enabled, = subject
expect(detect(enabled, :version)&.label).to eq("Target versions")
end
end

context "when work package multiple versions is not active",
with_settings: { work_package_multiple_versions: false } do
it "label is version" do
enabled, = subject
expect(detect(enabled, :version)&.label).to eq("Version")
end
end
end
end

private
Expand Down
Loading