Skip to content

Instantly share code, notes, and snippets.

@gary
Created November 9, 2011 03:25
Show Gist options
  • Save gary/1350240 to your computer and use it in GitHub Desktop.
Save gary/1350240 to your computer and use it in GitHub Desktop.
Current week...
Timecop.freeze(Time.local(2011, 11, 8, 12, 0, 0))
start = Time.now - 2.days
finish = Time.now + 5.days
LeadAssignmentPeriod.blueprint do
start_date { start }
end_date { finish }
end
require 'spec_helper'
describe LeadAssignmentPeriod do
context 'scopes' do
context '.current' do
context 'when there is a period for the current week' do
before { LeadAssignmentPeriod.make!(:totaling_to_100) }
subject { LeadAssignmentPeriod.current }
it { should have(1).lead_assignment_period }
end
end
end
end
scope :current, lambda {
now = Time.now
where('start_date <= ?', now).
where('end_date >= ?', now)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment