[#2281] Added a TimeEntry#billable? method which is delegated to
TimeEntryActivity#billable?
This commit is contained in:
2
init.rb
2
init.rb
@@ -2,8 +2,10 @@ require 'redmine'
|
||||
|
||||
# Patches to the Redmine core.
|
||||
require 'dispatcher'
|
||||
require 'overhead_time_entry_patch'
|
||||
require 'overhead_time_entry_activity_patch'
|
||||
Dispatcher.to_prepare do
|
||||
TimeEntry.send(:include, OverheadTimeEntryPatch)
|
||||
TimeEntryActivity.send(:include, OverheadTimeEntryActivityPatch)
|
||||
end
|
||||
|
||||
|
||||
11
lib/overhead_time_entry_patch.rb
Normal file
11
lib/overhead_time_entry_patch.rb
Normal 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
|
||||
|
||||
21
spec/lib/overhead_time_entry_patch_spec.rb
Normal file
21
spec/lib/overhead_time_entry_patch_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user