Created
November 9, 2011 03:25
-
-
Save gary/1350240 to your computer and use it in GitHub Desktop.
Current week...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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