[#4389] Add the Deliverable filter to the Time Entry report.

This commit is contained in:
Eric Davis
2010-08-16 09:39:27 -07:00
parent a3e1aa277f
commit 620eaa262f
4 changed files with 74 additions and 0 deletions
+4
View File
@@ -28,6 +28,10 @@ class Deliverable < ActiveRecord::Base
''
end
def to_s
title
end
def to_underscore
self.class.to_s.underscore
end
+1
View File
@@ -85,3 +85,4 @@ require 'redmine_contracts/hooks/controller_issues_edit_before_save_hook'
require 'redmine_contracts/hooks/view_issues_bulk_edit_details_bottom_hook'
require 'redmine_contracts/hooks/controller_issues_bulk_edit_before_save_hook'
require 'redmine_contracts/hooks/helper_issues_show_detail_after_setting_hook'
require 'redmine_contracts/hooks/controller_timelog_available_criterias_hook'
@@ -0,0 +1,14 @@
module RedmineContracts
module Hooks
class ControllerTimelogAvailableCriteriasHook < Redmine::Hook::ViewListener
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
end
end
@@ -0,0 +1,55 @@
require File.dirname(__FILE__) + '/../../../../test_helper'
class RedmineContracts::Hooks::ControllerTimelogAvailableCriteriasTest < ActionController::TestCase
include Redmine::Hook::Helper
def controller
@controller ||= ApplicationController.new
@controller.response ||= ActionController::TestResponse.new
@controller
end
def request
@request ||= ActionController::TestRequest.new
end
def hook(args={})
call_hook :controller_timelog_available_criterias, args
end
def context
@context ||= {
:available_criterias => {"existing" => {:label => 'existing'}}
}
end
context "#controller_timelog_available_criterias" do
should "return an empty string" do
@response.body = hook(context)
assert @response.body.blank?
end
context "Deliverables" do
should "add a deliverable_id to the available criterias" do
@response.body = hook(context)
assert context[:available_criterias]['deliverable_id']
end
should "add the deliverable sql to the available criterias" do
@response.body = hook(context)
assert "issues.deliverable_id", context[:available_criterias]['deliverable_id'][:sql]
end
should "add the deliverable Class to the available criterias" do
@response.body = hook(context)
assert Deliverable, context[:available_criterias]['deliverable_id'][:klass]
end
should "add the deliverable label to the available criterias" do
@response.body = hook(context)
assert :field_deliverable, context[:available_criterias]['deliverable_id'][:label]
end
end
end
end