Fix crash with budgets with no published phases

In this case, the duration of the budget cannot be determined, and the
application was crashing when trying to do so.

Now we're just returning `nil` as duration.
This commit is contained in:
Javi Martín
2021-05-20 14:45:53 +02:00
parent 69ade5b131
commit 93a7d28a82
4 changed files with 29 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ class Admin::Budgets::DurationComponent < ApplicationComponent
end
def duration
distance_of_time_in_words(durable.starts_at, durable.ends_at)
distance_of_time_in_words(durable.starts_at, durable.ends_at) if durable.starts_at && durable.ends_at
end
private