diff --git a/lib/overhead_timesheet_hook.rb b/lib/overhead_timesheet_hook.rb
index f07ee70..32dc57b 100644
--- a/lib/overhead_timesheet_hook.rb
+++ b/lib/overhead_timesheet_hook.rb
@@ -19,4 +19,9 @@ class OverheadTimesheetHook < Redmine::Hook::ViewListener
content_tag(:td,'')
end
end
+
+ # Added a new field for filtering based on "billable?"
+ def plugin_timesheet_views_timesheet_form(context={})
+ context[:controller].send(:render_to_string, :partial => 'timesheet/overhead_form', :layout => false)
+ end
end
diff --git a/spec/lib/overhead_timesheet_hook_spec.rb b/spec/lib/overhead_timesheet_hook_spec.rb
index 11db940..fa6b6f2 100644
--- a/spec/lib/overhead_timesheet_hook_spec.rb
+++ b/spec/lib/overhead_timesheet_hook_spec.rb
@@ -1,5 +1,10 @@
require File.dirname(__FILE__) + '/../spec_helper'
+# Hack to make RSpec play nicely with call_hook's default contexts
+def stub_view_to_use_controller_instance
+ self.stub!(:controller).and_return(@controller)
+end
+
describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_group_header" do
it 'should add a Billable column to the table' do
OverheadTimesheetHook.instance.plugin_timesheet_views_timesheet_group_header.should eql('
Billable
')
@@ -40,3 +45,19 @@ describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_time_entry" d
end
end
end
+
+describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_form", :type => :view do
+ include Redmine::Hook::Helper
+
+ before(:each) do
+ stub_view_to_use_controller_instance
+ end
+
+ it 'should add a "Billable" label' do
+ response = call_hook(:plugin_timesheet_views_timesheet_form, {})
+ response.should have_tag('label[class=?][for=?]', 'select_all', 'timesheet[billable][]')
+ end
+
+ it 'should add a multple select field called "billable"'
+ it 'should pre-select the values from the submission'
+end