Permalink
Browse files

consider ending day of month for custom permalink

  • Loading branch information...
1 parent 59a0c46 commit 189c2d0fd073e17e1c05b2a716b58a5b291c4c1f @morygonzalez committed Apr 15, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 lib/lokka/helpers.rb
  2. +1 −1 spec/unit/helpers_spec.rb
@@ -407,7 +407,10 @@ def custom_permalink_entry(path)
end
args = [0,1,1,0,0,0].each_with_index.map{|default,i| args[i] || default }
conditions[:created_at.gte] = Time.local(*args)
- args[time_order.index(last)-1] += 1
+ day_end = {:hour => 23, :minute => 59, :second => 59}
+ day_end.each_pair do |key, value|
+ args[time_order.index(key)] = value.to_i
+ end
conditions[:created_at.lt] = Time.local(*args)
end
Entry.first(conditions)
@@ -41,7 +41,7 @@
it 'should parse date condition' do
Entry.should_receive(:first).with(:slug => 'slug',
:created_at.gte => Time.local(2011, 1, 9),
- :created_at.lt => Time.local(2011, 1, 10))
+ :created_at.lt => Time.local(2011, 1, 9, 23, 59, 59))
custom_permalink_entry('/2011/01/09/slug')
end

0 comments on commit 189c2d0

Please sign in to comment.