Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-implement today method

  • Loading branch information...
commit f543fbd08d434041dbe461ca5f87102c918eecf1 1 parent 5d5059f
@radar authored
Showing with 16 additions and 0 deletions.
  1. +5 −0 lib/by_star/by_day.rb
  2. +11 −0 spec/by_star/by_day_spec.rb
View
5 lib/by_star/by_day.rb
@@ -8,6 +8,11 @@ def by_day(*args)
send("by_day_#{time_klass(time)}", time, options)
end
+ def today(options={})
+ time = Time.zone.now
+ by_day_Time_or_Date(time, options)
+ end
+
private
def by_day_Time_or_Date(time, options)
View
11 spec/by_star/by_day_spec.rb
@@ -21,3 +21,14 @@ def posts_count(*args)
Event.by_day(Time.now.yesterday, :field => "start_time").size.should eql(1)
end
end
+
+describe "today" do
+ it "should show the post for today" do
+ Post.today.map(&:text).should include("Today's post")
+ end
+
+ it "should be able to use an alternative field" do
+ # Test may occur on an event day.
+ Event.today(:field => "start_time").size.should eql(1)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.