From 2b7cfa4dbca93d0767646018dd5a22cc5c13166e Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 20 Jan 2009 14:16:28 -0800 Subject: [PATCH] Added specs to cover if Rate.for doesn't find anything. #1918 --- spec/models/rate_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/models/rate_spec.rb b/spec/models/rate_spec.rb index 35a1917..11accf4 100644 --- a/spec/models/rate_spec.rb +++ b/spec/models/rate_spec.rb @@ -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