diff --git a/lib/overhead_time_entry_activity_patch.rb b/lib/overhead_time_entry_activity_patch.rb index 2fa454d..7a912f9 100644 --- a/lib/overhead_time_entry_activity_patch.rb +++ b/lib/overhead_time_entry_activity_patch.rb @@ -39,6 +39,7 @@ module OverheadTimeEntryActivityPatch return false unless field custom_value = self.custom_value_for(field) + return false unless custom_value if field.field_format == 'bool' # Map string values to proper booleans diff --git a/lib/overhead_timesheet_hook.rb b/lib/overhead_timesheet_hook.rb index 22f5e67..12481af 100644 --- a/lib/overhead_timesheet_hook.rb +++ b/lib/overhead_timesheet_hook.rb @@ -3,4 +3,13 @@ class OverheadTimesheetHook < Redmine::Hook::ViewListener def plugin_timesheet_views_timesheet_group_header(context={}) return content_tag(:th, l(:overhead_field_billable)) end + + def plugin_timesheet_views_timesheet_time_entry(context={}) + time_entry = context[:time_entry] + if time_entry && time_entry.billable? + content_tag(:td, image_tag('true.png')) + else + content_tag(:td,'') + end + end end diff --git a/spec/lib/overhead_timesheet_hook_spec.rb b/spec/lib/overhead_timesheet_hook_spec.rb index 39b097a..d23aa67 100644 --- a/spec/lib/overhead_timesheet_hook_spec.rb +++ b/spec/lib/overhead_timesheet_hook_spec.rb @@ -5,3 +5,32 @@ describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_group_header" OverheadTimesheetHook.instance.plugin_timesheet_views_timesheet_group_header.should eql('Billable') end end + +describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_time_entry" do + before(:each) do + end + + def call_hook(time_entry) + context = {:time_entry => time_entry} + return OverheadTimesheetHook.instance.plugin_timesheet_views_timesheet_time_entry(context) + end + + it 'should add a table cell' do + time_entry = mock_model(TimeEntry, :billable? => false) + call_hook(time_entry).should have_tag('td') + end + + it "should be an empty cell if a time entry isn't billable" do + time_entry = mock_model(TimeEntry) + time_entry.should_receive(:billable?).and_return(false) + call_hook(time_entry).should have_tag('td','') + end + + it "should have a checkbox if a time entry is billable" do + time_entry = mock_model(TimeEntry) + time_entry.should_receive(:billable?).and_return(true) + call_hook(time_entry).should have_tag('td') do + with_tag('img[src*=?]','true.png') + end + end +end