[#2281] Added a TimeEntry#billable? method which is delegated to

TimeEntryActivity#billable?
This commit is contained in:
Eric Davis
2009-04-21 17:06:28 -07:00
parent ea38554820
commit adf17f8ed7
3 changed files with 34 additions and 0 deletions

View File

@@ -2,8 +2,10 @@ require 'redmine'
# Patches to the Redmine core. # Patches to the Redmine core.
require 'dispatcher' require 'dispatcher'
require 'overhead_time_entry_patch'
require 'overhead_time_entry_activity_patch' require 'overhead_time_entry_activity_patch'
Dispatcher.to_prepare do Dispatcher.to_prepare do
TimeEntry.send(:include, OverheadTimeEntryPatch)
TimeEntryActivity.send(:include, OverheadTimeEntryActivityPatch) TimeEntryActivity.send(:include, OverheadTimeEntryActivityPatch)
end end

View File

@@ -0,0 +1,11 @@
require_dependency 'time_entry'
module OverheadTimeEntryPatch
def self.included(base)
base.class_eval do
unloadable
delegate :billable?, :to => :activity
end
end
end

View File

@@ -0,0 +1,21 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe TimeEntry, 'billable?' do
before(:each) do
@time_entry = TimeEntry.new
end
it 'should be true if the activity is considered billable' do
@time_entry.should_receive(:activity).and_return do
mock_model(TimeEntryActivity, :billable? => true)
end
@time_entry.billable?.should be_true
end
it 'should be false if the activity is considered overhead' do
@time_entry.should_receive(:activity).and_return do
mock_model(TimeEntryActivity, :billable? => false)
end
@time_entry.billable?.should be_false
end
end