Skip to content

Commit

Permalink
Don't show talks that are scheduled >= 28 days out
Browse files Browse the repository at this point in the history
  • Loading branch information
zenspider committed Mar 6, 2013
1 parent 32b340e commit b7d89a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/models/talk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ class Talk < ActiveRecord::Base
presenter,
title"

scope :available, by_kind.where(:completed => false)
def self.available
by_kind.where("completed = ? and (scheduled_date is NULL or scheduled_date < ?)",
false,
28.days.from_now)
end

validates(:kind,
:inclusion => {
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/talks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def test_talks_sorted_on_scheduled_date_kind_and_title
setup_talks

@beg_two.scheduled_date = 2.month.from_now
@int_two.scheduled_date = 1.months.from_now
@int_two.scheduled_date = 27.days.from_now
@beg_two.save
@int_two.save

get :index

expected = [@int_two, @beg_two,
expected = [@int_two,
@beg_one, @talk,
@int_one,
@adv_one, @adv_two,
Expand Down

0 comments on commit b7d89a4

Please sign in to comment.