app/models/polymorphic/task.rb in fat_free_crm-0.16.4 vs app/models/polymorphic/task.rb in fat_free_crm-0.17.1

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Copyright (c) 2008-2013 Michael Dvorkin and contributors. # # Fat Free CRM is freely distributable under the terms of MIT license. # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ @@ -110,11 +112,11 @@ has_fields exportable validates_presence_of :user validates_presence_of :name, message: :missing_task_name - validates_presence_of :calendar, if: -> { self.bucket == 'specific_time' && !self.completed_at } + validates_presence_of :calendar, if: -> { bucket == 'specific_time' && !completed_at } validate :specific_time, unless: :completed? before_create :set_due_date before_update :set_due_date, unless: :completed? before_save :notify_assignee @@ -151,20 +153,19 @@ # Convert specific due_date to "due_today", "due_tomorrow", etc. bucket name. #---------------------------------------------------------------------------- def computed_bucket return bucket if bucket != "specific_time" - case - when overdue? + if overdue? "overdue" - when due_today? + elsif due_today? "due_today" - when due_tomorrow? + elsif due_tomorrow? "due_tomorrow" - when due_this_week? && !due_today? && !due_tomorrow? + elsif due_this_week? && !due_today? && !due_tomorrow? "due_this_week" - when due_next_week? + elsif due_next_week? "due_next_week" else "due_later" end end @@ -226,10 +227,10 @@ end end #---------------------------------------------------------------------------- def due_end_of_day? - due_at.present? && (due_at == due_at.end_of_day) + due_at.present? && (due_at.change(usec: 0) == due_at.end_of_day.change(usec: 0)) end #---------------------------------------------------------------------------- def due_beginning_of_day? due_at.present? && (due_at == due_at.beginning_of_day)