[#4225] Add the Deliverable as a criteria in the Time Entries Report.

This commit is contained in:
Eric Davis
2010-07-01 13:34:24 -07:00
parent e25f841fe2
commit aa9649fde3
2 changed files with 46 additions and 4 deletions

View File

@@ -1,7 +1,13 @@
module RedmineBudget
module Hooks
class ControllerTimelogAvailableCriteriasHook < Redmine::Hook::ViewListener
# Adds the Deliverable as a filter to the Timelog Report
def controller_timelog_available_criterias(context={})
context[:available_criterias]["deliverable_id"] = {
:sql => "#{Issue.table_name}.deliverable_id",
:klass => Deliverable,
:label => :field_deliverable
}
return ''
end
end

View File

@@ -12,8 +12,44 @@ def request
@request ||= ActionController::TestRequest.new
end
describe TimelogController, '#controller_timelog_available_criterias_hook', :type => :controller do
it 'should return an empty string' do
call_hook(:controller_timelog_available_criterias, {}).should be_blank
end
def run_hook
call_hook(:controller_timelog_available_criterias, {:available_criterias => @available_criterias})
end
describe TimelogController, '#controller_timelog_available_criterias_hook', :type => :controller do
before(:each) do
@available_criterias = {
'project' => {:sql => 'project_id', :klass => Project, :label => :label_project}
}
end
it "should always return an empty string" do
run_hook.should be_blank
end
it "should add a new hash to the available_criterias" do
run_hook
@available_criterias.should have(2).keys
@available_criterias.key?('deliverable_id').should be_true
end
it "should set the :sql field to use the issue's deliverable_id" do
run_hook
@available_criterias['deliverable_id'][:sql].should eql("issues.deliverable_id")
end
it "should set the :klass field to Deliverable" do
run_hook
@available_criterias['deliverable_id'][:klass].should eql(Deliverable)
end
it "should set the :label field to :field_deliverable" do
run_hook
@available_criterias['deliverable_id'][:label].should eql(:field_deliverable)
end
end