Skip to content
Merged
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
7 changes: 7 additions & 0 deletions app/controllers/workloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def index
# Make sure that last_day is at most 12 months after first_day to prevent
# long running times
@last_day = [(@first_day >> 12) - 1, @last_day].min

# Make sure that today is not after last_day to prevent a crash in the
# workload calculation (today would be outside the time span)
@today_capped = @today > @last_day
@today = [@today, @last_day].min

@time_span_to_display = @first_day..@last_day

if @date_check
Expand All @@ -56,6 +62,7 @@ def index
respond_to do |format|
format.html do
flash.now[:error] = l(:error_date_setting) unless @date_check
flash.now[:warning] = l(:warning_today_capped_to_last_day) if @today_capped
render action: :index
end

Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ de:
workload_unscheduled_issues_num: 'Anzahl ungeplanter Tickets:'
workload_unscheduled_issues_hours: 'Stunden aus ungeplanten Tickets:'
error_date_setting: 'Überprüfen Sie Ihre Eingabe! Das Enddatum (bis) liegt vor dem Startdatum (von).'
warning_today_capped_to_last_day: 'Das "Als Heute verwenden"-Datum lag nach dem Enddatum und wurde auf das Enddatum gesetzt.'
error_encoding_setting: 'Zeichenkodierung nicht erlaubt. Gültige Werte: %{value}.'
label_workload_calculation: Workloadberechnung
label_include_parent_tasks: Hauptaufgaben einbeziehen
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ en:
workload_unscheduled_issues_num: 'Number of unscheduled issues:'
workload_unscheduled_issues_hours: 'Hours of unscheduled issues:'
error_date_setting: 'Please check your data! The end date is before the start date.'
warning_today_capped_to_last_day: 'The "Use as today" date was after the end date and has been set to the end date.'
error_encoding_setting: 'Character encoding not allowed. Valid values: %{value}.'
label_workload_calculation: Workload calculation
label_include_parent_tasks: Include parent tasks
Expand Down
26 changes: 26 additions & 0 deletions test/functional/workloads_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,31 @@ class WorkloadsControllerTest < ActionDispatch::IntegrationTest
get workloads_path(workload: { start_date: 'not-a-date' })
assert_response :success
end

test 'should get index without error when start_date is after last_day' do
manager = roles :roles_001
manager.add_permission! :view_all_workloads
log_user('jsmith', 'jsmith')

get workloads_path(workload: {
first_day: '2026-01-01',
last_day: '2026-01-31',
start_date: '2026-06-01'
})
assert_response :success
end

test 'should show warning when start_date is after last_day' do
manager = roles :roles_001
manager.add_permission! :view_all_workloads
log_user('jsmith', 'jsmith')

get workloads_path(workload: {
first_day: '2026-01-01',
last_day: '2026-01-31',
start_date: '2026-06-01'
})
assert flash[:warning].present?
end
end
end
Loading