[#2280] Added a Billable cell with the green checkbox depending on if a
Time Entry is billable or not.
This commit is contained in:
@@ -39,6 +39,7 @@ module OverheadTimeEntryActivityPatch
|
|||||||
return false unless field
|
return false unless field
|
||||||
|
|
||||||
custom_value = self.custom_value_for(field)
|
custom_value = self.custom_value_for(field)
|
||||||
|
return false unless custom_value
|
||||||
|
|
||||||
if field.field_format == 'bool'
|
if field.field_format == 'bool'
|
||||||
# Map string values to proper booleans
|
# Map string values to proper booleans
|
||||||
|
|||||||
@@ -3,4 +3,13 @@ class OverheadTimesheetHook < Redmine::Hook::ViewListener
|
|||||||
def plugin_timesheet_views_timesheet_group_header(context={})
|
def plugin_timesheet_views_timesheet_group_header(context={})
|
||||||
return content_tag(:th, l(:overhead_field_billable))
|
return content_tag(:th, l(:overhead_field_billable))
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -5,3 +5,32 @@ describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_group_header"
|
|||||||
OverheadTimesheetHook.instance.plugin_timesheet_views_timesheet_group_header.should eql('<th>Billable</th>')
|
OverheadTimesheetHook.instance.plugin_timesheet_views_timesheet_group_header.should eql('<th>Billable</th>')
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user