Ported HourlyDeliverable.spent to use Rate. #1924

This commit is contained in:
Eric Davis
2009-01-21 14:27:12 -08:00
parent 5510753a4b
commit 50a466d7af
2 changed files with 5 additions and 6 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ class HourlyDeliverable < Deliverable
# Find each Member for their rate
time_logs.each do |time_log|
member = Member.find_by_user_id_and_project_id(time_log.user_id, time_log.project_id)
total += (member.rate * time_log.hours) unless member.nil? || member.rate.nil?
rate = Rate.amount_for(time_log.user, time_log.project, time_log.spent_on)
total += (rate * time_log.hours) unless rate.nil?
end
return total
+3 -4
View File
@@ -13,12 +13,11 @@ describe HourlyDeliverable, '.spent' do
@user = mock_model(User)
@issue1 = mock_model(Issue)
@issue_1_time_entry = mock_model(TimeEntry, :issue_id => @issue1.id, :user_id => @user.id, :project_id => @project.id, :hours => 1.0)
@issue_1_time_entry = mock_model(TimeEntry, :issue_id => @issue1.id, :user => @user, :project => @project, :hours => 1.0, :spent_on => Date.today)
@issue1.stub!(:time_entries).and_return([@issue_1_time_entry])
@member = mock_model(Member, :user => @user, :project => @project, :rate => 60.0)
Member.should_receive(:find_by_user_id_and_project_id).with(@user.id, @project.id).and_return(@member)
Rate.should_receive(:amount_for).with(@user, @project, @issue_1_time_entry.spent_on).and_return(60.0)
@deliverable = HourlyDeliverable.new({ :subject => 'test' })
@issues = [@issue1]
@deliverable.should_receive(:issues).twice.and_return(@issues)