Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Close the last review gaps of the additional details

Guido Boyke57de87e8502a
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
index ceaddcb..9bc5e20 100644
--- a/app/helpers/people_helper.rb
+++ b/app/helpers/people_helper.rb
@@ -184,10 +184,9 @@ module PeopleHelper
({ label: Person.human_attribute_name(:function), value: person.function } if person&.function.present?),
({ label: Person.human_attribute_name(:department), value: person.department } if person&.department.present?),
({ label: Person.human_attribute_name(:company), value: person.company } if person&.company.present?),
- if email.present?
- { label: Person.human_attribute_name(:email), value: email,
- href: PersonDetail.new('kind' => 'email', 'value' => email).href, icon: 'bi-envelope' }
- end,
+ # A member's email is the account's, checked by Devise only: linked as
+ # it is, not through PersonDetail's stricter rule.
+ ({ label: Person.human_attribute_name(:email), value: email, href: "mailto:#{email}", icon: 'bi-envelope' } if email.present?),
if phone.present?
{ label: Person.human_attribute_name(:phone), value: phone, href: PersonDetail.new('kind' => 'phone', 'value' => phone).href,
icon: 'bi-telephone', mono: true, action: t('views.organisations.people.show.call') }
diff --git a/app/models/person_detail.rb b/app/models/person_detail.rb
index 46ffd73..42493a4 100644
--- a/app/models/person_detail.rb
+++ b/app/models/person_detail.rb
@@ -153,8 +153,14 @@ class PersonDetail
end
end
+ # The date of a date detail, or nil. The rule of a browser's date field:
+ # Gregorian, from year 1 (Ruby alone takes year 0 and Julian leap days
+ # before 1582, which the field would show empty and the next save lose).
def date
- Date.iso8601(value) if kind == 'date' && ISO_DATE.match?(value)
+ return unless kind == 'date' && ISO_DATE.match?(value)
+
+ parsed = Date.iso8601(value, Date::GREGORIAN)
+ parsed if parsed.year.positive?
rescue Date::Error
nil
end
diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb
index 1323c26..4a2d3f0 100644
--- a/spec/helpers/people_helper_spec.rb
+++ b/spec/helpers/people_helper_spec.rb
@@ -125,11 +125,11 @@ RSpec.describe PeopleHelper, type: :helper do
expect(fields_for(phone: 'nur Zentrale').first[:href]).to be_nil
end
- # Review round 2, finding 6: the fixed email links through the same rule.
- it 'links the fixed email through PersonDetail, and not a malformed one' do
- expect(helper.person_fields(Person.new(name: 'M', email: '[email protected]'), nil).first[:href])
- .to eq('mailto:[email protected]')
- expect(helper.person_fields(Person.new(name: 'M', email: 'kaputt'), nil).first[:href]).to be_nil
+ # Review round 3, finding 3: the fixed email is the account's for a member,
+ # checked by Devise only; it keeps its link as before.
+ it 'links the fixed email as it is, also one only Devise accepts' do
+ expect(helper.person_fields(Person.new(name: 'M', email: 'jö[email protected]'), nil).first[:href])
+ .to eq('mailto:jö[email protected]')
end
it 'shows no line for a person without details' do
diff --git a/spec/models/person_detail_spec.rb b/spec/models/person_detail_spec.rb
index 01e4a3b..082e59b 100644
--- a/spec/models/person_detail_spec.rb
+++ b/spec/models/person_detail_spec.rb
@@ -124,6 +124,17 @@ RSpec.describe PersonDetail do
end
end
+ # Review round 3, finding 1: a date the browser's date field cannot hold
+ # (year 0, a Julian leap day) came back empty and was lost on the next save.
+ it 'refuses a date a date field cannot hold: year 0 and a Julian-only leap day' do
+ %w[0000-05-01 1500-02-29].each do |value|
+ expect(problems(detail(kind: 'date', value: value))).to eq([[:invalid_date, { position: 1 }]]), value
+ expect(described_class.new(detail(kind: 'date', value: value)).date).to be_nil
+ end
+ expect(problems(detail(kind: 'date', value: '0001-01-01'))).to eq([])
+ expect(problems(detail(kind: 'date', value: '1600-02-29'))).to eq([])
+ end
+
it 'refuses an impossible date and the other ISO forms (week, ordinal, compact)' do
%w[2026-02-30 2026-W44-3 2026-301 20261028 2026-10-28T10:00].each do |value|
expect(problems(detail(kind: 'date', value: value))).to eq([[:invalid_date, { position: 1 }]]), value
diff --git a/spec/system/people_additional_details_spec.rb b/spec/system/people_additional_details_spec.rb
index 42f9733..6b3c730 100644
--- a/spec/system/people_additional_details_spec.rb
+++ b/spec/system/people_additional_details_spec.rb
@@ -148,6 +148,9 @@ RSpec.describe 'People additional details in the form', type: :system do
open_form
add_button.click
add_button.click
+ # Review round 3, finding 2: the template's own number is 0-based.
+ expect(rows.map { |row| row['aria-label'] })
+ .to eq([1, 2].map { |n| I18n.t('views.organisations.people.form.detail_position', position: n) })
expect(page.evaluate_script('document.activeElement === document.querySelectorAll("[data-person-details-target=list] select")[1]'))
.to be(true)