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
14 changes: 0 additions & 14 deletions app/models/scheduled_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 0 additions & 12 deletions spec/models/scheduled_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading