Extracted specs from Rate#for for Rate#for_user_project_and_date #1920
This commit is contained in:
1 parent
3451286011
commit
24c445cce9
1 file changed
+37
@@ -218,3 +218,40 @@ describe Rate, 'for' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe Rate, 'for_user_project_and_date (private)' do
|
||||||
|
before(:each) do
|
||||||
|
@user = mock_model(User)
|
||||||
|
@project = mock_model(Project)
|
||||||
|
@date = '2009-01-01'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should find all the rates for a user on the project before the date' do
|
||||||
|
rate1 = mock_model(Rate, :amount => 50.50)
|
||||||
|
|
||||||
|
Rate.should_receive(:find).with(:first, {
|
||||||
|
:conditions => ["user_id IN (?) AND project_id IN (?) AND date_in_effect <= ?",
|
||||||
|
@user.id,
|
||||||
|
@project.id,
|
||||||
|
@date
|
||||||
|
],
|
||||||
|
:order => 'date_in_effect DESC'
|
||||||
|
}).and_return(rate1)
|
||||||
|
|
||||||
|
Rate.send(:for_user_project_and_date, @user, @project, @date)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return the value of the most recent rate found' do
|
||||||
|
rate1 = mock_model(Rate, :amount => 50.50)
|
||||||
|
|
||||||
|
Rate.should_receive(:find).with(:first, {
|
||||||
|
:conditions => ["user_id IN (?) AND project_id IN (?) AND date_in_effect <= ?",
|
||||||
|
@user.id,
|
||||||
|
@project.id,
|
||||||
|
@date
|
||||||
|
],
|
||||||
|
:order => 'date_in_effect DESC'
|
||||||
|
}).and_return(rate1)
|
||||||
|
Rate.send(:for_user_project_and_date, @user, @project, @date).should eql(rate1)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in new issue
Block a user