Added specs to cover if Rate.for doesn't find anything. #1918

This commit is contained in:
Eric Davis
2009-01-20 14:16:28 -08:00
parent 6f0666d854
commit 2b7cfa4dbc

View File

@@ -168,6 +168,11 @@ describe Rate, 'for' do
Rate.should_receive(:for_user_project_and_date).with(@user, @project, @date).and_return(@rate)
Rate.for(@user, @project, @date).should eql(@rate.amount)
end
it 'should return nil if no rate is found' do
Rate.should_receive(:for_user_project_and_date).with(@user, @project, @date).and_return(nil)
Rate.for(@user, @project, @date).should be_nil
end
end
describe 'with a user and project' do
@@ -180,6 +185,11 @@ describe Rate, 'for' do
Rate.should_receive(:for_user_project_and_date).with(@user, @project, Date.today.to_s).and_return(@rate)
Rate.for(@user, @project).should eql(@rate.amount)
end
it 'should return nil if no rate is found' do
Rate.should_receive(:for_user_project_and_date).with(@user, @project, Date.today.to_s).and_return(nil)
Rate.for(@user, @project).should be_nil
end
end
describe 'with a user' do
@@ -192,6 +202,11 @@ describe Rate, 'for' do
Rate.should_receive(:for_user_project_and_date).with(@user, nil, Date.today.to_s).and_return(@rate)
Rate.for(@user).should eql(@rate.amount)
end
it 'should return nil if no rate is found' do
Rate.should_receive(:for_user_project_and_date).with(@user, nil, Date.today.to_s).and_return(nil)
Rate.for(@user).should be_nil
end
end
it 'with an invalid user should raise an InvalidParameterException' do