diff --git a/app/models/scheduled_show.rb b/app/models/scheduled_show.rb index 6e7b9434..2a8587c9 100644 --- a/app/models/scheduled_show.rb +++ b/app/models/scheduled_show.rb @@ -43,8 +43,6 @@ class ScheduledShow < ActiveRecord::Base validates_presence_of :start_at, :end_at, :playlist_id, :title, :dj_id validates :description, length: { maximum: 10_000 } - validate :start_at_cannot_be_in_the_past, on: :create - validate :end_at_cannot_be_in_the_past, on: :create validate :end_at_cannot_be_before_start_at, on: :create alias_attribute :start, :start_at @@ -227,18 +225,6 @@ def ensure_time_zone end end - def start_at_cannot_be_in_the_past - if start_at < Time.current - errors.add(:start_at, "cannot be in the past") - end - end - - def end_at_cannot_be_in_the_past - if end_at < Time.current - errors.add(:end_at, "cannot be in the past") - end - end - def end_at_cannot_be_before_start_at if end_at < start_at errors.add(:end_at, "cannot be before start at") diff --git a/spec/models/scheduled_show_spec.rb b/spec/models/scheduled_show_spec.rb index 19490ffd..d5c79769 100644 --- a/spec/models/scheduled_show_spec.rb +++ b/spec/models/scheduled_show_spec.rb @@ -91,18 +91,6 @@ end describe "validations" do - it "start time cannot be in the past" do - start_at = Chronic.parse("yesterday at 3:15 pm").utc - end_at = Chronic.parse("today at 2:15 pm").utc - @scheduled_show = ScheduledShow.create radio: @radio, playlist: @playlist, start_at: start_at, end_at: end_at, title: "hey", dj: @dj - expect(@scheduled_show.errors[:start_at]).to be_present - end - it "end time cannot be in the past" do - start_at = Chronic.parse("today at 3:15 pm").utc - end_at = Chronic.parse("2 days ago at 2:15 pm").utc - @scheduled_show = ScheduledShow.create radio: @radio, playlist: @playlist, start_at: start_at, end_at: end_at, title: "hey" - expect(@scheduled_show.errors[:end_at]).to be_present - end it "end time cannot be before start time" do start_at = Chronic.parse("today at 3:15 pm").utc end_at = Chronic.parse("today at 2:15 pm").utc