[#4225] Add the Deliverable as a criteria in the Time Entries Report.
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
module RedmineBudget
|
module RedmineBudget
|
||||||
module Hooks
|
module Hooks
|
||||||
class ControllerTimelogAvailableCriteriasHook < Redmine::Hook::ViewListener
|
class ControllerTimelogAvailableCriteriasHook < Redmine::Hook::ViewListener
|
||||||
|
# Adds the Deliverable as a filter to the Timelog Report
|
||||||
def controller_timelog_available_criterias(context={})
|
def controller_timelog_available_criterias(context={})
|
||||||
|
context[:available_criterias]["deliverable_id"] = {
|
||||||
|
:sql => "#{Issue.table_name}.deliverable_id",
|
||||||
|
:klass => Deliverable,
|
||||||
|
:label => :field_deliverable
|
||||||
|
}
|
||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,8 +12,44 @@ def request
|
|||||||
@request ||= ActionController::TestRequest.new
|
@request ||= ActionController::TestRequest.new
|
||||||
end
|
end
|
||||||
|
|
||||||
describe TimelogController, '#controller_timelog_available_criterias_hook', :type => :controller do
|
def run_hook
|
||||||
it 'should return an empty string' do
|
call_hook(:controller_timelog_available_criterias, {:available_criterias => @available_criterias})
|
||||||
call_hook(:controller_timelog_available_criterias, {}).should be_blank
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user