[#4327] Add a select field to selecting the deliverable for an issue.

This commit is contained in:
Eric Davis
2010-08-02 16:07:59 -07:00
parent ad8dec8638
commit 729acf200d
5 changed files with 66 additions and 29 deletions
@@ -0,0 +1,9 @@
<% if project.module_enabled?(:contracts) %>
<p>
<% options = project.contracts.inject([]) {|data, contract|
data << [contract.name, contract.deliverables.collect {|d| [d.title, d.id]} ]
} %>
<%= form.select(:deliverable_id, grouped_options_for_select(options, issue.deliverable_id), {:include_blank => true}) %>
</p>
<% end %>
@@ -1,9 +1,7 @@
module RedmineContracts
module Hooks
class ViewIssuesFormDetailsBottomHook < Redmine::Hook::ViewListener
def view_issues_form_details_bottom(context={})
return ''
end
render_on(:view_issues_form_details_bottom, :partial => 'issues/edit_deliverable', :layout => false)
end
end
end
@@ -0,0 +1,52 @@
require File.dirname(__FILE__) + '/../../../test_helper'
class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionController::IntegrationTest
include Redmine::Hook::Helper
context "#view_issues_form_details_bottom" do
setup do
@project = Project.generate!
@issue = Issue.generate_for_project!(@project)
@contract1 = Contract.generate!(:project => @project)
@contract2 = Contract.generate!(:project => @project)
@manager = User.generate!(:login => 'manager', :password => 'existing', :password_confirmation => 'existing')
@role = Role.generate!(:permissions => [:view_issues, :edit_issues])
User.add_to_project(@manager, @project, @role)
@deliverable1 = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'The Title')
@deliverable2 = FixedDeliverable.generate!(:contract => @contract2, :manager => @manager, :title => 'The Title')
@issue.deliverable = @deliverable1
login_as('manager', 'existing')
end
context "with Contracts Enabled" do
setup do
visit_issue_page(@issue)
end
should "render the a select field for the deliverables with all of the deliverables grouped by contract" do
assert_select "select#issue_deliverable_id" do
assert_select "optgroup[label=?]", @contract1.name do
assert_select "option", :text => /#{@deliverable1.title}/
end
assert_select "optgroup[label=?]", @contract2.name do
assert_select "option", :text => /#{@deliverable2.title}/
end
end
end
end
context "with Contracts Disabled" do
setup do
@project.enabled_modules.collect {|m| m.destroy if m.name == 'contracts' }
visit_issue_page(@issue)
end
should "not render the deliverable select field" do
assert_select 'select#issue_deliverable_id', :count => 0
end
end
end
end
+4
View File
@@ -71,6 +71,10 @@ module IntegrationTestHelper
assert_template 'contracts/show'
end
def visit_issue_page(issue)
visit '/issues/' + issue.id.to_s
end
def assert_forbidden
assert_response :forbidden
assert_template 'common/403'
@@ -1,26 +0,0 @@
require File.dirname(__FILE__) + '/../../../../test_helper'
class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < 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 :view_issues_form_details_bottom, args
end
context "#view_issues_form_details_bottom" do
should "return an empty string" do
@response.body = hook
assert @response.body.blank?
end
end
end