Skip to content

Commit

Permalink
Correctly parese the duration
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Dec 17, 2024
1 parent 2dce08c commit fce7dfe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 4 additions & 1 deletion app/contracts/work_packages/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ def validate_people_visible(attribute, id_attribute, list)
end

def validate_duration_integer
errors.add :duration, :not_an_integer if model.duration_before_type_cast != model.duration
if (!model.duration_before_type_cast.is_a?(String) && model.duration_before_type_cast != model.duration) ||
(model.duration_before_type_cast.is_a?(String) && model.duration_before_type_cast.to_i.to_s != model.duration_before_type_cast)
errors.add :duration, :not_an_integer
end
end

def validate_duration_matches_dates
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/work_packages/date_picker_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ def schedule_manually

def work_package_datepicker_params
if params[:work_package]
# Transform to an Integer as the duration parameter is strictly expected to be an Integer
# Todo ?
params.require(:work_package)[:duration] =
begin
Integer(String(params.require(:work_package)[:duration]))
rescue StandardError
ArgumentError
end

params.require(:work_package)
.slice(*allowed_touched_params)
.merge(schedule_manually:)
Expand Down

0 comments on commit fce7dfe

Please sign in to comment.