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